pySerial question, setting certain serial parameters [newbie]

J

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
 
C

Chris Rebert

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
 
P

Peter

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.
 

Ask a Question

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

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

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top