physical hardware accesss
Robert Cragie
rcc at nospamthanks_jennic.com
Fri Jun 9 07:40:13 EDT 2000
Grant Edwards <ge at nowhere.none> wrote in message
news:gYT%4.1084$zm3.245488 at ptah.visi.com...
| In article <393f4dd2$0$2877 at wodc7nh6.news.uu.net>, Blu Dragoon wrote:
| >If I wanted to would be able to probe a serial, parallel, or USB port
| >with python.
|
| >Open(/dev/cua1)
| >Write(/dev/cua1)
|
| How about:
|
| fd = os.open("/dev/cua1")
| os.write(fd,buffer)
You missed out the flags in os.open():
fd = os.open("/dev/cua1", O_RDWR)
os.open() is the low-level 'open'. You could also use the 'higher-level
(possibly 'preferred'?)' built-in open(), which returns a file object:
file = open("/dev/cua1", "rw")
file.write(buffer)
If you need to do ioctl() etc. you can get the low-level file number using
the fileno() method, e.g.
fd = file.fileno()
Robert Cragie
More information about the Python-list
mailing list