Re: Pyserial problem

2022-12-22 Thread Barry


> On 22 Dec 2022, at 17:09, Patrick EGLOFF  wrote:
> 
> Hi all,
> 
> I use Python 3.10.9 and Pyserial 3.5 on a Win10 machine.
> 
> I'm sending datas via an USB port to a device that accept commands in the
> form of  : cmd;
> The device receives and reacts to the commands sent, and it should reply
> with an ACK of the same kind.
> 
> But looking with a COM port sniffer, nothing is sent back.
> 
> I checked that everything is working with PUTTY and even MINITERM, and
> everything is just fine, the device is responding correctly.
> 
> I have set the flow control to different values, as well as setting the RTS
> and DTR high or low with no change.
> Normally, the device works without any flow control, and CTS + DTR high.
> 
> I checked with MINITERM, that the flow control and control lines have the
> same state.
> 
> I'm a bit surprised and stucked.
> Can someone help ?

Please post tour code that you are using to talk to the device.

Barry

> Thanks,
> -- 
> Patrick Egloff
> email : pegl...@gmail.com
> Web page : http://www.egloff.eu
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Pyserial problem

2022-12-22 Thread Patrick EGLOFF
Hi all,

I use Python 3.10.9 and Pyserial 3.5 on a Win10 machine.

I'm sending datas via an USB port to a device that accept commands in the
form of  : cmd;
The device receives and reacts to the commands sent, and it should reply
with an ACK of the same kind.

But looking with a COM port sniffer, nothing is sent back.

I checked that everything is working with PUTTY and even MINITERM, and
everything is just fine, the device is responding correctly.

I have set the flow control to different values, as well as setting the RTS
and DTR high or low with no change.
Normally, the device works without any flow control, and CTS + DTR high.

I checked with MINITERM, that the flow control and control lines have the
same state.

I'm a bit surprised and stucked.
Can someone help ?
Thanks,
-- 
Patrick Egloff
email : pegl...@gmail.com
Web page : http://www.egloff.eu
-- 
https://mail.python.org/mailman/listinfo/python-list


Pyserial and some half-duplex woes.

2020-09-03 Thread Mark Barton

Hey All,

I am using Microchip's Python program to download 
code to a PIC32 microprocessor via Pyserial. There 
is also Microchip's bootloader code running on the 
PIC side. This works very well using the a 
standard serial hardware directly connected to a 
USB to serial adapter to one of the PIC's UARTs. 
However in our application the hardware is a 
single wire thus requiring a half-duplex 
communications. Fortunately Microchip's protocol 
lends itself to half-duplex communications, 
however the problem is that both the PIC and the 
Python program will receive an echo when one of 
the other transmits due to the hardware design. It 
other words the PIC will receive what it transmits 
and the same on the Python side. The PIC side is 
easily fixed by simply turning off receive during 
transmit. I don't think I can do this on the 
Python side at least there nothing in Pyserial's 
documentation that you can do that.


I have tried to do some flushing of the receive 
buffer, but I haven't been too successful. Perhaps 
that is due to timing.


I thought I would reach out to see if anyone may 
have had a similar experience.


Thanks for any help.

Mark


--
https://mail.python.org/mailman/listinfo/python-list


Re: pyserial and end-of-line specification

2017-07-21 Thread FS
Thanks Rob.
  Yes I ended up with a read(1) and use a field count and a few other checks to 
make sure I don't get a partial record. Serial is the "best of times and worst 
of times". Sure beats dealing with USB enumeration, power hungry ethernet 
processors and a lot of other stuff. I can still "see" serial on my o'scope 
which is always nice and I don't see it going away any time soon at least in 
the laboratory.

Python has been a bit of a chore-seems like a lot of verison/rev 
inconsistencies. At any rate I am going to stick with it. I used PERL in the 
past but I covet the stats packages and a few other things I lost when I left 
matlab and  I want to try for chemometrics work.

cheers
fritz
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pyserial and end-of-line specification

2017-07-19 Thread Rob Gaddi

On 07/18/2017 12:53 PM, FS wrote:

Thank you for your response Andre. I had tried some code like that in the 
document but it did not seem to work. However ever leaving my terminal for a 
time the code eventually wrote out the records so apparently there is some very 
deep buffering going on here. A little more searching on the web revealed the 
following:

https://stackoverflow.com/questions/10222788/line-buffered-serial-input

It is apparent that pySerial, or at least the documentation is falling short of 
my needs. It is very unclear what module in the layer is handling the buffering 
and newlines and so forth. Also unclear is whether the coupled python and OS is 
reading FIFO or LIFO--something important in quasi realtime scientific 
applications.
   This is problematic since the serial port is still so ubiquitous to a lot of 
scientific instrumentation. I probably will patch up some byte oriented code 
for this or perhaps write the module in C.

Thanks again
Fritz



Handling it .read(1) at a time is probably your best bet.  Append them 
into a bytearray and pull it all out when you're done.


It's a serial port; it's not like there is any degree of inefficiently 
that you could write the code that will make it slow with respect to the 
I/O.  I write a LOT of serial instrument I/O and I've definitely had to 
fall back to this plan.  Your code gets a little long, you hide it all 
in a function somewhere and never think on it again.


One paradigm I stick for ASCII serial is to have 3 functions:

def command(msg: str):
"""Sends a command, raises CommError if it doesn't get some
expected OK sort of thing."""

def query(msg: str):
"""Sends a commmand, returns a (trimmed) response line."""

def _communicate(msg: str):

The ugliest stuff, all the str->bytes->str stuff, the line-ending and 
protocols, goes into _communicate.  Query usually just calls 
_communicate.  Command slaps on whatever checks are needed.  It feels a 
bit heavy, but it leads to highly-usable code and makes it easy to 
integrate logging, retries, integrating "*OPC?" handshakes, whatever 
sort of things turn out to be necessary on a given device.


--
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.
--
https://mail.python.org/mailman/listinfo/python-list


Re: pyserial and end-of-line specification

2017-07-18 Thread FS
Thank you for your response Andre. I had tried some code like that in the 
document but it did not seem to work. However ever leaving my terminal for a 
time the code eventually wrote out the records so apparently there is some very 
deep buffering going on here. A little more searching on the web revealed the 
following:

https://stackoverflow.com/questions/10222788/line-buffered-serial-input

It is apparent that pySerial, or at least the documentation is falling short of 
my needs. It is very unclear what module in the layer is handling the buffering 
and newlines and so forth. Also unclear is whether the coupled python and OS is 
reading FIFO or LIFO--something important in quasi realtime scientific 
applications.
  This is problematic since the serial port is still so ubiquitous to a lot of 
scientific instrumentation. I probably will patch up some byte oriented code 
for this or perhaps write the module in C.

Thanks again
Fritz
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pyserial and end-of-line specification

2017-07-15 Thread Andre Müller
Just take a look into the documentation:
https://docs.python.org/3/library/io.html#io.TextIOWrapper

And in the example of Pyserial:
http://pyserial.readthedocs.io/en/latest/shortintro.html#eol

I think it shold be:
sio = io.TextIOWrapper(io.BufferedRWPair(ser, ser),
newline='yourline_ending')

But the documentation of Pytho says:
Warning BufferedRWPair does not attempt to synchronize accesses to its
underlying raw streams. You should not pass it the same object as reader
and writer; use BufferedRandom instead.


Maybe you should also try:

sio = io.TextIOWrapper(io.BufferedRandom(ser), newline='yourline_ending')

If it's readonly:
sio = io.TextIOWrapper(io.BufferedReader(ser), newline='yourline_ending')


I never tried it, but your question leads me to take a look into this cool
features of the io module.

Greetings Andre
-- 
https://mail.python.org/mailman/listinfo/python-list


pyserial and end-of-line specification

2017-07-14 Thread F S
I just started using Python and I am writing code to access my serial port 
using pyserial. I have no problem with unix based text coming in the stream 
using a LF (0x0A) record separator. I also am using unblocked IO. However I 
have some sensor devices that use the windows CRLF (0x0A,0x0D) record 
separators and also a 0x03 and 0x02 (stx,etx) framing so I need to change the 
EOL (end of line) specfier in order to get the pyserial readline to so this.

I read the doc page for pyserial and they allude to using TextIOWrapper: to 
accomplish this however the example is very unclear and I could not find better 
information on the IO page.

I would appreciate any advice on how to block the records using "x0Ax0D" and 
"x03".

Thanks
Fritz
-- 
https://mail.python.org/mailman/listinfo/python-list


Best practices interfacing to device with Python's asyncio and pyserial-asyncio

2017-04-03 Thread Malte Forkel
Hello,

I have written a Python package to read from and write to a serial
device that uses short telegrams to communicate with sensors and
actuators. My classes include one to model the transceiver (it
establishes the serial connection using
serial.aio.create_serial_connection) and one for the telegram protocol
based on asyncio.Protocol. I also have a bunch of classes for the
different types of telegrams and devices.

While this all works, the device model and the protocol don't look very
pythonic to me. Are there any tutorials or examples demonstrating best
practices of how to do something like this?

Thanks,
Malte

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue29361] bug in pyserial: serialposix.py

2017-01-24 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the report, but pyserial is not part of the Python stdlib. Please 
open your bug report on https://github.com/pyserial/pyserial.

--
nosy: +berker.peksag
resolution:  -> third party
stage:  -> resolved
status: open -> closed
type: crash -> behavior

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29361>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29361] bug in pyserial: serialposix.py

2017-01-24 Thread Reto Cavelti

New submission from Reto Cavelti:

bug in pyserial: serialposix.py

line 50:
# set custom divisor
buf[6] = buf[7] / baudrate

TypeError: integer argument expected, got float

fix: do cast: buf[6] = int(buf[7] / baudrate)

--
components: Library (Lib)
messages: 286168
nosy: rc
priority: normal
severity: normal
status: open
title: bug in pyserial: serialposix.py
type: crash
versions: Python 3.5

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29361>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29090] PySerial crash on Windows XP and Python 3.4

2017-01-03 Thread STINNER Victor

Changes by STINNER Victor <victor.stin...@gmail.com>:


--
resolution:  -> out of date
status: open -> closed
title: python34.dll crash -> PySerial crash on Windows XP and Python 3.4

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29090>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: pySerial raw data

2016-12-11 Thread MRAB

On 2016-12-11 21:29, Wanderer wrote:

On Sunday, December 11, 2016 at 12:52:04 PM UTC-5, MRAB wrote:

On 2016-12-11 16:28, Wanderer wrote:
> I have an outdoor thermometer that transmits to an indoor receiver at 433Mhz. 
I also have a 433Mhz USB serial port jig from a TI development tool. I would like 
to use the TI USB serial port to capture the temperature information. The TI USB 
port registers as a COM port that I can access with pySerial. Now the datasheet 
from the temperature probe only says that the RF frequency is 433MHz and that it 
transmits every 39 seconds. Since I don't know what protocol the thermometer uses 
or baud rate, I want to look at the rawest level of data collected with the USB 
com port and see if I can make anything out of the gobbledy gook coming in. Is 
there a way to get this kind of data from pySerial? I've tried scanning at 
different baud rates but so far I haven't captured anything.
>
> Also in the advanced settings in windows device manager, there are some 
settings for Fifo buffers, and receive and transmit buffers. Can these be accessed 
in pySerial? Does pySerial override the settings for baud rate, etc in windows 
device manager or do I need to set those to match what I'm using in pySerial?
>
What is the make and model of the thermometer? Is the datasheet online
somewhere?


http://global.oregonscientific.com/manual/THN132N.pdf

That datasheet says """This product is compatible with various wireless 
weather station products."""


OK, so that suggests that there's a standard of some kind somewhere.

Googling for """wireless weather station protocol""" gives:

Reverse engineering wireless weather stations
hackaday.com/2011/06/13/reverse-engineering-wireless-weather-stations/

and that page leads to:

TX29 Protocol
http://fredboboss.free.fr/articles/tx29.php

Good luck!

--
https://mail.python.org/mailman/listinfo/python-list


Re: pySerial raw data

2016-12-11 Thread Paul Rubin
Wanderer <wande...@dialup4less.com> writes:
> I also have a 433Mhz USB serial port jig from a TI development
> tool The TI USB port registers as a COM port that I can access
> with pySerial.

If the TI jig has 433 mhz (LORA?) at one end and serial at the other,
you have to find the port parameters in the docs for the TI jig, not the
thermometer.

If you don't have docs you can often figure out the right settings by
trial and error.  If not, the direct approach is to use an oscilloscope.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pySerial raw data

2016-12-11 Thread Wanderer
On Sunday, December 11, 2016 at 12:52:04 PM UTC-5, MRAB wrote:
> On 2016-12-11 16:28, Wanderer wrote:
> > I have an outdoor thermometer that transmits to an indoor receiver at 
> > 433Mhz. I also have a 433Mhz USB serial port jig from a TI development 
> > tool. I would like to use the TI USB serial port to capture the temperature 
> > information. The TI USB port registers as a COM port that I can access with 
> > pySerial. Now the datasheet from the temperature probe only says that the 
> > RF frequency is 433MHz and that it transmits every 39 seconds. Since I 
> > don't know what protocol the thermometer uses or baud rate, I want to look 
> > at the rawest level of data collected with the USB com port and see if I 
> > can make anything out of the gobbledy gook coming in. Is there a way to get 
> > this kind of data from pySerial? I've tried scanning at different baud 
> > rates but so far I haven't captured anything.
> >
> > Also in the advanced settings in windows device manager, there are some 
> > settings for Fifo buffers, and receive and transmit buffers. Can these be 
> > accessed in pySerial? Does pySerial override the settings for baud rate, 
> > etc in windows device manager or do I need to set those to match what I'm 
> > using in pySerial?
> >
> What is the make and model of the thermometer? Is the datasheet online 
> somewhere?

http://global.oregonscientific.com/manual/THN132N.pdf
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pySerial raw data

2016-12-11 Thread MRAB

On 2016-12-11 16:28, Wanderer wrote:

I have an outdoor thermometer that transmits to an indoor receiver at 433Mhz. I 
also have a 433Mhz USB serial port jig from a TI development tool. I would like 
to use the TI USB serial port to capture the temperature information. The TI 
USB port registers as a COM port that I can access with pySerial. Now the 
datasheet from the temperature probe only says that the RF frequency is 433MHz 
and that it transmits every 39 seconds. Since I don't know what protocol the 
thermometer uses or baud rate, I want to look at the rawest level of data 
collected with the USB com port and see if I can make anything out of the 
gobbledy gook coming in. Is there a way to get this kind of data from pySerial? 
I've tried scanning at different baud rates but so far I haven't captured 
anything.

Also in the advanced settings in windows device manager, there are some 
settings for Fifo buffers, and receive and transmit buffers. Can these be 
accessed in pySerial? Does pySerial override the settings for baud rate, etc in 
windows device manager or do I need to set those to match what I'm using in 
pySerial?

What is the make and model of the thermometer? Is the datasheet online 
somewhere?


--
https://mail.python.org/mailman/listinfo/python-list


pySerial raw data

2016-12-11 Thread Wanderer
I have an outdoor thermometer that transmits to an indoor receiver at 433Mhz. I 
also have a 433Mhz USB serial port jig from a TI development tool. I would like 
to use the TI USB serial port to capture the temperature information. The TI 
USB port registers as a COM port that I can access with pySerial. Now the 
datasheet from the temperature probe only says that the RF frequency is 433MHz 
and that it transmits every 39 seconds. Since I don't know what protocol the 
thermometer uses or baud rate, I want to look at the rawest level of data 
collected with the USB com port and see if I can make anything out of the 
gobbledy gook coming in. Is there a way to get this kind of data from pySerial? 
I've tried scanning at different baud rates but so far I haven't captured 
anything.

Also in the advanced settings in windows device manager, there are some 
settings for Fifo buffers, and receive and transmit buffers. Can these be 
accessed in pySerial? Does pySerial override the settings for baud rate, etc in 
windows device manager or do I need to set those to match what I'm using in 
pySerial?

Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pyserial: wait for execute

2016-10-16 Thread Grant Edwards
On 2016-10-16, Michael Okuntsov  wrote:

> is there a way, other than time.sleep(), to be sure that the command
> sent through a serial port has been fully executed?

If the remote device doesn't send a response telling you it's done
executing the command, then there is no way to know when that has
happened.

-- 
Grant


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pyserial: wait for execute

2016-10-15 Thread paulp
On Saturday, October 15, 2016 at 10:14:18 PM UTC-6, Michael Okuntsov wrote:
> Hello,
> is there a way, other than time.sleep(), to be sure that the command 
> sent through a serial port has been fully executed? I'm interested 
> specifically in SCPI commands in VA-meters such as Keithley and Tektronix.
> Thanks.

Looks like the out_waiting method on serial.Serial class is what you need. Or 
perhaps use the flush method, the doc seems to say it returns when the write 
completes.
-- 
https://mail.python.org/mailman/listinfo/python-list


pyserial: wait for execute

2016-10-15 Thread Michael Okuntsov

Hello,
is there a way, other than time.sleep(), to be sure that the command 
sent through a serial port has been fully executed? I'm interested 
specifically in SCPI commands in VA-meters such as Keithley and Tektronix.

Thanks.
--
https://mail.python.org/mailman/listinfo/python-list


ANN: pySerial 3.0

