pyserial and com port interrupts
Neil Benn
benn at cenix-bioscience.com
Thu Jan 13 07:49:56 EST 2005
Neil Benn wrote:
> engsol wrote:
>
>> Has anyone done a script that will rspond to the serial com port(s)
>> receive buffer interrupt, as opposed to polling and timeouts? Win2000
>> is the main interest right now.
>> Thanks
>> Norm B
>>
>>
> Hello,
>
> I came across this problem as when I first used PySerial, I
> came from a java background which has the ability to register
> listeners to a serial comm instance and receive interrupts (although
> some implementations use polling behind the scenes anyway). I don't
> think that pyserial has this kind of thing so I used the following :
<snip>
Tabs got screwed up here is teh code again :
def __checkSerial(self):
self.__objLock.acquire()
try:
try:
intNoChars = self.__objSerialPort.inWaiting()
if (intNoChars > 0):
strReceivedString =
self.__objSerialPort.read(intNoChars)
self.newMessage(strReceivedString)
except:
raise
finally:
self.__objLock.release()
Cheers,
Neil
--
Neil Benn
Senior Automation Engineer
Cenix BioScience
BioInnovations Zentrum
Tatzberg 47
D-01307
Dresden
Germany
Tel : +49 (0)351 4173 154
e-mail : benn at cenix-bioscience.com
Cenix Website : http://www.cenix-bioscience.com
More information about the Python-list
mailing list