Q: serial port transmit pending count

Grant Edwards grante at visi.com
Tue Nov 26 19:45:27 EST 2002


In article <3de40f51$1 at news.nz.asiaonline.net>, Colin Brown wrote:

> I am using pySerial to talk to serial ports under Mandrake
> Linux. Does anyone know of a way to find the remaining
> bytecount awaiting transmission please? I tried getting the
> size from the file descriptor but with no luck.

How did you try to get it from the file descriptor?

TIOCOUTQ returns the number of buffered tx chars.  For some
drivers (e.g. 16x50 UARTS) it doesn't appear to include
characters in the hardware FIFO.  For some others, I know it
does.

 import termios,fcntl,struct

 def txCount(fd):
    s = fcntl.ioctl(fd,termios.TIOCOUTQ,TIOCM_zero_str)
    return struct.unpack('I',s)[0]

-- 
Grant Edwards                   grante             Yow!  Thousands of days of
                                  at               civilians... have produced
                               visi.com            a... feeling for the
                                                   aesthetic modules --



More information about the Python-list mailing list