2015-12-30 Thread Chris Liechti

A new release of pySerial is available. There have been a lot
of changes so that the major version was bumped up to 3.0.

Changes include (since V2.7):
- Python 2.7 and Python 3.2+ from the same sources (lib2to3 is
  no longer used)
- new API, more properties, the set functions are deprecated.
  (old API still supported for backward compatibility)
- Updated miniterm (uses Unicode for console output, supports
  encodings on serial port, nicer port selection and more).
- IPv6 support for rfc2217:// and socket://
- New spy:// handler to log traffic and control calls.
- New alt:// handler to select implementations
- URL parameters have changed
- Experimental classes for easy threading support
- Experimental asyncio support (posix)
- A number of bugfixes.

See https://github.com/pyserial/pyserial/blob/master/CHANGES.rst
for more details.

Changes in development:
- SVN -> GIT
- moved (from SF) to github: https://github.com/pyserial/pyserial

Currently unsupported is the Jython platform (lack of testing).

Download at: https://github.com/pyserial/pyserial/releases
or via PyPI: https://pypi.python.org/pypi/pyserial

Docs: http://pythonhosted.org/pyserial/ (stable)
  https://pyserial.readthedocs.org/en/latest/ (follows git)

chris
--
https://mail.python.org/mailman/listinfo/python-announce-list

   Support the Python Software Foundation:
   http://www.python.org/psf/donations/


Re: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic

2015-10-07 Thread Dave Farrance
Rob Gaddi <rgaddi@technologyhighland.invalid> wrote:

>So, this is odd.  I'm running Ubuntu 14.04, and my system did a kernel 
>upgrade from the repository from 3.13.0-63-generic to 3.13.0-65-generic.  
>And pyserial (2.7, installed through pip) stopped working.

When KDE's "Plasma 5" appeared with Kubuntu 15.04, I found it to be too
new and have too many dysfunctions, so I reverted to Kubuntu 14.04 LTS.

Now this problem.  Looking at the Ubuntu 14.04 repository, I found that
it contained a backported version of the kernel used in 15.04.  So...

Remove "meta" packages that have latest 3.13 kernel as dependencies:

sudo apt-get purge linux-generic linux-signed-generic

Install meta packages that pull in the latest 3.19 kernel:

sudo apt-get install linux-generic-lts-vivid
  linux-signed-generic-lts-vivid

Serial now works fine. The later kernel introduces no functional changes
in (K)ubuntu 14.04 that I can discern.  I presume that since it is a
"backported" version of the 3.19 kernel, that its video drivers have
been matched to Ubuntu 14.04's version of X.Org, and so on.

Anyway, that's what works for me. I could've put a "hold" on the
3.13.0-63 kernel, but this seems a better fix.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic

2015-10-06 Thread Grant Edwards
On 2015-10-03, Laura Creighton  wrote:

>  https://bugs.launchpad.net/ubuntu/+source/linux-lts-trusty/+bug/1501345
>  seems to be about a whole lot of serial ports to me, not just FTDI

