I'm trying to use the Python USPP module to read data from a serial port under Windows 2000. My test code is as follows:
Everything works up until the "read" call. If I send 2 bytes to the serial port from another system connected to it via a null modem cable, the "inWaiting" call properly returns 2. But when it tries to actually read the data, I get the following:
I've been trying to figure this out for a couple of hours now and can't seem to make any progress. Any ideas?
c|i
Code:
import uspp
import time
tty = uspp.SerialPort ( "COM1", 1000, 9600 )
print "sleeping"
time.sleep ( 2 )
bytes = tty.inWaiting ( )
print bytes
print tty.read ( bytes )
Everything works up until the "read" call. If I send 2 bytes to the serial port from another system connected to it via a null modem cable, the "inWaiting" call properly returns 2. But when it tries to actually read the data, I get the following:
Code:
H:\main\temp>serial_temp.py
sleeping
0
Traceback (most recent call last):
File "H:\main\temp\serial_temp.py", line 15, in ?
print tty.read ( bytes )
File "C:\Python22\lib\SerialPort_win.py", line 194, in read
(hr, buff) = ReadFile(self.__handle, num)
pywintypes.api_error: (87, 'ReadFile', 'The parameter is incorrect.')
I've been trying to figure this out for a couple of hours now and can't seem to make any progress. Any ideas?
c|i