pyserial

Philippe Martin pmartin at snakecard.com
Thu Feb 23 14:42:05 EST 2006


Hi,

I never found the need to flush anything and I always use inWaiting prior to
reader.

A+

Philippe



Mimi wrote:

> Hi,
> I use the pyserial to read data from a serial port.
> My code is in window Xp and python 2.4. when I use Hyperteminal I can
> read data without try and try again that it is not the case with
> pyserial library.
> anyone can help me ?
> this is a part of my code:
> 
> self.ser = serial.Serial()
>     self.ser.baudrate = 9600
>             self.ser.port = 3
>             self.ser.timeout= 10
>             self.ser.bytesize = serial.EIGHTBITS
>             self.ser.stopbits = serial.STOPBITS_ONE
>             self.ser.xonxoff = 0
> 
>    nbHisto = 144
>    for i in range(0,nbHisto):
>                 while 1:
>                     print self.ser.flushInput()
>                     print self.ser.flushOutput()
>                     cmd = "%xs\r" %(i+1)
>                     self.ser.write("%s" %cmd)
> 
>                     #print cmd
> 
>                     histo = self.ser.readlines()
>                     #print histo
>                     if histo:
>                         if histo=="\r\n":
>                             pass
>                         else:
> 
>                             histoAdresse = int(histo[0].strip('\r\n'))
>                             print histoAdresse
> 
>                             try:
>                                 dateHisto_cur = listeFenetreNonNul["%s"
> %(histoAdresse)]
>                                 print dateHisto_cur
> 
> 
> self.ecrireHistoDansFic(histo,histoAdresse,dateHisto_cur,histoAdresse,i)
>                                 break
>                             except:
> 
>                                 print "Adresse pas trouvee dans le
> systeme %s" %(histoAdresse)
>                                 break
>                     # End if
> 
>                     sleep(10)
>                 # End while
>             #End for
> 
>             
>             self.ser.close()




More information about the Python-list mailing list