Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #19923 > unrolled thread

pySerial question, setting certain serial parameters [newbie]

Started byJean Dupont <jeandupont115@gmail.com>
First post2012-02-04 04:47 -0800
Last post2012-02-07 16:16 -0800
Articles 3 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  pySerial question, setting certain serial parameters [newbie] Jean Dupont <jeandupont115@gmail.com> - 2012-02-04 04:47 -0800
    Re: pySerial question, setting certain serial parameters [newbie] Chris Rebert <clp2@rebertia.com> - 2012-02-06 20:48 -0800
    Re: pySerial question, setting certain serial parameters [newbie] Peter <peter.milliken@gmail.com> - 2012-02-07 16:16 -0800

#19923 — pySerial question, setting certain serial parameters [newbie]

FromJean Dupont <jeandupont115@gmail.com>
Date2012-02-04 04:47 -0800
SubjectpySerial question, setting certain serial parameters [newbie]
Message-ID<4142345.2853.1328359637311.JavaMail.geo-discussion-forums@yquu38>
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

[toc] | [next] | [standalone]


#19936

FromChris Rebert <clp2@rebertia.com>
Date2012-02-06 20:48 -0800
Message-ID<mailman.5492.1328590137.27778.python-list@python.org>
In reply to#19923
On Sat, Feb 4, 2012 at 4:47 AM, Jean Dupont <jeandupont115@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)

A link to the Perl library's documentation would be helpful.

Cheers,
Chris

[toc] | [prev] | [next] | [standalone]


#19994

FromPeter <peter.milliken@gmail.com>
Date2012-02-07 16:16 -0800
Message-ID<22a9c96e-60a2-4c03-b80e-954c30ea6872@g4g2000pbi.googlegroups.com>
In reply to#19923
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.



[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web