We just ran into the OP's problem where I work: Ununtu kernel updated
and all serial ports stopped working (it isn't just an FTDI problem). 

Booting with the previous kernel makes the serial ports work again.

What I'm trying to figure out: is this something _Ubuntu_ did so that
only affects Ubuntu kernels?  [I haven't seen it mentioned on the
linux-serial mailing list, and nobody other than Ubuntu users seem to
have the problem, so I think the answer to my question is "yes".]

-- 
Grant Edwards   grant.b.edwardsYow! Am I SHOPLIFTING?
  at   
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic

2015-10-06 Thread Rob Gaddi
On Tue, 06 Oct 2015 21:31:02 +, Grant Edwards wrote:

> On 2015-10-03, Laura Creighton <l...@openend.se> wrote:
> 
>>  https://bugs.launchpad.net/ubuntu/+source/linux-lts-trusty/
+bug/1501345
>>  seems to be about a whole lot of serial ports to me, not just FTDI
> 
> We just ran into the OP's problem where I work: Ununtu kernel updated
> and all serial ports stopped working (it isn't just an FTDI problem).
> 
> Booting with the previous kernel makes the serial ports work again.
> 
> What I'm trying to figure out: is this something _Ubuntu_ did so that
> only affects Ubuntu kernels?  [I haven't seen it mentioned on the
> linux-serial mailing list, and nobody other than Ubuntu users seem to
> have the problem, so I think the answer to my question is "yes".]

Glad I was able to get you some heads-up on it; I wound up burning 4 
hours before I figured out what the problem was.

I'm not sure if these are Ubuntu specific problems, but I slung some C to 
test and confirmed that they're not Python specific problems.  Pyserial 
uses select(), and on Linux all of select(), poll(), and epoll() are 
handled at the driver level by the same entry point.  Anything in the 
genre is hosed until they get it back under control.

Personally, I'm so upset that I'm going to call Linux and demand my money 
back.  But until then I'm regressed to -63.

-- 
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic

2015-10-06 Thread Laura Creighton
In a message of Tue, 06 Oct 2015 21:31:02 -, Grant Edwards writes:
>On 2015-10-03, Laura Creighton  wrote:
>
>>  https://bugs.launchpad.net/ubuntu/+source/linux-lts-trusty/+bug/1501345
>>  seems to be about a whole lot of serial ports to me, not just FTDI
>
>We just ran into the OP's problem where I work: Ununtu kernel updated
>and all serial ports stopped working (it isn't just an FTDI problem). 
>
>Booting with the previous kernel makes the serial ports work again.
>
>What I'm trying to figure out: is this something _Ubuntu_ did so that
>only affects Ubuntu kernels?  [I haven't seen it mentioned on the
>linux-serial mailing list, and nobody other than Ubuntu users seem to
>have the problem, so I think the answer to my question is "yes".]
>
>-- 
>Grant Edwards   grant.b.edwardsYow! Am I SHOPLIFTING?
>  at   
>  gmail.com

Upstream from ubuntu is debian.
I am running debian unstable.
I did a kernel update, all my serial ports work fine,
but since I don't have a simple script to test if
I have the problem, I cannot swear for certain ubuntu did it ...

Laura

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic

2015-10-05 Thread Rob Gaddi
On Sat, 03 Oct 2015 11:12:28 +0200, Laura Creighton wrote:

> In a message of Sat, 03 Oct 2015 11:07:04 +0200, Laura Creighton writes:
>>In a message of Fri, 02 Oct 2015 22:36:23 -, Rob Gaddi writes:
>>>So, this is odd.  I'm running Ubuntu 14.04, and my system did a kernel
>>>upgrade from the repository from 3.13.0-63-generic to
>>>3.13.0-65-generic. And pyserial (2.7, installed through pip) stopped
>>>working.
>>>
>>>Specifically, when I make read() calls on a Serial object, I get the
>>>error
>>>
>>>serial.serialutil.SerialException: device reports readiness to read but
>>>returned no data (device disconnected?)
>>>
>>>This comes from the PosixSerial.read() method in serialposix.py, and
>>>seems to be a result of the select.select call screwing up.
>>>
>>>I reboot under 3.13.0-63-generic.  My code works.  I reboot under
>>>3.13.0-65-generic.  My code doesn't.  Implication would seem to be that
>>>somehow between these kernel versions, the select() logic in the serial
>>>driver changed.  This happens regardless of whether the serial port is
>>>real, FTDI USB-UART, or Prolific USB-UART.
>>>
>>>Can anyone else confirm?  Also, who do I try to report this one to?
>>>
>>>Thanks,
>>>Rob
>>>
>>>--
>>>Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email
>>>address domain is currently out of order.  See above to fix.
>>>--
>>>https://mail.python.org/mailman/listinfo/python-list
>>
>>I think you have this bug
>>https://bugs.launchpad.net/ubuntu/+source/linux/+bug/460857
>>
>>or rather, you like the behaviour that ubuntu thinks is buggy, which
>>never got fixed, and don't like that it changed to be what ubuntu thinks
>>is correct in .65.
>>
>>I'd talk to the pyserial issue tracker as the people there ought to be
>>well aware of this problem, and then see if talking to ubuntu is the
>>right thing to do.
>>
>>Laura --
>>https://mail.python.org/mailman/listinfo/python-list
> 
> I think I said that poorly.
> 
> What I think happened is that ubuntu made some changes to fix this
> problem, and along the way they managed to break things for you,
> and maybe all pyserial users.  But I would talk to the pyserial people
> about that.
> 
> Laura

I'm not sure poorly as much as "could have offended someone who hasn't 
been caught by these sorts of issues before".  I took it as meant, that 
one person's bug is another's fix, rather than as "Your bug report is 
stupid and you should feel bad and never Python again."

And thanks for the find on https://bugs.launchpad.net/ubuntu/+source/
linux-lts-trusty/+bug/1501345.  That is PRECISELY what I should have been 
able to find.  I'll make only the excuse that it was late Friday with me 
having to run for the airport and I wanted to at least flag it as an 
issue before I hit the door.

-- 
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic

2015-10-03 Thread Laura Creighton
In a message of Sat, 03 Oct 2015 11:07:04 +0200, Laura Creighton writes:
>In a message of Fri, 02 Oct 2015 22:36:23 -, Rob Gaddi writes:
>>So, this is odd.  I'm running Ubuntu 14.04, and my system did a kernel 
>>upgrade from the repository from 3.13.0-63-generic to 3.13.0-65-generic.  
>>And pyserial (2.7, installed through pip) stopped working.
>>
>>Specifically, when I make read() calls on a Serial object, I get the error
>>
>>serial.serialutil.SerialException: device reports readiness to read but 
>>returned no data (device disconnected?)
>>
>>This comes from the PosixSerial.read() method in serialposix.py, and 
>>seems to be a result of the select.select call screwing up.
>>
>>I reboot under 3.13.0-63-generic.  My code works.  I reboot under 
>>3.13.0-65-generic.  My code doesn't.  Implication would seem to be that 
>>somehow between these kernel versions, the select() logic in the serial 
>>driver changed.  This happens regardless of whether the serial port is 
>>real, FTDI USB-UART, or Prolific USB-UART.
>>
>>Can anyone else confirm?  Also, who do I try to report this one to?
>>
>>Thanks,
>>Rob
>>
>>-- 
>>Rob Gaddi, Highland Technology -- www.highlandtechnology.com
>>Email address domain is currently out of order.  See above to fix.
>>-- 
>>https://mail.python.org/mailman/listinfo/python-list
>
>I think you have this bug
>https://bugs.launchpad.net/ubuntu/+source/linux/+bug/460857
>
>or rather, you like the behaviour that ubuntu thinks is buggy,
>which never got fixed, and don't like that it changed to be
>what ubuntu thinks is correct in .65.
>
>I'd talk to the pyserial issue tracker as the people there ought
>to be well aware of this problem, and then see if talking to
>ubuntu is the right thing to do.
>
>Laura
>-- 
>https://mail.python.org/mailman/listinfo/python-list

I think I said that poorly.

What I think happened is that ubuntu made some changes to fix this
problem, and along the way they managed to break things for you,
and maybe all pyserial users.  But I would talk to the pyserial people
about that.

Laura
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic

2015-10-03 Thread Michael Torrie
On 10/03/2015 03:19 AM, Laura Creighton wrote:
> With better searching, I find this bug.
> https://bugs.launchpad.net/ubuntu/+source/linux-lts-trusty/+bug/1501345
> 
> Looks like that's the real one.

This ubuntu bug and the other bug you mention seem to be about FTDI
devices. Rob said in his original post that the problem occurs with a
real UART serial port as well, and also the prolific USB chipset.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic

2015-10-03 Thread Laura Creighton
With better searching, I find this bug.
https://bugs.launchpad.net/ubuntu/+source/linux-lts-trusty/+bug/1501345

Looks like that's the real one.

Laura
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic

2015-10-03 Thread Laura Creighton
In a message of Fri, 02 Oct 2015 22:36:23 -, Rob Gaddi writes:
>So, this is odd.  I'm running Ubuntu 14.04, and my system did a kernel 
>upgrade from the repository from 3.13.0-63-generic to 3.13.0-65-generic.  
>And pyserial (2.7, installed through pip) stopped working.
>
>Specifically, when I make read() calls on a Serial object, I get the error
>
>serial.serialutil.SerialException: device reports readiness to read but 
>returned no data (device disconnected?)
>
>This comes from the PosixSerial.read() method in serialposix.py, and 
>seems to be a result of the select.select call screwing up.
>
>I reboot under 3.13.0-63-generic.  My code works.  I reboot under 
>3.13.0-65-generic.  My code doesn't.  Implication would seem to be that 
>somehow between these kernel versions, the select() logic in the serial 
>driver changed.  This happens regardless of whether the serial port is 
>real, FTDI USB-UART, or Prolific USB-UART.
>
>Can anyone else confirm?  Also, who do I try to report this one to?
>
>Thanks,
>Rob
>
>-- 
>Rob Gaddi, Highland Technology -- www.highlandtechnology.com
>Email address domain is currently out of order.  See above to fix.
>-- 
>https://mail.python.org/mailman/listinfo/python-list

I think you have this bug
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/460857

or rather, you like the behaviour that ubuntu thinks is buggy,
which never got fixed, and don't like that it changed to be
what ubuntu thinks is correct in .65.

I'd talk to the pyserial issue tracker as the people there ought
to be well aware of this problem, and then see if talking to
ubuntu is the right thing to do.

Laura
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic

2015-10-03 Thread Laura Creighton
In a message of Sat, 03 Oct 2015 08:38:53 -0600, Michael Torrie writes:
>On 10/03/2015 03:19 AM, Laura Creighton wrote:
>> With better searching, I find this bug.
>> https://bugs.launchpad.net/ubuntu/+source/linux-lts-trusty/+bug/1501345
>> 
>> Looks like that's the real one.
>
>This ubuntu bug and the other bug you mention seem to be about FTDI
>devices. Rob said in his original post that the problem occurs with a
>real UART serial port as well, and also the prolific USB chipset.
>
>-- 
>https://mail.python.org/mailman/listinfo/python-list

 https://bugs.launchpad.net/ubuntu/+source/linux-lts-trusty/+bug/1501345
 seems to be about a whole lot of serial ports to me, not just FTDI

Laura
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic

2015-10-02 Thread Grant Edwards
On 2015-10-02, Rob Gaddi <rgaddi@technologyhighland.invalid> wrote:

> Also, who do I try to report this one to?

I'd try here:

https://github.com/pyserial/pyserial/issues


-- 
https://mail.python.org/mailman/listinfo/python-list


Pyserial and Ubuntu Linux kernel 3.13.0-65-generic

2015-10-02 Thread Rob Gaddi
So, this is odd.  I'm running Ubuntu 14.04, and my system did a kernel 
upgrade from the repository from 3.13.0-63-generic to 3.13.0-65-generic.  
And pyserial (2.7, installed through pip) stopped working.

Specifically, when I make read() calls on a Serial object, I get the error

serial.serialutil.SerialException: device reports readiness to read but 
returned no data (device disconnected?)

This comes from the PosixSerial.read() method in serialposix.py, and 
seems to be a result of the select.select call screwing up.

I reboot under 3.13.0-63-generic.  My code works.  I reboot under 
3.13.0-65-generic.  My code doesn't.  Implication would seem to be that 
somehow between these kernel versions, the select() logic in the serial 
driver changed.  This happens regardless of whether the serial port is 
real, FTDI USB-UART, or Prolific USB-UART.

Can anyone else confirm?  Also, who do I try to report this one to?

Thanks,
Rob

-- 
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.
-- 
https://mail.python.org/mailman/listinfo/python-list


ANN: pySerial 3.0a0

2015-09-23 Thread Chris Liechti

A new prerelease of pySerial is available. There have been a lot
of changes so that the major version was bumped up to 3.

Changes include:
- Python 2.7 and Python 3.2+ from the same sources (lib2to3 is
  no longer used)
- More properties, the set functions are deprecated.
- Updated miniterm (uses Unicode for console output, supports
  encodings on serial port, nicer port selection and more).
- IPv6 support for rfc2217:// and socket://
- New spy:// handler to log traffic and control calls.
- URL parameters have changed.
- Experimental asyncio support (posix)
- A number of other bugfixes.
- And more...

See https://github.com/pyserial/pyserial/blob/master/CHANGES.rst
for more details.

Changes in development:
- SVN -> GIT
- moved (from SF) to github: https://github.com/pyserial/pyserial

Currently unsupported is the Jython platform (lack of testing).

Download at: https://github.com/pyserial/pyserial/releases
Docs: https://pyserial.readthedocs.org/en/latest/

chris
--
https://mail.python.org/mailman/listinfo/python-announce-list

   Support the Python Software Foundation:
   http://www.python.org/psf/donations/


pyserial and threads

2015-09-17 Thread pozz
I'm trying to create a simple program in Python that opens N serial 
ports (through pyserial) and forward every byte received on one of those 
ports to the other ports.


At startup I open the ports and create and start a thread to manage the 
receiving. When a byte is received, I call the .write() method for all 
the other ports.


It works, but sometimes it seems to block. I think I haven't used 
correctly the threads.


Below is my code, I hope someone can help me.

Consider that I'm a newbie in python and I never used threads before.


import serial
import threading
import sys, os
import signal
import time

class Miniterm(object):
  def __init__(self, port, baudrate):
self.serial = serial.Serial(port, baudrate, timeout=1)

  def start(self, com_list):
self.alive = True
self.com_list = com_list
self._reader_alive = True
self.receiver_thread = threading.Thread(target=self.reader)
self.receiver_thread.setDaemon(True)
self.receiver_thread.start()

  def stop(self):
self.alive = False

  def reader(self):
try:
  while self.alive and self._reader_alive:
data = self.serial.read(1)
  if len(data) > 0:
  for p in self.com_list:
if p[1] != self:
  p[1].write(data)
except serial.SerialException:
  self.alive = False
  raise

  def write(self, data):
self.serial.write(data)

if __name__ == "__main__":
  ports = []
  for com in sys.argv[1:]:
try:
  miniterm = Miniterm(com, 38400)
except serial.SerialException:
  sys.stderr.write("could not open port " + com)
  sys.exit(1)
ports.append((com, miniterm))
for p in ports:
  p[1].start(ports)
  print("Port " + p[0] + " has started", flush=True)
while True:
  time.sleep(1)

--
https://mail.python.org/mailman/listinfo/python-list


Re: pyserial and threads

2015-09-17 Thread alister
On Thu, 17 Sep 2015 11:28:04 +0200, pozz wrote:

> I'm trying to create a simple program in Python that opens N serial
> ports (through pyserial) and forward every byte received on one of those
> ports to the other ports.
> 
> At startup I open the ports and create and start a thread to manage the
> receiving. When a byte is received, I call the .write() method for all
> the other ports.
> 
> It works, but sometimes it seems to block. I think I haven't used
> correctly the threads.
> 
> Below is my code, I hope someone can help me.
> 
> Consider that I'm a newbie in python and I never used threads before.
> 
> 
> import serial import threading import sys, os import signal import time
> 
> class Miniterm(object):
>def __init__(self, port, baudrate):
>  self.serial = serial.Serial(port, baudrate, timeout=1)
> 
>def start(self, com_list):
>  self.alive = True self.com_list = com_list self._reader_alive =
>  True self.receiver_thread = threading.Thread(target=self.reader)
>  self.receiver_thread.setDaemon(True) self.receiver_thread.start()
> 
>def stop(self):
>  self.alive = False
> 
>def reader(self):
>  try:
>while self.alive and self._reader_alive:
>  data = self.serial.read(1)
>if len(data) > 0:
>for p in self.com_list:
>  if p[1] != self:
>p[1].write(data)
>  except serial.SerialException:
>self.alive = False raise
> 
>def write(self, data):
>  self.serial.write(data)
>   
> if __name__ == "__main__":
>ports = []
>for com in sys.argv[1:]:
>  try:
>miniterm = Miniterm(com, 38400)
>  except serial.SerialException:
>sys.stderr.write("could not open port " + com) sys.exit(1)
>  ports.append((com, miniterm))
>  for p in ports:
>p[1].start(ports)
>print("Port " + p[0] + " has started", flush=True)
>  while True:
>time.sleep(1)

I would like to know more about how many serial ports are connected & 
what the equipment they are connected to does and expects.

I can see the data being transmitted snowballing & running away in a +ve 
feedback loop very easily.




-- 
The only "ism" Hollywood believes in is plagiarism.
-- Dorothy Parker
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pyserial and threads

2015-09-17 Thread Chris Angelico
On Thu, Sep 17, 2015 at 7:28 PM, pozz  wrote:
> At startup I open the ports and create and start a thread to manage the
> receiving. When a byte is received, I call the .write() method for all the
> other ports.
>
> It works, but sometimes it seems to block. I think I haven't used correctly
> the threads.
>

Seems a fairly reasonable model. From what I'm seeing here, you start
a thread to read from each serial port, but then those threads will
make blocking writes to all the other serial ports. Is it possible
that one of them is getting full?

When I do this kind of thing with TCP/IP sockets, I usually end up
having to go non-blocking in both directions, and maintaining a buffer
of unsent text for each socket. You may find that you need to do the
same thing here.

Where's the code getting blocked?

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pyserial and threads

2015-09-17 Thread pozz

Il 17/09/2015 15:04, Dennis Lee Bieber ha scritto:

On Thu, 17 Sep 2015 12:00:08 + (UTC), alister
 declaimed the following:



I can see the data being transmitted snowballing & running away in a +ve
feedback loop very easily.


Especially if a few of the remote devices are configured to ECHO
data... 


No ECHO.



Main thing I'd probably change is... Since the COM port identification
is already being provided during initialization of the handler object, why
maintain a list of (com, handler) pairs, and the subsequent subscripting --
just save the com port as an attribute of the object.

One could also make a copy of the object list in the start method, and
at that point, scan the list and remove that one's own identity. That would
remove the need for always testing "is the object I'm about to send to
really me?"


Ok, they are optimizations, but I don't think they solve my issue.

--
https://mail.python.org/mailman/listinfo/python-list


Re: pyserial and threads

2015-09-17 Thread pozz

Il 17/09/2015 14:00, alister ha scritto:


I would like to know more about how many serial ports are connected


One real serial port and two virtual serial ports, created by com0com 
(it's a free virtual serial port for Windows).




what the equipment they are connected to does and expects.


Raw bytes arranged in a well defined protocol. I'm the author of the 
protocol and equipments :-)




I can see the data being transmitted snowballing & running away in a +ve
feedback loop very easily.


No, because the byte received by first COM port is forwarded/transmitted 
to all the OTHERS COM ports in the list.

--
https://mail.python.org/mailman/listinfo/python-list


Re: pyserial and threads

2015-09-17 Thread Chris Angelico
On Thu, Sep 17, 2015 at 11:26 PM, pozz <pozzu...@gmail.com> wrote:
> How to have a non-blocking write?
>
> Maybe the problem happens when port 1 thread is in .read() (it blocks for 1
> second) and port 2 thread tries to write one byte (that was just received)
> to port 1.

I'm not sure, as I've never worked with serial ports in this way. What
you'd want is some form of call that says "write these bytes if you
can, but don't if you can't, and just tell me how many you wrote". A
quick look at the pyserial docs suggests that you may be able to
accomplish this by opening the port with writeTimeout=0, or possibly
some other value (it'll wait that many seconds - float allowed -
before giving up).

If it returns 0, stating that the byte wasn't written, you'd need to
hang onto that byte until it can write successfully. I've no idea how
you'd go about knowing that. With TCP sockets, select.select() is your
friend; if you're really lucky, pyserial will work with the same kind
of structure.

>> Where's the code getting blocked?
>
> I don't knwo exactly. I can only see no more bytes are received on COM
> ports.

Here's a way to test: Bracket each potentially-blocking call with a
status update, and then have your main loop collect the statuses and
print them out. Something like this:

  def reader(self):
try:
  while self.alive and self._reader_alive:
self.status = 'R' # Reading
data = self.serial.read(1)
self.status = 'P' # Processing
if len(data) > 0:
  for n,p in enumerate(self.com_list):
if p[1] != self:
  self.status = n # Writing to port n
  p[1].write(data)
  self.status = 'P'
except serial.SerialException:
  # This looks like a job for try/finally, actually
  self.status = 'Z' # Dead
  self.alive = False
  raise

Then your main thread, instead of just sleeping forever, does this:

while True:
  time.sleep(1)
  print(" ".join(port.status for port in ports), end="\r", flush=True)

You should normally see most of the threads blocked on reading,
assuming that the traffic levels are lower than the ports' capacities.
If you start seeing them blocked on writing, chances are they'll all
be blocking on the same port, and that's the port that's holding you
up.

Caution: Code utterly untested. You may have to debug some stuff.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pyserial and threads

2015-09-17 Thread pozz

Il 17/09/2015 11:42, Chris Angelico ha scritto:

On Thu, Sep 17, 2015 at 7:28 PM, pozz  wrote:

At startup I open the ports and create and start a thread to manage the
receiving. When a byte is received, I call the .write() method for all the
other ports.

It works, but sometimes it seems to block. I think I haven't used correctly
the threads.



Seems a fairly reasonable model. From what I'm seeing here, you start
a thread to read from each serial port, but then those threads will
make blocking writes to all the other serial ports. Is it possible
that one of them is getting full?

When I do this kind of thing with TCP/IP sockets, I usually end up
having to go non-blocking in both directions, and maintaining a buffer
of unsent text for each socket. You may find that you need to do the
same thing here.


How to have a non-blocking write?

Maybe the problem happens when port 1 thread is in .read() (it blocks 
for 1 second) and port 2 thread tries to write one byte (that was just 
received) to port 1.




Where's the code getting blocked?


I don't knwo exactly. I can only see no more bytes are received on COM 
ports.

--
https://mail.python.org/mailman/listinfo/python-list


Re: pySerial works in miniterm but not in my app

2014-11-01 Thread Dario
Il giorno venerdì 31 ottobre 2014 19:00:26 UTC+1, Dennis Lee Bieber ha scritto:

 Didn't quite answer my question. If the comm line is using remote 

I understand your point, I didn't mention but I also tried sending one char at 
a time and listening at the same time, nothing changed.

BUT.. plot twist: in Windows XP, the very same python code and usb adapter are 
working just right (python 2.7 and pySerial 2.7). Also with c#, no issues.

So one could blame the usb adapter or its drivers, but the fact is that minicom 
(not miniterm) always works, while miniterm only works if used after minicom, 
and only the first time.

I mean: I start minicom, it works. Close it (quit without reset), start 
miniterm, it works. Close miniterm, open it again, just garbage...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pySerial works in miniterm but not in my app

2014-11-01 Thread Dario
Il giorno sabato 1 novembre 2014 16:04:06 UTC+1, Dario ha scritto:

 BUT.. plot twist: in Windows XP, the very same python code and usb adapter 
 are working just right (python 2.7 and pySerial 2.7). Also with c#, no issues.

I compared the behaviour of mono and python (2.7 and 3.3) on the same hw and 
os, I guess something is wrong with pySerial implementation...

Mono code on Mint:


SerialPort s = new SerialPort(/dev/ttyUSB0, 19200, Parity.None, 8, 
StopBits.One);
s.Open();

s.Write(sw o01 +\r);

while (true)
Console.Write(Convert.ToChar(s.ReadByte()));


Device reacts correctly and I get back what I expect (the first line is because 
I sent the command via com port, the second is because I pushed a button on the 
device):

dario@ivymint ~ $ sudo ./Test1.exe 
sw o01 + Command OK
Button 1 pushed


Now equivalent Python 3.3 code on Mint:

---
import serial

s = serial.serial_for_url('/dev/ttyUSB0', 19200, bytesize = 8, parity = 'N', 
stopbits = 1)

s.close()
s.open()
s.write(bytearray('sw o01 +\r','ascii'))

while True:
print(s.read())
---

In this case, I don't receive anything for my command, and when I press I 
receive garbage instead of Button 1 pushed

dario@ivymint ~ $ sudo python3 ./test2.py 
b'\xfc'
b'\x8f'
b'\r'
b'\x85'
b'1'
b'+'
b'\xfe'
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pySerial works in miniterm but not in my app

2014-11-01 Thread Dario
Ehm sorry for the neverending spam, anyway I tried from my raspberry pi and it 
works there:

root@pi:/home/pi# python3 ./test.py 
b's'
b'w'
b' '
b'o'
b'0'
b'1'
b' '
b'+'
b' '
b'C'
b'o'
b'm'
b'm'
b'a'
b'n'
b'd'
b' '
b'O'
b'K'
b'\r'
b'\n'

Since I need it to work on the rpi and I was using Mint only for easiness, I'm 
ok with it :)

Thanks.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pySerial works in miniterm but not in my app

2014-10-31 Thread Dario
Il giorno giovedì 30 ottobre 2014 23:57:40 UTC+1, Dennis Lee Bieber ha scritto:

 sw o01 + --- I send this

 How do you send this... 

I just type or paste it in miniterm and hit return. Miniterm sends the return 
as CR, but it also works with CRLF.

 sw o01 + Command OK --- device does what it should *and* I receive this

 Is that a new line, or somehow part of the same line?

This is the response from the device, saying that my command was ok, and it 
also does what it should (it's an hdmi 4-4 matrix, it switches the first output 
to the next input).

 s.write('sw o01 +\r')

 What happens if you use \n... or \r\n ?

In my app, that doesn't make any difference, never works. In miniterm, only CR 
and CRLF work, LF alone does not.

This evening I'll try with com0com to see what is really sent...

-- 
Dario
-- 
https://mail.python.org/mailman/listinfo/python-list


pySerial works in miniterm but not in my app

2014-10-30 Thread Dario
Python 2.7.6 on Mint, pySerial 2.6

I'm trying to write a console app to control a certain device via a usb com 
port.

In miniterm (-p /dev/ttyUSB0 -e -b 19200), I can communicate correctly with 
this configuration:

--- Settings: /dev/ttyUSB0  19200,8,N,1
--- RTS: inactive  DTR: inactive  BREAK: inactive
--- CTS: inactive  DSR: inactive  RI: inactive  CD: inactive
--- software flow control: inactive
--- hardware flow control: inactive
--- data escaping: raw  linefeed: CR

sw o01 + --- I send this
sw o01 + Command OK --- device does what it should *and* I receive this


Now my code:


import serial

s = serial.serial_for_url(
'/dev/ttyUSB0',
19200,
bytesize = 8,
parity   = 'N',
stopbits = 1,
rtscts   = False,
dsrdtr   = False,
xonxoff  = False,
timeout  = 1 # tried without
)
s.close() # tried without
s.open()
s.write('sw o01 +\r')
s.flush() # tried without
s.close() # tried with a sleep before close


With this I don't receive anything (tried with readline etc, omitted for 
readability), and the device doesn't react. Also, if I connect again with 
miniterm and issue the command, I first receive a wrong command message, as 
if some garbage was actually sent by my app, then it works again.

Isn't my config equivalent to the one in miniterm? Anything missing?

Thanks

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pyserial on freebsd 10.10 i386 [SOLVED]

2014-10-19 Thread Grant Edwards
On 2014-10-18, Nagy L?szl? Zsolt gand...@shopzeus.com wrote:

 Strangely, pyserial will accept the number 0, but then it tries to open 
 a device that exists on Linux only...

I'm sure Chris would be happy to accept a patch fixing that problem.

-- 
Grant


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pyserial on freebsd 10.10 i386 [SOLVED]

2014-10-19 Thread Mark Lawrence

On 19/10/2014 16:06, Grant Edwards wrote:

On 2014-10-18, Nagy L?szl? Zsolt gand...@shopzeus.com wrote:


Strangely, pyserial will accept the number 0, but then it tries to open
a device that exists on Linux only...


I'm sure Chris would be happy to accept a patch fixing that problem.



Sadly to some people a patch is a thing that mends your flat tyre or 
goes over your eye.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list


pyserial on freebsd 10.10 i386

2014-10-18 Thread Nagy László Zsolt


I'm trying to open a serial port with pyserial on a Compaq Deskpro EN 
machine. Operating system is FreeBSD 10.10 RELEASE, i386.


root@merleg:~ # kldload scc
root@merleg:~ # python2.7 -m serial.tools.list_ports
no ports found
root@merleg:~ # whoami
root


Here are all the devices:

root@merleg:~ # ls /dev

acpicttyklogstdin   ttyva
ad0 cuau0   kmemstdout  ttyvb
ad0p1   cuau0.init  log sysmousettyvc
ad0p2   cuau0.lock  lpt0ttyu0   ttyvd
ad0p3   cuau1   lpt0.ctlttyu0.init  ttyve
ada0cuau1.init  mdctl   ttyu0.lock  ttyvf
ada0p1  cuau1.lock  mem ttyu1   ufssuspend
ada0p2  devctl  midistatttyu1.init  ugen0.1
ada0p3  devstat mixer0  ttyu1.lock  ugen0.2
agpgart fd  nfslock ttyv0   uhid0
apm fd0 nullttyv1   ukbd0
apmctl  fidopass0   ttyv2   urandom
atkbd0  geom.ctlpass1   ttyv3   usb
audit   gptid   pci ttyv4   usbctl
bpf io  ppi0ttyv5   xpt0
bpf0kbd0pts ttyv6   zero
cd0 kbd1random  ttyv7
console kbd2sndstat ttyv8
consolectl  kbdmux0 stderr  ttyv9


And here is what I see in dmesg:

root@merleg:~ # dmesg | grep uart

uart0: 16550 or compatible port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0

uart1: 16550 or compatible port 0x2f8-0x2ff irq 3 on acpi0

Obviously the question is: how do I open the COM port from pyserial on 
this machine?




--
https://mail.python.org/mailman/listinfo/python-list


Re: pyserial on freebsd 10.10 i386 [SOLVED]

2014-10-18 Thread Nagy László Zsolt
The port parameter of serial.Serial should be /dev/ttyu0 instead of 
COM1, and /dev/ttyu1 instead of COM2.


Strangely, pyserial will accept the number 0, but then it tries to open 
a device that exists on Linux only...


Anyway, problem solved.
--
https://mail.python.org/mailman/listinfo/python-list


Pyserial for Python3 in OSX?

2014-02-15 Thread eglowstein . h
I need to do some serial I/O on a Mac running OSX Mavericks. I followed the 
instructions at

http://stackoverflow.com/questions/20082935/how-to-install-pip-for-python3-on-mac-os-x

to install pyserial. OSX already had Python 2.7 and pyserial seems to work okay 
in 2.7, but I can't figure out how to get to run in 3.3.3 or 3.3.4.

After I install pyserial, in python 2.7 I can get this:

Python 2.7.5 (default, Sep 12 2013, 21:33:34) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type help, copyright, credits or license for more information.
 from serial.tools import list_ports
 list_ports.comports()
[['/dev/cu.Bluetooth-Incoming-Port', 'n/a', 'n/a'], ['/dev/cu.Bluetooth-Modem', 
'n/a', 'n/a'], ['/dev/cu.usbserial-AH012QEW', 'FT232R USB UART', 'USB 
VID:PID=403:6001 SNR=AH012QEW']]
 quit()

In Python 3, I get this:

Python 3.3.4 (default, Feb 15 2014, 21:28:44) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type help, copyright, credits or license for more information.
 from serial.tools import list_ports
 list_ports.comports()
[]
 quit()


I see all sorts of messages around the web suggesting similar problems getting 
Python 3 on a Mac to talk to serial ports but I can't find any fixes. Is there 
a trick I haven't found yet? Many thanks in advance for a cure.

Howard
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Logging data from Arduino using PySerial

2014-02-04 Thread MRAB

On 2014-02-04 04:07, Thomas wrote:

I've written a script to log data from my Arduino to a csv file. The script 
works well enough but it's very, very slow. I'm quite new to Python and I just 
wanted to put this out there to see if any Python experts could help optimise 
my code. Here it is:


[snip]

 # Cleaning the data_log and storing it in data.csv
 with open('data.csv','wb') as csvfile:
 for line in data_log:
 line_data = re.findall('\d*\.\d*',line) # Find all digits
 line_data = filter(None,line_data)# Filter out empty strings
 line_data = [float(x) for x in line_data] # Convert Strings to 
float

 for i in range(1,len(line_data)):
 line_data[i]=map(line_data[i],0,1023,0,5)


You're doing this for every in line the log:


 csvwrite = csv.writer(csvfile)

[snip]

Try moving before the 'for' loop so it's done only once.

--
https://mail.python.org/mailman/listinfo/python-list


Logging data from Arduino using PySerial

2014-02-03 Thread Thomas
I've written a script to log data from my Arduino to a csv file. The script 
works well enough but it's very, very slow. I'm quite new to Python and I just 
wanted to put this out there to see if any Python experts could help optimise 
my code. Here it is:

import serial
import re
import csv
import numpy as np
import matplotlib.pyplot as plt

portPath = /dev/ttyACM0
baud = 9600
sample_time = 0.5
sim_time = 30


# Initializing Lists
# Data Collection
data_log = []
line_data = []

def map(x, in_min, in_max, out_min, out_max):
return (((x - in_min) * (out_max - out_min))/(in_max - in_min)) + 
out_min

# Establishing Serial Connection
connection = serial.Serial(portPath,baud)

# Calculating the length of data to collect based on the
# sample time and simulation time (set by user)
max_length = sim_time/sample_time

# Collecting the data from the serial port
while True:
data_log.append(connection.readline())
if len(data_log)  max_length - 1:
break

# Cleaning the data_log and storing it in data.csv
with open('data.csv','wb') as csvfile:
for line in data_log:
line_data = re.findall('\d*\.\d*',line) # Find all digits
line_data = filter(None,line_data)# Filter out empty strings
line_data = [float(x) for x in line_data] # Convert Strings to float

for i in range(1,len(line_data)):
line_data[i]=map(line_data[i],0,1023,0,5)

csvwrite = csv.writer(csvfile)
csvwrite.writerow(line_data)



plt.clf()
plt.close()
plt.plotfile('data.csv',(0,1,2),names=['time (s)','voltage2 (V)','voltage1 
(V)'],newfig=True)
plt.show()


I'd appreciate any help/tips you can offer.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Logging data from Arduino using PySerial

2014-02-03 Thread Chris Angelico
On Tue, Feb 4, 2014 at 3:07 PM, Thomas t.tchorzew...@gmail.com wrote:
 I've written a script to log data from my Arduino to a csv file. The script 
 works well enough but it's very, very slow. I'm quite new to Python and I 
 just wanted to put this out there to see if any Python experts could help 
 optimise my code. Here it is:


The most important question is: Have you profiled your code? That is,
do you know which part(s) are slow?

And the first part of that question is: Define slow. How long does
your program actually take? How much data are you accumulating in that
time? By my reading, you're getting 60 lines from the serial port; how
long is each line?

For a basic back-of-the-envelope timing estimate, work out how long
each line is (roughly), and multiply by 60 (number of lines), then
divide by 960 (your baud rate, divided by 10, which gives a rough
bytes-per-second rate). That'll give you a ball-park figure for how
many seconds this loop will take:

 # Collecting the data from the serial port
 while True:
 data_log.append(connection.readline())
 if len(data_log)  max_length - 1:
 break

If your lines are 80 characters long, give or take, then that works
out to 80*60/960 = five seconds just to fetch the data from the serial
port. So if the script is taking anywhere from 3 to 8 seconds to run,
then you can assume that it's probably spending most of its time right
here. Yes, that might feel like it's really slow, but it's all down to
your baud rate. You can easily confirm this by surrounding that loop
with:

import time
start_time = time.time()
while ...
   ... append ...
print(Time to fetch from serial port:,time.time()-start_time)

(If this is Python 2, this will produce slightly ugly output as it'll
display it as a tuple. It'll work though.)

Put that in, and then run the program with some kind of external
timing. On Linux, that would be:

$ time python scriptname.py

If the total script execution is barely more than the time spent in
that loop, don't bother optimizing any of the rest of the code - it's
a waste of time improving something that's not materially affecting
your total run time.

But while I'm here looking at your code, I'll take the liberty of
making a few stylistic suggestions :) Feel free to ignore these, but
this is the more Pythonic way of writing the code. Starting with the
serial port fetch loop:

 # Collecting the data from the serial port
 while True:
 data_log.append(connection.readline())
 if len(data_log)  max_length - 1:
 break

An infinite loop with a conditional break exactly at one end. This
would be clearer written as a straight-forward conditional loop, with
the condition inverted:

while len(data_log)  max_length:
data_log.append(connection.readline())

This isn't strictly identical to your previous version, but since
len(data_log) will always be an integer, it is - I believe -
functionally equivalent. But make sure I haven't introduced any bugs.
:)

(There is another difference, in that my version checks the condition
on entry where yours would check it only after doing the first append
- your version would guarantee a minimum of one line in the log, mine
won't. I'm guessing that this won't be significant in normal usage; if
it is, go back to your version of the code.)

 def map(x, in_min, in_max, out_min, out_max):
 return (((x - in_min) * (out_max - out_min))/(in_max - in_min)) + 
 out_min

This shadows the built-in map() function. It works, but it's usually
safer to not do this, in case you subsequently want the default map().

 line_data = re.findall('\d*\.\d*',line) # Find all digits
 line_data = filter(None,line_data)# Filter out empty strings
 line_data = [float(x) for x in line_data] # Convert Strings to 
 float

You can combine these.

line_data = [float(x) for x in re.findall('\d*\.\d*',line) if x]

Optionally break out the re into a separate line, but definitely I'd
go with the conditional comprehension above the separate filter():

line_data = re.findall('\d*\.\d*',line)
line_data = [float(x) for x in line_data if x]

 for i in range(1,len(line_data)):
 line_data[i]=map(line_data[i],0,1023,0,5)

Is it deliberate that you start from 1 here? Are you consciously
skipping the first element, leaving it unchanged? If not, I would go
for another comprehension:

line_data = [map(x,0,1023,0,5) for x in line_data]

but if so, this warrants a code comment explaining why the first one is special.

 plt.clf()
 plt.close()
 plt.plotfile('data.csv',(0,1,2),names=['time (s)','voltage2 
 (V)','voltage1 (V)'],newfig=True)
 plt.show()

This, btw, is the other place that I'd look for a potentially large
slab of time. Bracket this with time.time() calls as above, and see
whether it's slow enough to mean nothing else is a concern. But I'd
first look at the serial port read loop; depending on how long your

Re: Logging data from Arduino using PySerial

2014-02-03 Thread Thomas
Wow...Thanks Chris! I really appreciate your suggestions (including the 
stylistic ones). I'll definitely be revising my code as soon as I find the 
time. As far as profiling goes, I've used timeit in the past but it's quite a 
pain going through any program block by block. I wish there were a program in 
which you could just toss in a script and it would spit out the bottlenecks in 
your code (with suggested performance improvements perhaps)...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Logging data from Arduino using PySerial

2014-02-03 Thread Chris Angelico
On Tue, Feb 4, 2014 at 3:57 PM, Thomas t.tchorzew...@gmail.com wrote:
 Wow...Thanks Chris! I really appreciate your suggestions (including the 
 stylistic ones). I'll definitely be revising my code as soon as I find the 
 time. As far as profiling goes, I've used timeit in the past but it's quite a 
 pain going through any program block by block. I wish there were a program in 
 which you could just toss in a script and it would spit out the bottlenecks 
 in your code (with suggested performance improvements perhaps)...


Well, timeit is good for microbenchmarking. (How useful
microbenchmarking itself is, now, that's a separate question.) For
anything where you can feel the program's time by human, it's easy
enough to use the time.time() function.

Add a little helper like this (untested):

last_time = time.time()
def tt(desc):
global last_time
cur_time=time.time()
print(%s: %f%(desc,cur_time-last_time))
last_time=cur_time


Then put this all through your code:



# Calculating the length of data to collect based on the
# sample time and simulation time (set by user)
max_length = sim_time/sample_time

tt(Init)

# Collecting the data from the serial port
while True:
data_log.append(connection.readline())
if len(data_log)  max_length - 1:
break

tt(Serial)

...

etc etc. Give it a short description saying what's just happened
(because it'll give the time since the previous timepoint), and then
just eyeball the results to see where the biggest numbers are. If you
do it right, you'll find a whole pile of sections with tiny numbers,
which you can easily ignore, and just a handful that even register.
Then you dig into those sections and see where the slowness is.

Be careful, though. You can easily waste hundreds of expensive dev
hours trying to track down an insignificant time delay. :)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PySerial for Python 2 vs. Python 3

2014-01-01 Thread Terry Reedy

On 1/1/2014 1:48 AM, Chris Angelico wrote:

On Wed, Jan 1, 2014 at 5:39 PM, Travis McGee nob...@gmail.com wrote:


What OS? If Windows, did you install the -py3k version for 3.x?


Anyway, I finally got it installed, but when I try to use a statement of the
sort ser.write(string) I get an exception which seems to imply that the
argument needs to be an integer, rather than a string.


According to a Stackoverflow issue, .write(n) will write n 0 bytes 
because it will send bytes(n) == n * bytes(b'\0').


PySerial is written in Python, so you could look at the .write method of 
the Serial class (presuming that 'ser' is an instance thereof) to see 
what it does.



Quoting the full exception would help!

My suspicion is that it works with byte strings, not Unicode strings.


That is what the doc either says or implies.


So you could do:

ser.write(bstring)

or:

ser.write(string.encode())

to turn it into a stream of bytes (the latter uses UTF-8, the former
would use your source file encoding).


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


PySerial for Python 2 vs. Python 3

2013-12-31 Thread Travis McGee
I've been working with a simple serial device that attaches to a USB 
port. It takes as commands short strings.


I wanted to use PySerial under Python 3, and, of course had the Devil's 
own time getting it installed and working since everything is geared 
towards Python 2.


Anyway, I finally got it installed, but when I try to use a statement of 
the sort ser.write(string) I get an exception which seems to imply 
that the argument needs to be an integer, rather than a string.


With some minor adjustments it works just fine under Python 2, so, in a 
sense, this is a non-issue. However, I'd be interested to hear from 
anyone who can comment on what the problem is.


Thanks,

Travis
--
https://mail.python.org/mailman/listinfo/python-list


Re: PySerial for Python 2 vs. Python 3

2013-12-31 Thread Devin Jeanpierre
On Tue, Dec 31, 2013 at 10:39 PM, Travis McGee nob...@gmail.com wrote:
 Anyway, I finally got it installed, but when I try to use a statement of the
 sort ser.write(string) I get an exception which seems to imply that the
 argument needs to be an integer, rather than a string.

You will get the most help if you provide a minimal, self-contained,
runnable example, and an example of its exact output.

-- Devin
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PySerial for Python 2 vs. Python 3

2013-12-31 Thread Chris Angelico
On Wed, Jan 1, 2014 at 5:39 PM, Travis McGee nob...@gmail.com wrote:
 Anyway, I finally got it installed, but when I try to use a statement of the
 sort ser.write(string) I get an exception which seems to imply that the
 argument needs to be an integer, rather than a string.

Quoting the full exception would help!

My suspicion is that it works with byte strings, not Unicode strings.
So you could do:

ser.write(bstring)

or:

ser.write(string.encode())

to turn it into a stream of bytes (the latter uses UTF-8, the former
would use your source file encoding).

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PySerial for Python 2 vs. Python 3

2013-12-31 Thread Steven D'Aprano
Travis McGee wrote:

 I've been working with a simple serial device that attaches to a USB
 port. It takes as commands short strings.
 
 I wanted to use PySerial under Python 3, and, of course had the Devil's
 own time getting it installed and working since everything is geared
 towards Python 2.
 
 Anyway, I finally got it installed, but when I try to use a statement of
 the sort ser.write(string) I get an exception which seems to imply
 that the argument needs to be an integer, rather than a string.

Seems to imply?


 With some minor adjustments it works just fine under Python 2, so, in a
 sense, this is a non-issue. However, I'd be interested to hear from
 anyone who can comment on what the problem is.

While I'd love to tell you exactly what the problem is, my crystal ball is
out of action. If you'd be so kind as to copy and paste the actual
exception, assuming it isn't a secret, perhaps we'll be able to tell you
what it actually says.


-- 
Steven

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The state of pySerial

2013-05-30 Thread MRAB

On 30/05/2013 02:32, Ma Xiaojun wrote:

I've already mailed the author, waiting for reply.

For Windows people, downloading a exe get you pySerial 2.5, which
list_ports and miniterm feature seems not included. To use 2.6,
download the tar.gz and use standard setup.py install to install it
(assume you have .py associated) . There is no C compiling involved in
the installation process.

For whether Python 3.3 is supported or not. I observed something like:
http://paste.ubuntu.com/5715275/ .

miniterm works for Python 3.3 at this time.


The problem there is that 'desc' is a bytestring, but the regex pattern
can match only a Unicode string (Python 3 doesn't let you mix
bytestrings and Unicode string like a Python 2).

The simplest fix would probably be to decode 'desc' to Unicode.
--
http://mail.python.org/mailman/listinfo/python-list


The state of pySerial

2013-05-29 Thread Ma Xiaojun
Hi, all.

pySerial is probably the solution for serial port programming.
Physical serial port is dead on PC but USB-to-Serial give it a second
life. Serial port stuff won't interest end users at all. But it is
still used in the EE world and so on. Arduino uses it to upload
programs. Sensors may use serial port to communicate with PC. GSM
Modem also uses serial port to communicate with PC.

Unforunately, pySerial project doesn't seem to have a good state. I
find pySerial + Python 3.3 broken on my machine (Python 2.7 is OK) .
There are unanswered outstanding bugs, PyPI page has 2.6 while SF
homepage still gives 2.5.

Any idea?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The state of pySerial

2013-05-29 Thread Grant Edwards
On 2013-05-29, Ma Xiaojun damage3...@gmail.com wrote:

 pySerial is probably the solution for serial port programming.
 Physical serial port is dead on PC but USB-to-Serial give it a second
 life. Serial port stuff won't interest end users at all. But it is
 still used in the EE world and so on. Arduino uses it to upload
 programs. Sensors may use serial port to communicate with PC. GSM
 Modem also uses serial port to communicate with PC.

 Unforunately, pySerial project doesn't seem to have a good state. I
 find pySerial + Python 3.3 broken on my machine (Python 2.7 is OK) .
 There are unanswered outstanding bugs, PyPI page has 2.6 while SF
 homepage still gives 2.5.

 Any idea?

Volunteer as a maintainer and start fixing bugs?

I use pyserial regularly, and the current version works fine for me,
but I'm using Python 2.7. There are still too many libraries that
don't support 3.x for me to consider using 3.x for real work.

-- 
Grant Edwards   grant.b.edwardsYow! They collapsed
  at   ... like nuns in the
  gmail.comstreet ... they had no
   teen appeal!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The state of pySerial

2013-05-29 Thread William Ray Wing
On May 29, 2013, at 2:23 PM, Ma Xiaojun damage3...@gmail.com wrote:

 Hi, all.
 
 pySerial is probably the solution for serial port programming.
 Physical serial port is dead on PC but USB-to-Serial give it a second
 life. Serial port stuff won't interest end users at all. But it is
 still used in the EE world and so on. Arduino uses it to upload
 programs. Sensors may use serial port to communicate with PC. GSM
 Modem also uses serial port to communicate with PC.
 
 Unforunately, pySerial project doesn't seem to have a good state. I
 find pySerial + Python 3.3 broken on my machine (Python 2.7 is OK) .
 There are unanswered outstanding bugs, PyPI page has 2.6 while SF
 homepage still gives 2.5.
 
 Any idea?
 -- 
 http://mail.python.org/mailman/listinfo/python-list

Let me add another vote/request for pySerial support.  I've been using it with 
python 2.7 on OS-X, unaware that there wasn't a path forward to python 3.x.  If 
an external sensor absolutely positively has to be readable, then RS-232 is the 
only way to go.  USB interfaces can and do lock up if recovery from a power 
failure puts power on the external side before the computer has finished 
initializing the CPU side.  RS-232, bless its primitive heart, could care less.

Thanks,
Bill
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The state of pySerial

2013-05-29 Thread Terry Jan Reedy

On 5/29/2013 4:00 PM, William Ray Wing wrote:

On May 29, 2013, at 2:23 PM, Ma Xiaojun damage3...@gmail.com wrote:


Hi, all.

pySerial is probably the solution for serial port programming.
Physical serial port is dead on PC but USB-to-Serial give it a second
life. Serial port stuff won't interest end users at all. But it is
still used in the EE world and so on. Arduino uses it to upload
programs. Sensors may use serial port to communicate with PC. GSM
Modem also uses serial port to communicate with PC.

Unforunately, pySerial project doesn't seem to have a good state. I
find pySerial + Python 3.3 broken on my machine (Python 2.7 is OK) .
There are unanswered outstanding bugs, PyPI page has 2.6 while SF
homepage still gives 2.5.

Any idea?
--
http://mail.python.org/mailman/listinfo/python-list


Let me add another vote/request for pySerial support.  I've been using it with 
python 2.7 on OS-X, unaware that there wasn't a path forward to python 3.x.  If 
an external sensor absolutely positively has to be readable, then RS-232 is the 
only way to go.  USB interfaces can and do lock up if recovery from a power 
failure puts power on the external side before the computer has finished 
initializing the CPU side.  RS-232, bless its primitive heart, could care less.


Then 'someone' should ask the author his intentions and offer to help or 
take over.


I did some RS-232 interfacing in the  1980s, and once past the fiddly 
start/stop/parity bit, baud rate, and wiring issues, I had a program run 
connected to multiple machines for years with no more interface problems.


Terry


--
http://mail.python.org/mailman/listinfo/python-list


Re: The state of pySerial

2013-05-29 Thread Terry Jan Reedy

On 5/29/2013 3:47 PM, Grant Edwards wrote:

On 2013-05-29, Ma Xiaojun damage3...@gmail.com wrote:


pySerial is probably the solution for serial port programming.
Physical serial port is dead on PC but USB-to-Serial give it a second
life. Serial port stuff won't interest end users at all. But it is
still used in the EE world and so on. Arduino uses it to upload
programs. Sensors may use serial port to communicate with PC. GSM
Modem also uses serial port to communicate with PC.

Unforunately, pySerial project doesn't seem to have a good state. I
find pySerial + Python 3.3 broken on my machine (Python 2.7 is OK) .
There are unanswered outstanding bugs, PyPI page has 2.6 while SF
homepage still gives 2.5.

Any idea?


Volunteer as a maintainer and start fixing bugs?


It seems to be getting around 200 downloands a day. Quite worth someone 
supporting it.



I use pyserial regularly, and the current version works fine for me,
but I'm using Python 2.7. There are still too many libraries that
don't support 3.x for me to consider using 3.x for real work.


The only download is a .exe. It it just the executable binary or is that 
a zip unpacker with source?




--
http://mail.python.org/mailman/listinfo/python-list


Re: The state of pySerial

2013-05-29 Thread MRAB

On 29/05/2013 22:38, Terry Jan Reedy wrote:

On 5/29/2013 4:00 PM, William Ray Wing wrote:

On May 29, 2013, at 2:23 PM, Ma Xiaojun damage3...@gmail.com wrote:


Hi, all.

pySerial is probably the solution for serial port programming.
Physical serial port is dead on PC but USB-to-Serial give it a second
life. Serial port stuff won't interest end users at all. But it is
still used in the EE world and so on. Arduino uses it to upload
programs. Sensors may use serial port to communicate with PC. GSM
Modem also uses serial port to communicate with PC.

Unforunately, pySerial project doesn't seem to have a good state. I
find pySerial + Python 3.3 broken on my machine (Python 2.7 is OK) .
There are unanswered outstanding bugs, PyPI page has 2.6 while SF
homepage still gives 2.5.

Any idea?
--
http://mail.python.org/mailman/listinfo/python-list


Let me add another vote/request for pySerial support.  I've been using it with 
python 2.7 on OS-X, unaware that there wasn't a path forward to python 3.x.  If 
an external sensor absolutely positively has to be readable, then RS-232 is the 
only way to go.  USB interfaces can and do lock up if recovery from a power 
failure puts power on the external side before the computer has finished 
initializing the CPU side.  RS-232, bless its primitive heart, could care less.


Then 'someone' should ask the author his intentions and offer to help or
take over.


This page:

http://pyserial.sourceforge.net/pyserial.html#requirements

says:

Python 2.3 or newer, including Python 3.x


I did some RS-232 interfacing in the  1980s, and once past the fiddly
start/stop/parity bit, baud rate, and wiring issues, I had a program run
connected to multiple machines for years with no more interface problems.



--
http://mail.python.org/mailman/listinfo/python-list


Re: The state of pySerial

2013-05-29 Thread Ma Xiaojun
I've already mailed the author, waiting for reply.

For Windows people, downloading a exe get you pySerial 2.5, which
list_ports and miniterm feature seems not included. To use 2.6,
download the tar.gz and use standard setup.py install to install it
(assume you have .py associated) . There is no C compiling involved in
the installation process.

For whether Python 3.3 is supported or not. I observed something like:
http://paste.ubuntu.com/5715275/ .

miniterm works for Python 3.3 at this time.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The state of pySerial

2013-05-29 Thread Grant Edwards
On 2013-05-29, Terry Jan Reedy tjre...@udel.edu wrote:
 On 5/29/2013 3:47 PM, Grant Edwards wrote:
 On 2013-05-29, Ma Xiaojun damage3...@gmail.com wrote:
[...]
 Unforunately, pySerial project doesn't seem to have a good state. I
 find pySerial + Python 3.3 broken on my machine (Python 2.7 is OK) .
 There are unanswered outstanding bugs, PyPI page has 2.6 while SF
 homepage still gives 2.5.

 Any idea?

 Volunteer as a maintainer and start fixing bugs?

 It seems to be getting around 200 downloands a day. Quite worth
 someone supporting it.

Chris has a day job, just like the rest of us.  He might even have a
family and hobbies other than supporting pyserial. ;)

Everybody should feel free to submit patches for open bugs and to test
any patches waiting to be accepted.

 I use pyserial regularly, and the current version works fine for me,
 but I'm using Python 2.7. There are still too many libraries that
 don't support 3.x for me to consider using 3.x for real work.

 The only download is a .exe. It it just the executable binary or is that 
 a zip unpacker with source?

http://pyserial.sourceforge.net/pyserial.html#from-source-tar-gz-or-checkout

https://pypi.python.org/packages/source/p/pyserial/pyserial-2.6.tar.gz#md5=cde799970b7c1ce1f7d6e9ceebe64c98

-- 
Grant

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to set 250000 baud rate in pyserial ?

2012-10-26 Thread kurabas
Error is like cannot set special baud rate.
But as I said pyserial set this speed without problem  for ttyUSB0
So it seems pyserial uses diefferent code depending of port type.
I tried to simlink ln -s ttyACM0 ttyUSB0 but it does not work


On Thursday, October 25, 2012 9:11:23 PM UTC+3, Dennis Lee Bieber wrote:
 On Thu, 25 Oct 2012 04:09:56 -0700 (PDT), kura...@gmail.com declaimed
 
 the following in gmane.comp.python.general:
 
 
 
  I use Arduino 1280 and Arduino 2560 under Fedora 15. 
 
  1280 creates ttyUSB0 port  and can be set at 250 successfully.
 
  2560 creates ttyACM0 port and can be only set at speeds from list (no 
  25) in pyserial. How to set 25 to ttyACM0 port?? Need I patch 
  kernel or python?
 
 
 
   You don't say what error you are receiving but looking at the source
 
 (serialposix.py) implies that it accepts nearly anything on Linux, and
 
 relies on the OS returning a success/failure if the value is allowed or
 
 not. 
 
 
 
   xxxBSD, SunOS, HPUX, IRIX, and CYGWIN systems don't allow special
 
 baudrates at all.
 
 
 
   .NET, JVM, and Windows don't seem to have explicit call outs for bad
 
 rates -- just a generic port configured OK test.
 
 -- 
 
   Wulfraed Dennis Lee Bieber AF6VN
 
 wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to set 250000 baud rate in pyserial ?

2012-10-26 Thread Michael Torrie
On 10/26/2012 04:01 PM, kura...@gmail.com wrote:
 Error is like cannot set special baud rate. But as I said pyserial
 set this speed without problem  for ttyUSB0 So it seems pyserial uses
 diefferent code depending of port type. I tried to simlink ln -s
 ttyACM0 ttyUSB0 but it does not work

No the difference in how baud rate is set is most likely in the driver.
 pyserial just uses standard kernel apis and ioctls to control the device.
-- 
http://mail.python.org/mailman/listinfo/python-list


How to set 250000 baud rate in pyserial ?

2012-10-25 Thread kurabas
I use Arduino 1280 and Arduino 2560 under Fedora 15. 
1280 creates ttyUSB0 port  and can be set at 250 successfully.
2560 creates ttyACM0 port and can be only set at speeds from list (no 25) 
in pyserial. How to set 25 to ttyACM0 port?? Need I patch kernel or python?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to set 250000 baud rate in pyserial ?

2012-10-25 Thread Grant Edwards
On 2012-10-25, Dennis Lee Bieber wlfr...@ix.netcom.com wrote:
 On Thu, 25 Oct 2012 04:09:56 -0700 (PDT), kura...@gmail.com wrote:

 I use Arduino 1280 and Arduino 2560 under Fedora 15.  1280 creates
 ttyUSB0 port and can be set at 250 successfully. 2560 creates
 ttyACM0 port and can be only set at speeds from list (no 25) in
 pyserial. How to set 25 to ttyACM0 port?? Need I patch kernel or
 python?

 You don't say what error you are receiving but looking at the source
 (serialposix.py) implies that it accepts nearly anything on Linux, and
 relies on the OS returning a success/failure if the value is allowed or
 not. 

1) Are you sure it matters?  I've never played with an Arduino board,
   but other stuff I've used that implements a virtual serial port
   using a ttyUSB or ttyACM device (e.g. oscilloscope, various Atmel
   eval boards, JTAG interfaces, etc.) didn't have actual UARTs in
   them with real baud rate generators.  You got the same high-speed
   transfers no matter what baud rate you told the tty driver.

2) If you want a non-standard baud rate, there is a termios2 API on
   Linux that allows that (assuming the low-level driver and hardwdare
   support it).  The last time I looked, it wasn't supported by
   pyserial, but you can ask pyserial for the underlying file
   descriptor and do the ioctl manually.  The slightly ugly bit is
   that you'll have to use struct (or maybe ctypes) to handle the
   termios2 C structure.

   The behavior of baud rate requests that can't be met exactly is
   probably not very consistent.  IIRC, the recommended approach is
   for the low level driver to pick the closest supported baud, and
   then report the actual baud rate back when you subsequently read
   the termios2 structure. However, I do know of some devices that
   will always report the requested baud rate even if the physical
   baud rate that was selected wasn't exactly the same as the request
   rate.

Here's how you set an arbitrary baud rate in C:
   
-arbitrary-baud.c--
#include stdlib.h
#include stdio.h
#include fcntl.h
#include errno.h
#include string.h
#include linux/termios.h

int ioctl(int d, int request, ...);

int main(int argc, char *argv[])
{
  struct termios2 t;
  int fd,baud;

  if (argc != 3)
{
  fprintf(stderr,usage: %s device baud\n, argv[0]);
  return 1;
}

  fd = open(argv[1], O_RDWR | O_NOCTTY | O_NDELAY);

  if (fd == -1)
  {
fprintf(stderr, error opening %s: %s, argv[1], strerror(errno));
return 2;
  }

  baud = atoi(argv[2]);

  if (ioctl(fd, TCGETS2, t))
{
  perror(TCGETS2);
  return 3;
}

  t.c_cflag = ~CBAUD;
  t.c_cflag |= BOTHER;
  t.c_ispeed = baud;
  t.c_ospeed = baud;

  if (ioctl(fd, TCSETS2, t))
{
  perror(TCSETS2);
  return 4;
}

  if (ioctl(fd, TCGETS2, t))
{
  perror(TCGETS2);
  return 5;
}

  printf(actual speed reported %d\n, t.c_ospeed);
  return 0;
}



-- 
Grant Edwards   grant.b.edwards
  at   
  gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PySerial could not open port COM4: [Error 5] Access is denied - please help

2012-06-28 Thread Grant Edwards
On 2012-06-28, Adam adam@no_thanks.com wrote:

 Obviously pySerial considers the serial port open

Because it's already been opened by the Python program.

 and will not open an already open serial port.

Pyserial will happily try if you call the open() of a port that's
already open, but Windows will return an error.

 However, why is it that TeraTerm can open the serial port?

Because TeraTerm only opens it once.

 Here's the link where I read about calling ser.close() before
 ser.open() ...

 Trying to open a serial port with pyserial on WinXP - Access denied

 http://stackoverflow.com/questions/2063257/trying-to-open-a-serial-port-with-pyserial-on-winxp-access-denied

That code is broken.

The port is opened by this line:

 self.ser=serial.Serial(port='\\.\COM1', baudrate=9600, 
bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, 
stopbits=serial.STOPBITS_ONE, timeout=1)

And then the author tries to _open_it_a_second_time_ here:

 self.ser.open()

 Here's the Python scripts ...
 https://github.com/adafruit/Tweet-a-Watt/downloads
 Click on the Download as ... button for the Python scripts

Like I kept telling you, those programs are trying to re-open a port
that they've already open.  Here's the erroneous code:

wattcher.py:

53  
54  # open up the FTDI serial port to get data transmitted to xbee
55  ser = serial.Serial(SERIALPORT, BAUDRATE)
56  ser.open()
57  

Line 55 opens the serial port.

Line 56 tries to _open_it_again_.  _The_port_is_already_open_. 
Windows doesn't allow a serial port to be opened twice, therefore the
ser.open() call raises an exception.

Just delete line 56.


The same thing happens here:

gmeter-wattcher.py

83  
84  # open up the FTDI serial port to get data transmitted to xbee
85  ser = serial.Serial(SERIALPORT, BAUDRATE)
86  ser.open()
87  

Just delete line 86.

See how simple it was to get the problem solved once you posted the
actual code?

-- 
Grant Edwards   grant.b.edwardsYow! HUMAN REPLICAS are
  at   inserted into VATS of
  gmail.comNUTRITIONAL YEAST ...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PySerial could not open port COM4: [Error 5] Access is denied - please help

2012-06-28 Thread Roel Schroeven

Temia Eszteri schreef:

Actually, I believe someone in an earlier thread in the newsgroup or
elsewhere pointed out that serial ports automatically open under
Windows. I'd have to look it back up when I have the time, which I
don't have at the moment, unfortunately.


That doesn't have anything to do with Windows, but with how pySerial 
works. See the documentation for __init__():


The port is immediately opened on object creation, when a port is 
given. It is not opened when port is None and a successive call to 
open() will be needed.


So if your script does something like

prt = serial.Serial('COM4')

then pySerial automatically opens the port, and you shouldn't call 
prt.open() anymore.


If, on the contrary, you do something like

prt = serial.Serial()
prt.port = 'COM4'

then pySerial doesn't open the port, and you have to call prt.open() to 
do it.


PySerial has this same behavior on both Windows and Linux. The 
difference might be that on Linux it is possible to open serial ports 
more than once, while that doesn't work on Windows.


Best regards,
Roel

--
http://mail.python.org/mailman/listinfo/python-list


Re: PySerial could not open port COM4: [Error 5] Access is denied - please help

2012-06-28 Thread Adam

Grant Edwards invalid@invalid.invalid wrote in message 
news:jshotj$s55$1...@reader1.panix.com...
 On 2012-06-28, Adam adam@no_thanks.com wrote:

 Obviously pySerial considers the serial port open

 Because it's already been opened by the Python program.

 and will not open an already open serial port.

 Pyserial will happily try if you call the open() of a port that's
 already open, but Windows will return an error.

 However, why is it that TeraTerm can open the serial port?

 Because TeraTerm only opens it once.

 Here's the link where I read about calling ser.close() before
 ser.open() ...

 Trying to open a serial port with pyserial on WinXP - Access denied

 http://stackoverflow.com/questions/2063257/trying-to-open-a-serial-port-with-pyserial-on-winxp-access-denied

 That code is broken.

 The port is opened by this line:

 self.ser=serial.Serial(port='\\.\COM1', baudrate=9600, 
 bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, 
 stopbits=serial.STOPBITS_ONE, timeout=1)

 And then the author tries to _open_it_a_second_time_ here:

 self.ser.open()

 Here's the Python scripts ...
 https://github.com/adafruit/Tweet-a-Watt/downloads
 Click on the Download as ... button for the Python scripts

 Like I kept telling you, those programs are trying to re-open a port
 that they've already open.  Here's the erroneous code:

 wattcher.py:

53
54  # open up the FTDI serial port to get data transmitted to xbee
55  ser = serial.Serial(SERIALPORT, BAUDRATE)
56  ser.open()
57

 Line 55 opens the serial port.

 Line 56 tries to _open_it_again_.  _The_port_is_already_open_.
 Windows doesn't allow a serial port to be opened twice, therefore the
 ser.open() call raises an exception.

 Just delete line 56.


 The same thing happens here:

 gmeter-wattcher.py

83
84  # open up the FTDI serial port to get data transmitted to xbee
85  ser = serial.Serial(SERIALPORT, BAUDRATE)
86  ser.open()
87

 Just delete line 86.

 See how simple it was to get the problem solved once you posted the
 actual code?

 -- 
 Grant Edwards   grant.b.edwardsYow! HUMAN REPLICAS are
  at   inserted into VATS of
  gmail.comNUTRITIONAL YEAST ...


Thanks, Grant !


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PySerial could not open port COM4: [Error 5] Access is denied- please help

2012-06-28 Thread Adam

Roel Schroeven r...@roelschroeven.net wrote in message 
news:mailman.1618.1340910525.4697.python-l...@python.org...
 Temia Eszteri schreef:
 Actually, I believe someone in an earlier thread in the newsgroup or
 elsewhere pointed out that serial ports automatically open under
 Windows. I'd have to look it back up when I have the time, which I
 don't have at the moment, unfortunately.

 That doesn't have anything to do with Windows, but with how pySerial 
 works. See the documentation for __init__():

 The port is immediately opened on object creation, when a port is given. 
 It is not opened when port is None and a successive call to open() will be 
 needed.

 So if your script does something like

 prt = serial.Serial('COM4')

 then pySerial automatically opens the port, and you shouldn't call 
 prt.open() anymore.

 If, on the contrary, you do something like

 prt = serial.Serial()
 prt.port = 'COM4'

 then pySerial doesn't open the port, and you have to call prt.open() to do 
 it.

 PySerial has this same behavior on both Windows and Linux. The difference 
 might be that on Linux it is possible to open serial ports more than once, 
 while that doesn't work on Windows.

 Best regards,
 Roel



Thanks for the info.  Your explanation helps a lot.



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PySerial could not open port COM4: [Error 5] Access is denied - please help

2012-06-27 Thread Adam

John Nagle na...@animats.com wrote in message 
news:jse604$1cq$1...@dont-email.me...
 On 6/26/2012 9:12 PM, Adam wrote:
 Host OS:Ubuntu 10.04 LTS
 Guest OS:Windows XP Pro SP3


 I am able to open port COM4 with Terminal emulator.

 So, what can cause PySerial to generate the following error ...

 C:\Wattcherpython wattcher.py
 Traceback (most recent call last):
File wattcher.py, line 56, in module
  ser.open()
File C:\Python25\Lib\site-packages\serial\serialwin32.py, line 56, 
 in
 open
  raise SerialException(could not open port %s: %s % (self.portstr,
 ctypes.WinError()))
 serial.serialutil.SerialException: could not open port COM4: [Error 5]
 Access is denied.

 Are you trying to access serial ports from a virtual machine?
 Which virtual machine environment?  Xen?  VMware? QEmu?  VirtualBox?
 I wouldn't expect that to work in most of those.

 What is COM4, anyway?   Few machines today actually have four
 serial ports.  Is some device emulating a serial port?

 John Nagle


Thanks, and yes, I am using VirtualBox.  My laptop does not have a serial 
port so
I use a USB-to-serial converter, which is assigned COM4.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PySerial could not open port COM4: [Error 5] Access is denied - please help

2012-06-27 Thread Paul

Adam wrote:
John Nagle na...@animats.com wrote in message 
news:jse604$1cq$1...@dont-email.me...

On 6/26/2012 9:12 PM, Adam wrote:

Host OS:Ubuntu 10.04 LTS
Guest OS:Windows XP Pro SP3


I am able to open port COM4 with Terminal emulator.

So, what can cause PySerial to generate the following error ...

C:\Wattcherpython wattcher.py
Traceback (most recent call last):
   File wattcher.py, line 56, in module
 ser.open()
   File C:\Python25\Lib\site-packages\serial\serialwin32.py, line 56, 
in

open
 raise SerialException(could not open port %s: %s % (self.portstr,
ctypes.WinError()))
serial.serialutil.SerialException: could not open port COM4: [Error 5]
Access is denied.

Are you trying to access serial ports from a virtual machine?
Which virtual machine environment?  Xen?  VMware? QEmu?  VirtualBox?
I wouldn't expect that to work in most of those.

What is COM4, anyway?   Few machines today actually have four
serial ports.  Is some device emulating a serial port?

John Nagle



Thanks, and yes, I am using VirtualBox.  My laptop does not have a serial 
port so

I use a USB-to-serial converter, which is assigned COM4.




Doesn't VirtualBox allow remapping serial ports ? I thought you
could have COM 4 in the host OS, and make it COM 1 or COM 2 in
the guest. Something like that.

http://virtuatopia.com/images/6/60/Virtualbox_serial_port_settings.jpg

Also, Windows (as a host), is notorious for stealing control of
COM ports. Even Windows software, when you run it, would report
COM 4 is busy. Then, you have to track down *why* it's busy.
Is it that FAX software you installed ? The GPS software
that talks to your GPS serial interface ?

In theory, the Handle program is supposed to identify what
is keeping a COM port busy, but I don't get the desired
results from it very often. You need to know the naming
convention for virtual COM ports (COM4 via USB to serial, is
more virtual than physical). That's what makes it harder
to track down.

These are some names for COM ports, in Windows. The last two entries,
are my USB to serial adapters. VCP1 functions as COM3.
VCP0 functions as COM4. The VCP part is what would be
listed in Handle from Sysinternals. The \device\serial
format, is more likely to be used with true native
motherboard serial ports.

   \device\serial

   ups.exe pid: 1072 NT AUTHORITY\SYSTEM
  98: File  (---)   \Device\VCP0
   hypertrm.exe pid: 3404 ComputerName\UserID (claims to use COM3)
  E0: File  (---)   \Device\VCP1

You can download Handle and play with it here.

http://technet.microsoft.com/en-us/sysinternals/bb896655

Note that, in my Handle results, at the time I was running
the Windows provided ups.exe to talk to my external UPS
(uninterruptible power supply). So that's what that
reference is. The hypertrm one, is me using the
built-in Windows terminal software, to talk to COM3,
to keep the port artificially busy for the purposes
of testing.

If things were working well in your case, you *might*
see something of this form. If not, you'd instead
see the name of the process that has stolen the
com port.

   virtualbox.exe pid: 1234 ComputerName\UserID
  E0: File  (---)  \Device\VCP0

HTH,
   Paul
--
http://mail.python.org/mailman/listinfo/python-list


Re: PySerial could not open port COM4: [Error 5] Access is denied - please help

2012-06-27 Thread David H. Lipman

From: Adam adam@no_thanks.com



John Nagle na...@animats.com wrote in message 
news:jse604$1cq$1...@dont-email.me...

On 6/26/2012 9:12 PM, Adam wrote:

Host OS:Ubuntu 10.04 LTS
Guest OS:Windows XP Pro SP3

I am able to open port COM4 with Terminal emulator.

So, what can cause PySerial to generate the following error ...

C:\Wattcherpython wattcher.py
Traceback (most recent call last):
   File wattcher.py, line 56, in module
 ser.open()
   File C:\Python25\Lib\site-packages\serial\serialwin32.py, line 56, 
in

open
 raise SerialException(could not open port %s: %s % (self.portstr,
ctypes.WinError()))
serial.serialutil.SerialException: could not open port COM4: [Error 5]
Access is denied.


Are you trying to access serial ports from a virtual machine?
Which virtual machine environment?  Xen?  VMware? QEmu?  VirtualBox?
I wouldn't expect that to work in most of those.

What is COM4, anyway?   Few machines today actually have four
serial ports.  Is some device emulating a serial port?

John Nagle

Thanks, and yes, I am using VirtualBox.  My laptop does not have a serial 
port so

I use a USB-to-serial converter, which is assigned COM4.



Then it is a Virtual COM port.  Often software will want to communicate 
directly to the COM4 port which is usually at: IRQ3 and I/O 2E8h.


--
Dave
Multi-AV Scanning Tool - http://multi-av.thespykiller.co.uk
http://www.pctipp.ch/downloads/dl/35905.asp 


--
http://mail.python.org/mailman/listinfo/python-list


Re: PySerial could not open port COM4: [Error 5] Access is denied - please help

2012-06-27 Thread Grant Edwards
On 2012-06-27, David H. Lipman DLipman~nospam~@Verizon.Net wrote:
 From: Adam adam@no_thanks.com
 John Nagle na...@animats.com wrote in message 
 news:jse604$1cq$1...@dont-email.me...
 On 6/26/2012 9:12 PM, Adam wrote:
 Host OS:Ubuntu 10.04 LTS
 Guest OS:Windows XP Pro SP3

 I am able to open port COM4 with Terminal emulator.

 So, what can cause PySerial to generate the following error ...

 C:\Wattcherpython wattcher.py
 Traceback (most recent call last):
File wattcher.py, line 56, in module
  ser.open()
File C:\Python25\Lib\site-packages\serial\serialwin32.py, line 56, in 
 open
  raise SerialException(could not open port %s: %s % (self.portstr,
 ctypes.WinError()))
 serial.serialutil.SerialException: could not open port COM4: [Error 5]
 Access is denied.

 Are you trying to access serial ports from a virtual machine? Which
 virtual machine environment?  Xen?  VMware? QEmu?  VirtualBox? I
 wouldn't expect that to work in most of those.

Except he says it _does_ work with his terminal emulator.

 What is COM4, anyway?   Few machines today actually have four
 serial ports.  Is some device emulating a serial port?

It shouldn't matter.  If other apps can open COM4, then pyserial
should be able to open COM4.

 Thanks, and yes, I am using VirtualBox.  My laptop does not have a
 serial port so I use a USB-to-serial converter, which is assigned
 COM4.

 Then it is a Virtual COM port. Often software will want to
 communicate directly to the COM4 port which is usually at: IRQ3 and
 I/O 2E8h.

Pyserial doesn't do that.  It uses the standard win32 serial API, and
it should work just fine with any Win32 serial device (what you call a
virtual COM port).

-- 
Grant Edwards   grant.b.edwardsYow! World War III?
  at   No thanks!
  gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PySerial could not open port COM4: [Error 5] Access is denied - please help

2012-06-27 Thread Adam

Paul nos...@needed.com wrote in message 
news:jseu9c$sp3$1...@dont-email.me...
 Adam wrote:
 John Nagle na...@animats.com wrote in message 
 news:jse604$1cq$1...@dont-email.me...
 On 6/26/2012 9:12 PM, Adam wrote:
 Host OS:Ubuntu 10.04 LTS
 Guest OS:Windows XP Pro SP3


 I am able to open port COM4 with Terminal emulator.

 So, what can cause PySerial to generate the following error ...

 C:\Wattcherpython wattcher.py
 Traceback (most recent call last):
File wattcher.py, line 56, in module
  ser.open()
File C:\Python25\Lib\site-packages\serial\serialwin32.py, line 56, 
 in
 open
  raise SerialException(could not open port %s: %s % 
 (self.portstr,
 ctypes.WinError()))
 serial.serialutil.SerialException: could not open port COM4: [Error 5]
 Access is denied.
 Are you trying to access serial ports from a virtual machine?
 Which virtual machine environment?  Xen?  VMware? QEmu?  VirtualBox?
 I wouldn't expect that to work in most of those.

 What is COM4, anyway?   Few machines today actually have four
 serial ports.  Is some device emulating a serial port?

 John Nagle


 Thanks, and yes, I am using VirtualBox.  My laptop does not have a serial 
 port so
 I use a USB-to-serial converter, which is assigned COM4.


 Doesn't VirtualBox allow remapping serial ports ? I thought you
 could have COM 4 in the host OS, and make it COM 1 or COM 2 in
 the guest. Something like that.

 http://virtuatopia.com/images/6/60/Virtualbox_serial_port_settings.jpg

 Also, Windows (as a host), is notorious for stealing control of
 COM ports. Even Windows software, when you run it, would report
 COM 4 is busy. Then, you have to track down *why* it's busy.
 Is it that FAX software you installed ? The GPS software
 that talks to your GPS serial interface ?

 In theory, the Handle program is supposed to identify what
 is keeping a COM port busy, but I don't get the desired
 results from it very often. You need to know the naming
 convention for virtual COM ports (COM4 via USB to serial, is
 more virtual than physical). That's what makes it harder
 to track down.

 These are some names for COM ports, in Windows. The last two entries,
 are my USB to serial adapters. VCP1 functions as COM3.
 VCP0 functions as COM4. The VCP part is what would be
 listed in Handle from Sysinternals. The \device\serial
 format, is more likely to be used with true native
 motherboard serial ports.

\device\serial

ups.exe pid: 1072 NT AUTHORITY\SYSTEM
   98: File  (---)   \Device\VCP0
hypertrm.exe pid: 3404 ComputerName\UserID (claims to use COM3)
   E0: File  (---)   \Device\VCP1

 You can download Handle and play with it here.

 http://technet.microsoft.com/en-us/sysinternals/bb896655

 Note that, in my Handle results, at the time I was running
 the Windows provided ups.exe to talk to my external UPS
 (uninterruptible power supply). So that's what that
 reference is. The hypertrm one, is me using the
 built-in Windows terminal software, to talk to COM3,
 to keep the port artificially busy for the purposes
 of testing.

 If things were working well in your case, you *might*
 see something of this form. If not, you'd instead
 see the name of the process that has stolen the
 com port.

virtualbox.exe pid: 1234 ComputerName\UserID
   E0: File  (---)  \Device\VCP0

 HTH,
Paul


Thanks (Guru Paul), I've been using the USB-to-serial converter successfully 
without
enabling/remapping via VBox Settings=Serial Ports (which are both not 
enabled).
I can see the serial port COM4 under Device Manager though.  So, maybe 
enabling is
necessary when the host has native serial ports, which my laptop does not 
have.

From the output generated by Handle.exe, here's the section for TeraTerm ...
--
ttermpro.exe pid: 596 VBOX_WINXPPRO\adam(claims to use COM4)
C: File  (RW-)   D:\downloads\Tera Term Pro\ttpro313
   2C: Section   \BaseNamedObjects\ttset_memfilemap
   44: File  (RW-) 
C:\WINDOWS.0\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.6028_x-ww_61e65202
   54: File  (RW-) 
C:\WINDOWS.0\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.6195_x-ww_44262b86
   70: Section 
\BaseNamedObjects\_ISWINTERNAL_EPT32_SHEX_K32_0_1c9aa25ea688500_7c80_S-1-5-21-1801674531-1078145449-1957994488-1004
   78: File  (RWD)   C:\DOCUME~1\adam\LOCALS~1\Temp\IswTmp\Logs\ISWSHEX.swl
   AC: Section 
\BaseNamedObjects\_ISWINTERNAL_EPT32_SHEX_A32_0_1c98aa70f70ec00_77dd_S-1-5-21-1801674531-1078145449-1957994488-1004
  100: Section 
\BaseNamedObjects\CiceroSharedMemDefaultS-1-5-21-1801674531-1078145449-1957994488-1004
  108: File  (RW-)   D:\downloads\Tera Term Pro\ttpro313\httplog.log
  120: Section 
\BaseNamedObjects\CTF.TimListCache.FMPDefaultS-1-5-21-1801674531-1078145449-1957994488-1004SFM.DefaultS-1-5-21-1801674531-1078145449-1957994488-1004
  128: Section   \BaseNamedObjects\ShimSharedMemory
  138

Re: PySerial could not open port COM4: [Error 5] Access is denied - please help

2012-06-27 Thread Paul

Adam wrote:
Paul nos...@needed.com wrote in message 
news:jseu9c$sp3$1...@dont-email.me...

Adam wrote:
John Nagle na...@animats.com wrote in message 
news:jse604$1cq$1...@dont-email.me...

On 6/26/2012 9:12 PM, Adam wrote:

Host OS:Ubuntu 10.04 LTS
Guest OS:Windows XP Pro SP3


I am able to open port COM4 with Terminal emulator.

So, what can cause PySerial to generate the following error ...

C:\Wattcherpython wattcher.py
Traceback (most recent call last):
   File wattcher.py, line 56, in module
 ser.open()
   File C:\Python25\Lib\site-packages\serial\serialwin32.py, line 56, 
in

open
 raise SerialException(could not open port %s: %s % 
(self.portstr,

ctypes.WinError()))
serial.serialutil.SerialException: could not open port COM4: [Error 5]
Access is denied.

Are you trying to access serial ports from a virtual machine?
Which virtual machine environment?  Xen?  VMware? QEmu?  VirtualBox?
I wouldn't expect that to work in most of those.

What is COM4, anyway?   Few machines today actually have four
serial ports.  Is some device emulating a serial port?

John Nagle

Thanks, and yes, I am using VirtualBox.  My laptop does not have a serial 
port so

I use a USB-to-serial converter, which is assigned COM4.


Doesn't VirtualBox allow remapping serial ports ? I thought you
could have COM 4 in the host OS, and make it COM 1 or COM 2 in
the guest. Something like that.

http://virtuatopia.com/images/6/60/Virtualbox_serial_port_settings.jpg

Also, Windows (as a host), is notorious for stealing control of
COM ports. Even Windows software, when you run it, would report
COM 4 is busy. Then, you have to track down *why* it's busy.
Is it that FAX software you installed ? The GPS software
that talks to your GPS serial interface ?

In theory, the Handle program is supposed to identify what
is keeping a COM port busy, but I don't get the desired
results from it very often. You need to know the naming
convention for virtual COM ports (COM4 via USB to serial, is
more virtual than physical). That's what makes it harder
to track down.

These are some names for COM ports, in Windows. The last two entries,
are my USB to serial adapters. VCP1 functions as COM3.
VCP0 functions as COM4. The VCP part is what would be
listed in Handle from Sysinternals. The \device\serial
format, is more likely to be used with true native
motherboard serial ports.

   \device\serial

   ups.exe pid: 1072 NT AUTHORITY\SYSTEM
  98: File  (---)   \Device\VCP0
   hypertrm.exe pid: 3404 ComputerName\UserID (claims to use COM3)
  E0: File  (---)   \Device\VCP1

You can download Handle and play with it here.

http://technet.microsoft.com/en-us/sysinternals/bb896655

Note that, in my Handle results, at the time I was running
the Windows provided ups.exe to talk to my external UPS
(uninterruptible power supply). So that's what that
reference is. The hypertrm one, is me using the
built-in Windows terminal software, to talk to COM3,
to keep the port artificially busy for the purposes
of testing.

If things were working well in your case, you *might*
see something of this form. If not, you'd instead
see the name of the process that has stolen the
com port.

   virtualbox.exe pid: 1234 ComputerName\UserID
  E0: File  (---)  \Device\VCP0

HTH,
   Paul



Thanks (Guru Paul), I've been using the USB-to-serial converter successfully 
without
enabling/remapping via VBox Settings=Serial Ports (which are both not 
enabled).
I can see the serial port COM4 under Device Manager though.  So, maybe 
enabling is
necessary when the host has native serial ports, which my laptop does not 
have.


From the output generated by Handle.exe, here's the section for TeraTerm ...
--
ttermpro.exe pid: 596 VBOX_WINXPPRO\adam(claims to use COM4)
C: File  (RW-)   D:\downloads\Tera Term Pro\ttpro313
   2C: Section   \BaseNamedObjects\ttset_memfilemap
   44: File  (RW-) 
C:\WINDOWS.0\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.6028_x-ww_61e65202
   54: File  (RW-) 
C:\WINDOWS.0\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.6195_x-ww_44262b86
   70: Section 
\BaseNamedObjects\_ISWINTERNAL_EPT32_SHEX_K32_0_1c9aa25ea688500_7c80_S-1-5-21-1801674531-1078145449-1957994488-1004

   78: File  (RWD)   C:\DOCUME~1\adam\LOCALS~1\Temp\IswTmp\Logs\ISWSHEX.swl
   AC: Section 
\BaseNamedObjects\_ISWINTERNAL_EPT32_SHEX_A32_0_1c98aa70f70ec00_77dd_S-1-5-21-1801674531-1078145449-1957994488-1004
  100: Section 
\BaseNamedObjects\CiceroSharedMemDefaultS-1-5-21-1801674531-1078145449-1957994488-1004

  108: File  (RW-)   D:\downloads\Tera Term Pro\ttpro313\httplog.log
  120: Section 
\BaseNamedObjects\CTF.TimListCache.FMPDefaultS-1-5-21-1801674531-1078145449-1957994488-1004SFM.DefaultS-1-5-21-1801674531-1078145449-1957994488-1004

  128: Section   \BaseNamedObjects\ShimSharedMemory
  138: Section   \BaseNamedObjects

Re: PySerial could not open port COM4: [Error 5] Access is denied - please help

2012-06-27 Thread Adam

Paul nos...@needed.com wrote in message 
news:jsfatv$djt$1...@dont-email.me...
 Adam wrote:
 Paul nos...@needed.com wrote in message 
 news:jseu9c$sp3$1...@dont-email.me...
 Adam wrote:
 John Nagle na...@animats.com wrote in message 
 news:jse604$1cq$1...@dont-email.me...
 On 6/26/2012 9:12 PM, Adam wrote:
 Host OS:Ubuntu 10.04 LTS
 Guest OS:Windows XP Pro SP3


 I am able to open port COM4 with Terminal emulator.

 So, what can cause PySerial to generate the following error ...

 C:\Wattcherpython wattcher.py
 Traceback (most recent call last):
File wattcher.py, line 56, in module
  ser.open()
File C:\Python25\Lib\site-packages\serial\serialwin32.py, line 
 56, in
 open
  raise SerialException(could not open port %s: %s % 
 (self.portstr,
 ctypes.WinError()))
 serial.serialutil.SerialException: could not open port COM4: [Error 
 5]
 Access is denied.
 Are you trying to access serial ports from a virtual machine?
 Which virtual machine environment?  Xen?  VMware? QEmu?  VirtualBox?
 I wouldn't expect that to work in most of those.

 What is COM4, anyway?   Few machines today actually have four
 serial ports.  Is some device emulating a serial port?

 John Nagle

 Thanks, and yes, I am using VirtualBox.  My laptop does not have a 
 serial port so
 I use a USB-to-serial converter, which is assigned COM4.

 Doesn't VirtualBox allow remapping serial ports ? I thought you
 could have COM 4 in the host OS, and make it COM 1 or COM 2 in
 the guest. Something like that.

 http://virtuatopia.com/images/6/60/Virtualbox_serial_port_settings.jpg

 Also, Windows (as a host), is notorious for stealing control of
 COM ports. Even Windows software, when you run it, would report
 COM 4 is busy. Then, you have to track down *why* it's busy.
 Is it that FAX software you installed ? The GPS software
 that talks to your GPS serial interface ?

 In theory, the Handle program is supposed to identify what
 is keeping a COM port busy, but I don't get the desired
 results from it very often. You need to know the naming
 convention for virtual COM ports (COM4 via USB to serial, is
 more virtual than physical). That's what makes it harder
 to track down.

 These are some names for COM ports, in Windows. The last two entries,
 are my USB to serial adapters. VCP1 functions as COM3.
 VCP0 functions as COM4. The VCP part is what would be
 listed in Handle from Sysinternals. The \device\serial
 format, is more likely to be used with true native
 motherboard serial ports.

\device\serial

ups.exe pid: 1072 NT AUTHORITY\SYSTEM
   98: File  (---)   \Device\VCP0
hypertrm.exe pid: 3404 ComputerName\UserID (claims to use COM3)
   E0: File  (---)   \Device\VCP1

 You can download Handle and play with it here.

 http://technet.microsoft.com/en-us/sysinternals/bb896655

 Note that, in my Handle results, at the time I was running
 the Windows provided ups.exe to talk to my external UPS
 (uninterruptible power supply). So that's what that
 reference is. The hypertrm one, is me using the
 built-in Windows terminal software, to talk to COM3,
 to keep the port artificially busy for the purposes
 of testing.

 If things were working well in your case, you *might*
 see something of this form. If not, you'd instead
 see the name of the process that has stolen the
 com port.

virtualbox.exe pid: 1234 ComputerName\UserID
   E0: File  (---)  \Device\VCP0

 HTH,
Paul


 Thanks (Guru Paul), I've been using the USB-to-serial converter 
 successfully without
 enabling/remapping via VBox Settings=Serial Ports (which are both not 
 enabled).
 I can see the serial port COM4 under Device Manager though.  So, maybe 
 enabling is
 necessary when the host has native serial ports, which my laptop does 
 not have.

 From the output generated by Handle.exe, here's the section for TeraTerm 
 ...
 --
 ttermpro.exe pid: 596 VBOX_WINXPPRO\adam(claims to use COM4)
 C: File  (RW-)   D:\downloads\Tera Term Pro\ttpro313
2C: Section   \BaseNamedObjects\ttset_memfilemap
44: File  (RW-) 
 C:\WINDOWS.0\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.6028_x-ww_61e65202
54: File  (RW-) 
 C:\WINDOWS.0\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.6195_x-ww_44262b86
70: Section 
 \BaseNamedObjects\_ISWINTERNAL_EPT32_SHEX_K32_0_1c9aa25ea688500_7c80_S-1-5-21-1801674531-1078145449-1957994488-1004
78: File  (RWD) 
 C:\DOCUME~1\adam\LOCALS~1\Temp\IswTmp\Logs\ISWSHEX.swl
AC: Section 
 \BaseNamedObjects\_ISWINTERNAL_EPT32_SHEX_A32_0_1c98aa70f70ec00_77dd_S-1-5-21-1801674531-1078145449-1957994488-1004
   100: Section 
 \BaseNamedObjects\CiceroSharedMemDefaultS-1-5-21-1801674531-1078145449-1957994488-1004
   108: File  (RW-)   D:\downloads\Tera Term Pro\ttpro313\httplog.log
   120: Section 
 \BaseNamedObjects\CTF.TimListCache.FMPDefaultS-1-5-21-1801674531-1078145449-1957994488

Re: PySerial could not open port COM4: [Error 5] Access is denied - please help

2012-06-27 Thread Paul

Adam wrote:




This is a tough one.


Try

   handle -a  allhand.txt

Then open the allhand.txt with Notepad and look for interesting entries.

***

I tested right now, and first opened a session in HyperTerminal with one
of my USB to serial adapters. The second serial adapter, is connect to a
UPS, looking for a shutdown message. So the second entry should be present
at all times.

hypertrm.exe pid: 3452
...
  120: File  (---)   \Device\VCP1


ups.exe pid: 1568 NT AUTHORITY\SYSTEM
...
   98: File  (---)   \Device\VCP0

I don't have any serial entries on this machine. But one of
my other machines, has a real COM port on the SuperI/O chip,
so the entries for that would involve the word serial in some
way. The USB ones, at least the ones I've got, say VCP. Possibly
because one of the driver files sets up virtual COM ports. There
is a control panel for the driver, that maps a virtual COM port,
to a COM port number, like COM3 and COM4 in this case.

  Paul
--
http://mail.python.org/mailman/listinfo/python-list


Re: PySerial could not open port COM4: [Error 5] Access is denied - please help

2012-06-27 Thread Adam

Paul nos...@needed.com wrote in message 
news:jsfhv2$ta9$1...@dont-email.me...
 Adam wrote:


 This is a tough one.

 Try

handle -a  allhand.txt

 Then open the allhand.txt with Notepad and look for interesting entries.

 ***

 I tested right now, and first opened a session in HyperTerminal with one
 of my USB to serial adapters. The second serial adapter, is connect to a
 UPS, looking for a shutdown message. So the second entry should be present
 at all times.

 hypertrm.exe pid: 3452
 ...
   120: File  (---)   \Device\VCP1


 ups.exe pid: 1568 NT AUTHORITY\SYSTEM
 ...
98: File  (---)   \Device\VCP0

 I don't have any serial entries on this machine. But one of
 my other machines, has a real COM port on the SuperI/O chip,
 so the entries for that would involve the word serial in some
 way. The USB ones, at least the ones I've got, say VCP. Possibly
 because one of the driver files sets up virtual COM ports. There
 is a control panel for the driver, that maps a virtual COM port,
 to a COM port number, like COM3 and COM4 in this case.

   Paul


Thanks (Guru Paul), you're the best.  I think we may have something this 
time ...

  144: File  (---)   \Device\ProlificSerial3

And, TeraTerm (using COM4) is open and receiving data wirelessly.

From the output generated by handle -a, here's the section for TeraTerm 
...
--
ttermpro.exe pid: 3648 VBOX_WINXPPRO\adam(claims to use COM4)
4: KeyedEvent\KernelObjects\CritSecOutOfMemoryEvent
8: Directory \KnownDlls
C: File  (RW-)   D:\downloads\Tera Term Pro\ttpro313
   10: Event
   14: Directory \Windows
   18: Port
   1C: WindowStation \Windows\WindowStations\WinSta0
   20: Desktop   \Default
   24: WindowStation \Windows\WindowStations\WinSta0
   28: Directory \BaseNamedObjects
   2C: Section   \BaseNamedObjects\ttset_memfilemap
   30: Semaphore
   34: Semaphore
   38: Key   HKLM
   3C: Event
   40: Semaphore 
\BaseNamedObjects\shell.{A48F1A32-A340-11D1-BC6B-00A0C90312E1}
   44: File  (RW-) 
C:\WINDOWS.0\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.6028_x-ww_61e65202
   48: File  (---)   \Device\KsecDD
   4C: Key   HKCU
   50: Key   HKCU\CLSID
   54: File  (RW-) 
C:\WINDOWS.0\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.6195_x-ww_44262b86
   58: Mutant
   5C: Event \BaseNamedObjects\crypt32LogoffEvent
   60: Event
   64: Mutant
   68: Event
   6C: Event
   70: Section 
\BaseNamedObjects\_ISWINTERNAL_EPT32_SHEX_K32_0_1c9aa25ea688500_7c80_S-1-5-21-1801674531-1078145449-1957994488-1004
   74: Event
   78: File  (RWD)   C:\DOCUME~1\adam\LOCALS~1\Temp\IswTmp\Logs\ISWSHEX.swl
   7C: Semaphore
   80: Semaphore
   84: Semaphore
   88: Semaphore
   8C: Semaphore
   90: Semaphore
   94: Semaphore
   98: Semaphore
   9C: Semaphore
   A0: Semaphore
   A4: Semaphore
   A8: Semaphore
   AC: Section 
\BaseNamedObjects\_ISWINTERNAL_EPT32_SHEX_A32_0_1c98aa70f70ec00_77dd_S-1-5-21-1801674531-1078145449-1957994488-1004
   B0: Port
   B4: Section
   B8: Key   HKCU
   BC: Mutant 
\BaseNamedObjects\CTF.LBES.MutexDefaultS-1-5-21-1801674531-1078145449-1957994488-1004
   C0: File  (---)   \Device\Tcp
   C4: File  (---)   \Device\Tcp
   C8: File  (---)   \Device\Ip
   CC: File  (---)   \Device\Ip
   D0: File  (---)   \Device\Ip
   D4: Semaphore
   D8: Semaphore
   DC: Key   HKLM\SYSTEM\ControlSet001\Services\Tcpip\Linkage
   E0: Key   HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters
   E4: Key 
HKLM\SYSTEM\ControlSet001\Services\NetBT\Parameters\Interfaces
   E8: Key   HKLM\SYSTEM\ControlSet001\Services\NetBT\Parameters
   EC: Threadttermpro.exe(3648): 3684
   F0: Event
   F4: Key 
HKLM\SYSTEM\ControlSet001\Services\WinSock2\Parameters\Protocol_Catalog9
   F8: Event
   FC: Key 
HKLM\SYSTEM\ControlSet001\Services\WinSock2\Parameters\NameSpace_Catalog5
  100: Section 
\BaseNamedObjects\CiceroSharedMemDefaultS-1-5-21-1801674531-1078145449-1957994488-1004
  104: Key   HKLM\SOFTWARE\Microsoft\SystemCertificates\My
  108: File  (RW-)   D:\downloads\Tera Term Pro\ttpro313\httplog.log
  10C: Mutant 
\BaseNamedObjects\CTF.Compart.MutexDefaultS-1-5-21-1801674531-1078145449-1957994488-1004
  110: Mutant 
\BaseNamedObjects\CTF.Asm.MutexDefaultS-1-5-21-1801674531-1078145449-1957994488-1004
  114: Mutant 
\BaseNamedObjects\CTF.Layouts.MutexDefaultS-1-5-21-1801674531-1078145449-1957994488-1004
  118: Mutant 
\BaseNamedObjects\CTF.TMD.MutexDefaultS-1-5-21-1801674531-1078145449-1957994488-1004
  11C: Mutant 
\BaseNamedObjects\CTF.TimListCache.FMPDefaultS-1-5-21-1801674531-1078145449-1957994488-1004MUTEX.DefaultS-1-5-21-1801674531-1078145449-1957994488-1004
  120: Section 
\BaseNamedObjects\CTF.TimListCache.FMPDefaultS-1-5-21-1801674531-1078145449-1957994488-1004SFM.DefaultS-1-5-21-1801674531-1078145449-1957994488-1004
  124: Mutant

Re: PySerial could not open port COM4: [Error 5] Access is denied - please help

2012-06-27 Thread Grant Edwards
On 2012-06-27, Adam adam@no_thanks.com wrote:

 The Python script needed a call to ser.close() before ser.open() in
 order to work.

IOW, the port opened OK, but when you tried to open it a second time
without closing it first, _that's_ when the .open() call failed.

That's a restriction built in to Win32.  You can't open a serial port
that's already open.  [Linux doesn't have that restriction.]

Why do you need to open it a second time?

-- 
Grant Edwards   grant.b.edwardsYow! Send your questions to
  at   ``ASK ZIPPY'', Box 40474,
  gmail.comSan Francisco, CA 94140,
   USA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PySerial could not open port COM4: [Error 5] Access is denied - please help

2012-06-27 Thread Adam

Grant Edwards invalid@invalid.invalid wrote in message 
news:jsftah$bb5$1...@reader1.panix.com...
 On 2012-06-27, Adam adam@no_thanks.com wrote:

 The Python script needed a call to ser.close() before ser.open() in
 order to work.

 IOW, the port opened OK, but when you tried to open it a second time
 without closing it first, _that's_ when the .open() call failed.

 That's a restriction built in to Win32.  You can't open a serial port
 that's already open.  [Linux doesn't have that restriction.]

 Why do you need to open it a second time?

 -- 
 Grant Edwards   grant.b.edwardsYow! Send your 
 questions to
  at   ``ASK ZIPPY'', Box 
 40474,
  gmail.comSan Francisco, CA 94140,
   USA


As far as I can tell, the wireless hardware connected to the USB-to-serial 
converter is
receiving data (which may have the serial port open?).  I can see the data 
being
received in TeraTerm (using COM4).  After closing TeraTerm,
I start up the Python script and get the following error message ...

C:\Wattcherpython wattcher.py
Traceback (most recent call last):
  File wattcher.py, line 56, in module
ser.open()
  File C:\Python25\Lib\site-packages\serial\serialwin32.py, line 56, in
open
raise SerialException(could not open port %s: %s % (self.portstr,
ctypes.WinError()))
serial.serialutil.SerialException: could not open port COM4: [Error 5]
Access is denied.


Searching for similar encounters of this error message,
some people said that calling ser.close() before ser.open()
solved the problem.  And, it worked for me as well.

Is this considered a chicken  egg situation?


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PySerial could not open port COM4: [Error 5] Access is denied - please help

2012-06-27 Thread Grant Edwards
On 2012-06-27, Adam adam@no_thanks.com wrote:
 Grant Edwards invalid@invalid.invalid wrote:
 On 2012-06-27, Adam adam@no_thanks.com wrote:

 The Python script needed a call to ser.close() before ser.open() in
 order to work.

 IOW, the port opened OK, but when you tried to open it a second time
 without closing it first, _that's_ when the .open() call failed.

 That's a restriction built in to Win32.  You can't open a serial port
 that's already open.  [Linux doesn't have that restriction.]

 Why do you need to open it a second time?

 As far as I can tell, the wireless hardware connected to the
 USB-to-serial converter is receiving data (which may have the serial
 port open?).  I can see the data being received in TeraTerm (using
 COM4).  After closing TeraTerm, I start up the Python script and get
 the following error message ...

 C:\Wattcherpython wattcher.py
 Traceback (most recent call last):
   File wattcher.py, line 56, in module
 ser.open()
   File C:\Python25\Lib\site-packages\serial\serialwin32.py, line 56, in
 open
 raise SerialException(could not open port %s: %s % (self.portstr,
 ctypes.WinError()))
 serial.serialutil.SerialException: could not open port COM4: [Error 5]
 Access is denied.


 Searching for similar encounters of this error message, some people
 said that calling ser.close() before ser.open() solved the problem.
 And, it worked for me as well.

 Is this considered a chicken  egg situation?

Can you post a small example showing what you're doing?

If you're getting that error (and calling ser.close() makes that error
go away), then it's because you're trying to re-open a port that you
already have open.

