472,805 Members | 1,613 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 software developers and data experts.

pyserial doesn't recognize virtual serial port

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

Oct 12 '07 #1
3 11187
On 2007-10-12, na**************@gmail.com <na**************@gmail.comwrote:
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'm not sure what you mean by "virtual ports". I've used
pyserial with several different network attached devices that
provide drivers that make them appear as COMnn devices under
windows. I never had any problems.
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.')
--------------
If you specify a filename that the OS doesn't recognize there's
nothing pyserial can do about it.
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?
My guess is you're not spelling the device name correctly.
Device names under Windows are even more screwed up than the
rest of the OS. By default there are a limited set of devices
with specially mapped "DOS compatible" names such as LPT1,
COM3, etc. My guess is that the device you're attempting to
use doesn't have a name that's mapped to the DOS-compatible
namespace as CNCA0.

You could try using the name \\.\CNCA0

Or you could try to figure otu how to map the device into the
DOS namespace as CNCA0.

You could also try running some sort of system call trace on
HyperTerminal to find out what name it's using to open the
device when you tell it to use port CNCA0.

Or you could just give up and switch to Linux. [That's what
I'd recommend, personally.]

--
Grant Edwards grante Yow! YOU PICKED KARL
at MALDEN'S NOSE!!
visi.com
Oct 12 '07 #2
Hi Grant,
It worked... I had the same suspicion and changed the port names to
COM2 and COM4 and it worked.

--NS
On Oct 12, 8:34 pm, Grant Edwards <gra...@visi.comwrote:
On 2007-10-12, naveen.sabapa...@gmail.com <naveen.sabapa...@gmail.comwrote:
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'm not sure what you mean by "virtual ports". I've used
pyserial with several different network attached devices that
provide drivers that make them appear as COMnn devices under
windows. I never had any problems.
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.')
--------------

If you specify a filename that the OS doesn't recognize there's
nothing pyserial can do about it.
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?

My guess is you're not spelling the device name correctly.
Device names under Windows are even more screwed up than the
rest of the OS. By default there are a limited set of devices
with specially mapped "DOS compatible" names such as LPT1,
COM3, etc. My guess is that the device you're attempting to
use doesn't have a name that's mapped to the DOS-compatible
namespace as CNCA0.

You could try using the name \\.\CNCA0

Or you could try to figure otu how to map the device into the
DOS namespace as CNCA0.

You could also try running some sort of system call trace on
HyperTerminal to find out what name it's using to open the
device when you tell it to use port CNCA0.

Or you could just give up and switch to Linux. [That's what
I'd recommend, personally.]

--
Grant Edwards grante Yow! YOU PICKED KARL
at MALDEN'S NOSE!!
visi.com

Oct 13 '07 #3
Try reading the sourceforge.net help forum about com0com:
http://sourceforge.net/forum/forum.p...orum_id=440109
Maybe you can find the solution.
I think you should prefix the port name with "\\.\"
Something like "\\.\CNCA0"

Did you ever try to use the com2tcp utility?
I'm trying to use it, but there are so little information.
I posted a request on the forum, and still waiting for answer.
Salvatore

On 12 Ott, 06:50, naveen.sabapa...@gmail.com wrote:
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
Nov 21 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Bob Greschke | last post by:
We have some equipment that communicates at 57600 baud RS232. The path from the PC is USB to a Phillips USB hub, then off of that a TUSB3410 USB/Serial converter. The driver for the 3410 chip...
5
by: Mimi | last post by:
Hi, I use the pyserial to read data from a serial port. My code is in window Xp and python 2.4. when I use Hyperteminal I can read data without try and try again that it is not the case with...
15
by: Lone Wolf | last post by:
I'm trying to get data through my serial port from a CMUcam. This gizmo tracks a color and returns a packet of data. The packet has nine data points (well, really eight since the first point is...
3
by: Ron Jackson | last post by:
I am using Python 2.5 on Windows XP. I have installed Pyserial and win32all extensions. When I try to run the example program scan.py (included below), or any other program using pyserial, as...
0
by: pauland80 | last post by:
<snip> <snip> Late thanks for your both answers! (Please excuse me for that) The problem was a bug in the device firmware. But before finding this, I dugg lightly in the pyserial source...
0
by: [david] | last post by:
http://pyserial.sourceforge.net/ "port numbering starts at zero, no need to know the port name in the user program" But the implementation in SerialWin32 is just (Portnum +1)
1
by: JAMoore84 | last post by:
Hi Guys, I have a project where I'd like to save GPS data that is streamed to a Sony Vaio over bluetooth. I can monitor the data stream over Hyper Terminal, but I'd like to use python to...
6
by: terry | last post by:
Hi, I am trying to send a character to '/dev/ttyS0' and expect the same character and upon receipt I want to send another character. I tired with Pyserial but in vain. Test Set up: 1. Send...
2
by: bryanleo | last post by:
We are trying to read data from a microcontroller and interface it through serial port. The output is then displayed in Python using Pyserial or the hyperterminal, the former is more important ...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.