pyserial doesn't recognize virtual serial port

naveen.sabapathy at gmail.com naveen.sabapathy at gmail.com
Fri Oct 12 01:50:11 EDT 2007


Hi,
  I am trying to use virtual serial ports to develop/test my serial
communication program. Running in to trouble...

  I am using com0com to create the virtual ports. The virtual ports
seem to be working fine when I test it with Hyperterminal .

I am using the example program that comes with pyserial, as below.
---------------
import serial
ser = serial.Serial('CNCA0') #open virtual serial port
print ser.portstr            #check which port was realy used
ser.write("Hello")              #write a string
ser.close()                  #close port
-----------------

The following is the error message:

--------------
Traceback (most recent call last):
  File "C:\Python25\Naveen Files\TestSerial", line 2, in <module>
    ser = serial.Serial('CNCA0') #open first serial port
  File "c:\Python25\Lib\site-packages\serial\serialutil.py", line 156,
in __init__
    self.open()
  File "c:\Python25\Lib\site-packages\serial\serialwin32.py", line 55,
in open
    raise SerialException("could not open port: %s" % msg)
SerialException: could not open port: (2, 'CreateFile', 'The system
cannot find the file specified.')
--------------

When I try with 'COM3', which comes inbuilt in my laptop, COM3 is
recognized. Few other posts on the web seem to indicate pyserial
should work fine with virtual serial ports. What am I missing? Please
help.

--Thanks
--NS




More information about the Python-list mailing list