What happens if you just get rid of both the ser.close() and
ser.open() calls?  IOW, the port is apparently already open -- why do
you want to close() and then re-open() it?

-- 
Grant Edwards   grant.b.edwardsYow! I wonder if I should
  at   put myself in ESCROW!!
  gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PySerial could not open port COM4: [Error 5] Access is denied - please help

2012-06-27 Thread Grant Edwards
On 2012-06-27, Grant Edwards invalid@invalid.invalid wrote:
 On 2012-06-27, Adam adam@no_thanks.com wrote:
 Grant Edwards invalid@invalid.invalid wrote:

 Why do you need to open it a second time?

 As far as I can tell, the wireless hardware connected to the
 USB-to-serial converter is receiving data (which may have the serial
 port open?).  I can see the data being received in TeraTerm (using
 COM4).  After closing TeraTerm, I start up the Python script and get
 the following error message ...
[...]
 Searching for similar encounters of this error message, some people
 said that calling ser.close() before ser.open() solved the problem.
 And, it worked for me as well.

 Is this considered a chicken  egg situation?

 Can you post a small example showing what you're doing?

The best way to get help is to write as small a program as possible
that demonstrates the problem, and post it.  I'll help you get
started...

Does this program work?

import serial
ser = serial.Serial(COM4)
ser.close()

