pyserial port connection problem

J

Jon

Hi,

I wrote some code to read in info from a port using pyserial. the code
reads info sent by a box that is connected to my computer by an
rs232-to usb adapter. When I was writing the code and testing it on my
computer it worked fine.
I ran py2exe on the program (which uses wxpython for its gui) and sent
the output from the py2exe to another computer. now when I try to run
it on this other computer it fails to open the port. it gives the error
that it cannot createfile. the code I'm using to connect is the same as
it is when it worked on my computer.
I do notice that pyserial sees this port on the other computer as
\\\\.\\COM14 - while windows device manager displays it as COM14.
On the other computer the data is properly displayed in Hyperterminal
when opened on COM14.

how can I resolve this issue?

thanks!
 
G

Grant Edwards

I ran py2exe on the program (which uses wxpython for its gui)
and sent the output from the py2exe to another computer. now
when I try to run it on this other computer it fails to open
the port. it gives the error that it cannot createfile. the
code I'm using to connect is the same as it is when it worked
on my computer.

Are you sure you're using the correct com port?
I do notice that pyserial sees this port on the other computer as
\\\\.\\COM14 - while windows device manager displays it as COM14.

That's just another one of the many fun and wonderful little
bits of brokenness in MS Windows. COM14 can't be opened using
the name COM14. You have to call it \\.\COM14. Using the
unadorned COMx name only works for COM1-COM9. Since the
dimwits at MS decided to use C's "escape" character as a
directory separator, you've got to double it up (e.g.
"\\\\.\\COM14") to get the string you really want.
On the other computer the data is properly displayed in
Hyperterminal when opened on COM14.

What it displays as on other computers is irrelevant. Just
because a USB serial adapter shows up as COM14 on machine A,
that doesn't mean it's going to be COM14 on machine B.
how can I resolve this issue?

Go look in the device manager to see what com port you should
be using.
 
N

Nick Craig-Wood

Jon said:
I wrote some code to read in info from a port using pyserial. the code
reads info sent by a box that is connected to my computer by an
rs232-to usb adapter. When I was writing the code and testing it on my
computer it worked fine.
I ran py2exe on the program (which uses wxpython for its gui) and sent
the output from the py2exe to another computer. now when I try to run
it on this other computer it fails to open the port. it gives the error
that it cannot createfile. the code I'm using to connect is the same as
it is when it worked on my computer.
I do notice that pyserial sees this port on the other computer as
\\\\.\\COM14 - while windows device manager displays it as COM14.

That is a bit too many backslashes... You can only directly open COM1
to COM9 under windows. If you have >= 10 COM ports you need to use
the \\.\COM14 syntax. It looks like your backslashes have been
doubled somewhere along the line, though this maybe be a printing
artifact.

Are you passing the port name into pyserial or allowing the user to
choose it, or just getting pyserial to choose the n-th port?

Also are you running as adminstrator? You may need admin rights to
open a serial port under windows (I'm not sure).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top