Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #19969
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Subject | Re: convert perl-script for voltcraft voltmeter to python [newbie] |
| Date | 2012-02-07 12:44 -0500 |
| References | <d953c169-0656-46c1-a3ba-5387c9c06df8@t30g2000vbx.googlegroups.com> <8a475c9d-24ed-45a4-af9f-2ca826f9301d@m2g2000vbc.googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5506.1328637009.27778.python-list@python.org> (permalink) |
On Fri, 3 Feb 2012 05:11:54 -0800 (PST), Jean Dupont
<jeandupont115@gmail.com> wrote:
>As my request might have been too much asked, I have started doing
>some coding myself.
>I'm in doubt about the readline statement -which doesn't show anything
>received- as the meter sends continuously streams of 11 bytes
Well, since readline() pretty much by definition wants a line-ending
character before returning, it obviously won't work. (Side comment:
readline() isn't even shown as part of the basic Serial class -- it is
in a class FileLike: http://pyserial.sourceforge.net/pyserial_api.html
-- oh wait.. fine print says that is a base class for Serial on non-io
module systems).
What is the boundary marker for your 11-byte chunks? You may need to
do a synchronization loop using
while ser2.read() != marker: continue
then go into main processing loop with
data = ser2.read(11)
to capture a "chunk".
Oh, BTW...
> $port->rts_active(0);
> $port->dtr_active(1);
...
> #$port->read_char_time(5); # wait 5ms per character
> $port->read_const_time(200); # 0.2 second per unfulfilled "read"
vs your
> ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, timeout=15)
Your timeout is FIFTEEN SECONDS!
Suspect you want something like
ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE,
serial.STOPBITS-ONE, timeout=0.200,
dsrdtr = True)
and maybe also
ser2.setDTR(True)
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
convert perl-script for voltcraft voltmeter to python [newbie] Jean Dupont <jeandupont115@gmail.com> - 2012-02-02 12:57 -0800
Re: convert perl-script for voltcraft voltmeter to python [newbie] Jean Dupont <jeandupont115@gmail.com> - 2012-02-03 05:11 -0800
Re: convert perl-script for voltcraft voltmeter to python [newbie] Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-02-07 12:44 -0500
Re: convert perl-script for voltcraft voltmeter to python [newbie] Rick Johnson <rantingrickjohnson@gmail.com> - 2012-02-07 11:47 -0800
Re: convert perl-script for voltcraft voltmeter to python [newbie] Dietmar Schwertberger <news@schwertberger.de> - 2012-02-08 01:26 +0100
Re: convert perl-script for voltcraft voltmeter to python [newbie] Jean Dupont <jeandupont115@gmail.com> - 2012-02-08 04:24 -0800
Re: convert perl-script for voltcraft voltmeter to python [newbie] Terry Reedy <tjreedy@udel.edu> - 2012-02-06 23:21 -0500
Re: convert perl-script for voltcraft voltmeter to python [newbie] Jean Dupont <jeandupont115@gmail.com> - 2012-02-07 11:44 -0800
Re: convert perl-script for voltcraft voltmeter to python [newbie] Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-02-07 17:57 -0500
csiph-web