At the moment, I don't have access to a Windows machine, but I think
the above should run without any errors.  If it works, then you've
successfully opened and closed the COM4 port.  Start adding
features, in increments as small as possible, until the program
fails.

Then try to remove stuff that's not needed while still keeping the
failure.

IOW, try to find the smallest possible program that fails.

Usually, in the process of doing that, you'll figure out what you were
doing wrong.  If not, post the smallest failing program you can come
up with, and somebody will be able to help.

If you won't show us what you're doing, we can't tell you what you're
doing wrong.

-- 
Grant Edwards   grant.b.edwardsYow! Gee, I feel kind of
  at   LIGHT in the head now,
  gmail.comknowing I can't make my
   satellite dish PAYMENTS!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PySerial could not open port COM4: [Error 5] Access is denied - please help

2012-06-27 Thread Temia Eszteri
On Wed, 27 Jun 2012 22:18:59 + (UTC), Grant Edwards
invalid@invalid.invalid wrote:

 Can you post a small example showing what you're doing?

The best way to get help is to write as small a program as possible
that demonstrates the problem, and post it.  I'll help you get
started...

Does this program work?

import serial
ser = serial.Serial(COM4)
ser.close()

At the moment, I don't have access to a Windows machine, but I think
the above should run without any errors.  If it works, then you've
successfully opened and closed the COM4 port.  Start adding
features, in increments as small as possible, until the program
fails.

