473,881 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("Hell o") #write a string
ser.close() #close port
-----------------

The following is the error message:

--------------
Traceback (most recent call last):
File "C:\Python25\Na veen Files\TestSeria l", line 2, in <module>
ser = serial.Serial(' CNCA0') #open first serial port
File "c:\Python25\Li b\site-packages\serial \serialutil.py" , line 156,
in __init__
self.open()
File "c:\Python25\Li b\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 11678
On 2007-10-12, na************* *@gmail.com <na************ **@gmail.comwro te:
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("Hell o") #write a string
ser.close() #close port
-----------------

The following is the error message:

--------------
Traceback (most recent call last):
File "C:\Python25\Na veen Files\TestSeria l", line 2, in <module>
ser = serial.Serial(' CNCA0') #open first serial port
File "c:\Python25\Li b\site-packages\serial \serialutil.py" , line 156,
in __init__
self.open()
File "c:\Python25\Li b\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.co mwrote:
On 2007-10-12, naveen.sabapa.. .@gmail.com <naveen.sabapa. ..@gmail.comwro te:
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("Hell o") #write a string
ser.close() #close port
-----------------
The following is the error message:
--------------
Traceback (most recent call last):
File "C:\Python25\Na veen Files\TestSeria l", line 2, in <module>
ser = serial.Serial(' CNCA0') #open first serial port
File "c:\Python25\Li b\site-packages\serial \serialutil.py" , line 156,
in __init__
self.open()
File "c:\Python25\Li b\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("Hell o") #write a string
ser.close() #close port
-----------------

The following is the error message:

--------------
Traceback (most recent call last):
File "C:\Python25\Na veen Files\TestSeria l", line 2, in <module>
ser = serial.Serial(' CNCA0') #open first serial port
File "c:\Python25\Li b\site-packages\serial \serialutil.py" , line 156,
in __init__
self.open()
File "c:\Python25\Li b\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
11061
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 creates a "normal" comm port (like COM3). There is a C++ program that has no problem talking to the equipment, but two Python programs have trouble. One is a big, scary, controller program, and the other, since that is the one I'm having trouble...
5
9969
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 pyserial library. anyone can help me ? this is a part of my code: self.ser = serial.Serial() self.ser.baudrate = 9600
15
16905
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 just a packet header) separated by spaces as follows: M xxx xxx xxx xxx xxx xxx xxx xxx Here is the code I am using (python v24): import serial
3
8166
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 soon as it hits the statement: s = serial.Serial(i) I get the error:
0
596
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 and found (to take with care!) :
0
2082
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
1716
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 capture it as well. I've installed Python 2.5, pyserial 2.2 and the appropriate pywin program (pywin32-210.win32-py2.5.exe). My problem comes when I try to open a serial port. After importing "serial", I issue the following statement:
6
6678
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 '%' to serial port and make sure it reached the serial port. 2. Once confirmed, send another character.
2
4168
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 When you touch the input pins of the microcontroller the value changes real time in hyper terminal. But In the case of the pyserial module, even though you touch the input pins, the value does not change. We have actually noticed that python records and...
0
9776
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11102
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10719
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10403
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9555
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5781
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5978
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4597
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4196
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.