pySerial question, setting certain serial parameters [newbie]

Discussion in 'Python' started by Jean Dupont, Feb 4, 2012.

  1. Jean Dupont

    Jean Dupont Guest

    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
     
    Jean Dupont, Feb 4, 2012
    #1
    1. Advertising

  2. Jean Dupont

    Chris Rebert Guest

    On Sat, Feb 4, 2012 at 4:47 AM, Jean Dupont <> 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
     
    Chris Rebert, Feb 7, 2012
    #2
    1. Advertising

  3. Jean Dupont

    Peter Guest

    On Feb 4, 11:47 pm, Jean Dupont <> 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.
     
    Peter, Feb 8, 2012
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    462
    Hendrik van Rooyen
    Jun 7, 2007
  2. Replies:
    0
    Views:
    767
  3. Replies:
    4
    Views:
    2,075
    marina_dan
    Oct 31, 2011
  4. terry
    Replies:
    5
    Views:
    893
    Gabriel Genellina
    May 3, 2008
  5. Terry Reedy

    Re: python 2.7.1 "serial" vs "pyserial"

    Terry Reedy, Mar 25, 2011, in forum: Python
    Replies:
    0
    Views:
    586
    Terry Reedy
    Mar 25, 2011
Loading...

Share This Page