Then try to remove stuff that's not needed while still keeping the
failure.

IOW, try to find the smallest possible program that fails.

Usually, in the process of doing that, you'll figure out what you were
doing wrong.  If not, post the smallest failing program you can come
up with, and somebody will be able to help.

If you won't show us what you're doing, we can't tell you what you're
doing wrong.

Actually, I believe someone in an earlier thread in the newsgroup or
elsewhere pointed out that serial ports automatically open under
Windows. I'd have to look it back up when I have the time, which I
don't have at the moment, unfortunately.

~Temia
-- 
The amazing programming device: fuelled entirely by coffee, it codes while
awake and tests while asleep!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PySerial could not open port COM4: [Error 5] Access is denied - please help

2012-06-27 Thread Adam

Temia Eszteri lamial...@cleverpun.com wrote in message 
news:ra2nu7h75720i75ijhabg12dngrab75...@4ax.com...
 On Wed, 27 Jun 2012 22:18:59 + (UTC), Grant Edwards
 invalid@invalid.invalid wrote:

 Can you post a small example showing what you're doing?

The best way to get help is to write as small a program as possible
that demonstrates the problem, and post it.  I'll help you get
started...

Does this program work?

import serial
ser = serial.Serial(COM4)
ser.close()

At the moment, I don't have access to a Windows machine, but I think
the above should run without any errors.  If it works, then you've
successfully opened and closed the COM4 port.  Start adding
features, in increments as small as possible, until the program
fails.

