Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > pySerial question, setting certain serial parameters [newbie]

Reply
Thread Tools

pySerial question, setting certain serial parameters [newbie]

 
 
Jean Dupont
Guest
Posts: n/a
 
      02-04-2012
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
 
Reply With Quote
 
 
 
 
Chris Rebert
Guest
Posts: n/a
 
      02-07-2012
On Sat, Feb 4, 2012 at 4:47 AM, Jean Dupont <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
 
Peter
Guest
Posts: n/a
 
      02-08-2012
On Feb 4, 11:47*pm, Jean Dupont <(E-Mail Removed)> 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.




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
pyserial doesn't recognize virtual serial port naveen.sabapathy@gmail.com Python 4 10-31-2011 08:11 PM
Re: python 2.7.1 "serial" vs "pyserial" Terry Reedy Python 0 03-25-2011 08:23 PM
Pyserial - send and receive characters through linux serial port terry Python 5 05-03-2008 03:15 AM
[pyserial - winXP] Serial port stop receiving data after a few hours, raise no error pauland80@gmail.com Python 0 08-07-2007 09:06 PM
[pyserial - winXP] Serial port stop receiving data after a few hours, raise no error pauland80@gmail.com Python 2 06-07-2007 05:56 AM



Advertisments