[Tutor] IOError with fcntl.ioctl

Richi python-tutor at richip.dhs.org
Tue Aug 16 09:18:20 CEST 2005


Hi,

I'm trying to get the number of bytes available on an open serial device 
(on Linux). I try the following commands:

 >>> import os
 >>> import fcntl
 >>> import termios
 >>> fd = os.open ("/dev/ttyS0", os.O_RDWR)
 >>> fcntl.ioctl (fd, termios.TIOCINQ)

and after the last line I get the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
IOError: [Errno 14] Bad address

I've tried fcntl.ioctl (fd, termios.FIONREAD) (which is supposed to do 
the same thing, I think), and I still get the previous error. In fact, 
any ioctl() command I give to that file descriptor gives that result.

I'd appreciate any help in getting this to work.
--

Richi


More information about the Tutor mailing list