Then try to remove stuff that's not needed while still keeping the
failure.

IOW, try to find the smallest possible program that fails.

Usually, in the process of doing that, you'll figure out what you were
doing wrong.  If not, post the smallest failing program you can come
up with, and somebody will be able to help.

If you won't show us what you're doing, we can't tell you what you're
doing wrong.

 Actually, I believe someone in an earlier thread in the newsgroup or
 elsewhere pointed out that serial ports automatically open under
 Windows. I'd have to look it back up when I have the time, which I
 don't have at the moment, unfortunately.

 ~Temia
 -- 
 The amazing programming device: fuelled entirely by coffee, it codes while
 awake and tests while asleep!


Thanks, I think I read that as well but can't recall where.

I am just running Python scripts (downloaded),
which is not opening the serial port more than once (as Grant keeps 
assuming).


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PySerial could not open port COM4: [Error 5] Access is denied - please help

2012-06-27 Thread Grant Edwards
On 2012-06-27, Adam adam@no_thanks.com wrote:

 Actually, I believe someone in an earlier thread in the newsgroup or
 elsewhere pointed out that serial ports automatically open under
 Windows. I'd have to look it back up when I have the time, which I
 don't have at the moment, unfortunately.

What they're referring to is that on startup, Windows used to open
serial ports and query them to see if there was a serial mouse
connected.  If it _thought_ it found a mouse, it would then hold the
port. I don't think that behavior has been enabled by default for a
long time.

