clearing serial port

Grant Edwards grante at visi.com
Tue Jan 29 10:45:34 EST 2002


In article <3C568C71.70103 at beth.uniforum.org.za>, mixo wrote:
> 
> I have one tiny irritating problem :
> 
> Here is what I do:
> 
>    Clear Request To Send (~CRTS)
>    Read from port
>    sleep
> 
> My problem:
> 
> Should the device be turned off whilst readings are being taken,
> I get the previous reading, which means I need to clear the
> input from the device, before reading from the port. What
> usually happens is that I get an additional reading without
> any input, then reading returns to normal.
> 
> How do clear information that has been previously sent to the port?

You need to flush the input buffer in the serial port device
driver. Under Unix, it's done with the tcflush() system call
or the corresponding ioctl() call.

-- 
Grant Edwards                   grante             Yow!  Was my SOY LOAF left
                                  at               out in th'RAIN? It tastes
                               visi.com            REAL GOOD!!



More information about the Python-list mailing list