By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,551 Members | 1,159 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,551 IT Pros & Developers. It's quick & easy.

pyserial port connection problem

P: n/a
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!

Nov 17 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 2006-11-17, Jon <js****@gmail.comwrote:
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.

--
Grant Edwards grante Yow! There's a SALE on
at STRETCH SOCKS down at the
visi.com "7-11"!!
Nov 17 '06 #2

P: n/a
Jon <js****@gmail.comwrote:
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).

--
Nick Craig-Wood <ni**@craig-wood.com-- http://www.craig-wood.com/nick
Nov 17 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.