If that were the case, then your terminal program wouldn't be able to
open the port either.

However, IIRC, some versions of windows do open and then close the
ports during the bus/device enumeration step of startup. However, they
don't keep the port open, so it doesn't affect the ability of user
applications to later open the port.

 Thanks, I think I read that as well but can't recall where.

 I am just running Python scripts (downloaded), which is not opening
 the serial port more than once (as Grant keeps assuming).

Well, I'm assuming your description of what you're doing is accurate.

If you're telling the truth, then the program is opening the port more
than once.

If the port wasn't already open, then calling ser.close() wouldn't do
_anything_.  Here's the close() implmentation from pyserial:

def close(self):
Close port
if self._isOpen:
if self.hComPort:
# Restore original timeout values:
win32.SetCommTimeouts(self.hComPort, self._orgTimeouts)
# Close COM-Port:
win32.CloseHandle(self.hComPort)
win32.CloseHandle(self._overlappedRead.hEvent)
win32.CloseHandle(self._overlappedWrite.hEvent)
self.hComPort = None
self._isOpen = False

There's only _one_ place where self._isOpen is set to True, and that's
at the end of the open() call:

def open(self):
Open port with current settings. This may throw a SerialException
   if the port cannot be opened.
[...]
self._overlappedWrite.hEvent = win32.CreateEvent(None, 0, 0, None)
self._isOpen = True

If you have to add the call ser.close() before you can open the port
with ser.open(), then that means that the port _was_already_open_.

-- 
Grant Edwards   grant.b.edwardsYow! World War III?
  at   No thanks!
  gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PySerial could not open port COM4: [Error 5] Access is denied - please help

2012-06-27 Thread Adam

Grant Edwards invalid@invalid.invalid wrote in message 
news:jsg4o8$o4p$1...@reader1.panix.com...
 On 2012-06-27, Adam adam@no_thanks.com wrote:

 Actually, I believe someone in an earlier thread in the newsgroup or
 elsewhere pointed out that serial ports automatically open under
 Windows. I'd have to look it back up when I have the time, which I
 don't have at the moment, unfortunately.

 What they're referring to is that on startup, Windows used to open
 serial ports and query them to see if there was a serial mouse
 connected.  If it _thought_ it found a mouse, it would then hold the
 port. I don't think that behavior has been enabled by default for a
 long time.

 If that were the case, then your terminal program wouldn't be able to
 open the port either.

 However, IIRC, some versions of windows do open and then close the
 ports during the bus/device enumeration step of startup. However, they
 don't keep the port open, so it doesn't affect the ability of user
 applications to later open the port.

 Thanks, I think I read that as well but can't recall where.

 I am just running Python scripts (downloaded), which is not opening
 the serial port more than once (as Grant keeps assuming).

 Well, I'm assuming your description of what you're doing is accurate.

 If you're telling the truth, then the program is opening the port more
 than once.

 If the port wasn't already open, then calling ser.close() wouldn't do
 _anything_.  Here's the close() implmentation from pyserial:

def close(self):
Close port
if self._isOpen:
if self.hComPort:
# Restore original timeout values:
win32.SetCommTimeouts(self.hComPort, self._orgTimeouts)
# Close COM-Port:
win32.CloseHandle(self.hComPort)
win32.CloseHandle(self._overlappedRead.hEvent)
win32.CloseHandle(self._overlappedWrite.hEvent)
self.hComPort = None
self._isOpen = False

 There's only _one_ place where self._isOpen is set to True, and that's
 at the end of the open() call:

def open(self):
Open port with current settings. This may throw a 
 SerialException
   if the port cannot be opened.
 [...]
self._overlappedWrite.hEvent = win32.CreateEvent(None, 0, 0, None)
self._isOpen = True

 If you have to add the call ser.close() before you can open the port
 with ser.open(), then that means that the port _was_already_open_.

 -- 
 Grant Edwards   grant.b.edwardsYow! World War III?
  at   No thanks!
  gmail.com


Obviously pySerial considers the serial port open and will not open an 
already open serial port.
However, why is it that TeraTerm can open the serial port?

Here's the link where I read about calling ser.close() before ser.open() ...

Trying to open a serial port with pyserial on WinXP - Access denied
http://stackoverflow.com/questions/2063257/trying-to-open-a-serial-port-with-pyserial-on-winxp-access-denied


Here's the Python scripts ...
https://github.com/adafruit/Tweet-a-Watt/downloads
Click on the Download as ... button for the Python scripts


-- 
http://mail.python.org/mailman/listinfo/python-list


PySerial could not open port COM4: [Error 5] Access is denied - please help

2012-06-26 Thread Adam
Host OS:Ubuntu 10.04 LTS
Guest OS:Windows XP Pro SP3


I am able to open port COM4 with Terminal emulator.

So, what can cause PySerial to generate the following error ...

C:\Wattcherpython wattcher.py
Traceback (most recent call last):
  File wattcher.py, line 56, in module
ser.open()
  File C:\Python25\Lib\site-packages\serial\serialwin32.py, line 56, in 
open
raise SerialException(could not open port %s: %s % (self.portstr, 
ctypes.WinError()))
serial.serialutil.SerialException: could not open port COM4: [Error 5] 
Access is denied.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PySerial could not open port COM4: [Error 5] Access is denied - please help

2012-06-26 Thread John Nagle

On 6/26/2012 9:12 PM, Adam wrote:

Host OS:Ubuntu 10.04 LTS
Guest OS:Windows XP Pro SP3


I am able to open port COM4 with Terminal emulator.

So, what can cause PySerial to generate the following error ...

C:\Wattcherpython wattcher.py
Traceback (most recent call last):
   File wattcher.py, line 56, in module
 ser.open()
   File C:\Python25\Lib\site-packages\serial\serialwin32.py, line 56, in
open
 raise SerialException(could not open port %s: %s % (self.portstr,
ctypes.WinError()))
serial.serialutil.SerialException: could not open port COM4: [Error 5]
Access is denied.


Are you trying to access serial ports from a virtual machine?
Which virtual machine environment?  Xen?  VMware? QEmu?  VirtualBox?
I wouldn't expect that to work in most of those.

What is COM4, anyway?   Few machines today actually have four
serial ports.  Is some device emulating a serial port?

John Nagle


--
http://mail.python.org/mailman/listinfo/python-list


pyserial for GPS data

2012-03-15 Thread Arun p das
I have a USB GPS dongle using this for getting  position information. I
installed gpsd daemon so that any clients can read data from that. It is
working fine
used xgps, cgps as clients.

*gpsd -n -N -D2 /dev/ttyUSB0 *

import gps, os, time
g = gps.gps(mode=gps.WATCH_NEWSTYLE)
while 1:
os.system('clear')
g.poll()
#if gps.PACKET_SET:
g.stream()
print 'latitude ' , g.fix.latitude
print 'longitude ' , g.fix.longitude
print 'time utc ' , g.utc,' + ', g.fix.time


Used the following program to read gps data but it is not giving accurate
readings as cgps,xgps clients. I tried to read directly from the serial
port using the following program but its giving non printable characters as
output as it should return something like

$GPRMC,199304.973,3248.7780,N,11355.7832,W,1,06,02.2,25722.5,M,,,*00

*import serial*
*ser = serial.Serial( port='/dev/ttyUSB0', baudrate=4800,timeout=1) *
*while True:*
* line=ser.read()*
* print line,*
*f.close()*
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pySerial question, setting certain serial parameters [newbie]

2012-02-07 Thread Peter
On Feb 4, 11:47 pm, Jean Dupont jeandupont...@gmail.com wrote:
 I need to set the following options I found in a Perl-script in Python for 
 serial communication with a device (a voltmeter):

 $port-handshake(none);
 $port-rts_active(0);
 $port-dtr_active(1);

 I have thus far the following  statements but I think it does not set the 
 above parameters correctly:
 import serial
 voltport='/dev/ttyUSB2'
 ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1,timeout=15)

 thanks
 Jean

My reading of the __init__ method documentations shows you should
have:

ser2 = serial.Serial(voltport, 2400, dsrdtr=True, timeout=15)

since the defaults for bytesize are EIGHTBITS (for which you use 8 -
wrong), parity is already default to PARITY_NONE (so this isn't
needed), stopbits defaults to STOPBITS_ONE (for which you use 1 -
wrong) and (assuming the Perl code 1 is to enable) dsrdtr=True
(xonxoff and rtscts both default to False).

Try that.




-- 
http://mail.python.org/mailman/listinfo/python-list


pySerial question, setting certain serial parameters [newbie]

2012-02-06 Thread Jean Dupont
I need to set the following options I found in a Perl-script in Python for 
serial communication with a device (a voltmeter):

$port-handshake(none);
$port-rts_active(0);
$port-dtr_active(1); 

I have thus far the following  statements but I think it does not set the above 
parameters correctly:
import serial
voltport='/dev/ttyUSB2'
ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1,timeout=15) 

thanks
Jean
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   5   >