[Tutor] pySerial port write problem - Windows Error 2 - The system cannot find the file specified
Sridev Nair
sksridevnair at gmail.com
Sun Jan 16 11:59:13 CET 2011
Hi all,
I am trying to use pySerial to connect to a USB over Serial device. Using,
USB
monitoring tool, I see that I am able to connect to the port. I could also
read
data relayed by the device. However, any write on the com port handle is
throwing
Windows Error 2, The system cannot find the file specified"
I am working with pySerial 2.5, Python 2.7 on Windows XP Prof. SP2
Any idea why the write is failing? Any help much appreciated.
Regards,
Sridev
--------------------Code------------------------------
import serial
try:
port = serial.Serial('\\\\.\\COM10',timeout=2)
print "Successfully opened the com port."
print port
except:
print "Failed to initialize com port"
print port.write("020200013803")
---------------Code---------------------------------------
----------------Output------------------------------------
Serial<id=0xf47890, open=True>(port='\\\\.\\COM10', baudrate=9600,
bytesize=8, p
arity='N', stopbits=1, timeout=2, xonxoff=0, rtscts=0, dsrdtr=0)
WriteFile failed, 2: The system cannot find the file specified
------------------Output----------------------------------
On digging into serialwin32.py line
>>err = win32.WriteFile(self.hComPort, data, len(data), ctypes.byref(n),
self._overlappedWrite)
I see that self.hComPort = 1948 which is the valid handle created while
opening
the port.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110116/e52817ab/attachment.html>
More information about the Tutor
mailing list