Serial & reset of the device

Discussion in 'Python' started by yorick, Jul 7, 2011.

  1. yorick

    yorick Guest

    Hello,

    I'm trying to access a hardware board of my company through a serial
    connection using a Python script and the pyserial module.

    I use Python 2.7.1 with Ubuntu 11.04 (pyserial is the package python-
    serial with version 2.5.2, http://pyserial.sourceforge.net/pyserial_api.html).

    The board to which I'm trying to connect works correctly with serial
    as some other guys did some TCL scripts to manage it.
    My problem is that every time I open a new connection, the device is
    reset. I'd like to not have the device reset.

    The code is the following :

    handler = serial.Serial(port=self.portname, baudrate=9600,
    bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stHello,

    I'm trying to access a hardware board of my company through a serial
    connection using a Python script and the pyserial module.

    I use Python 2.7.1 with Ubuntu 11.04 (pyserial is the package python-
    serial with version 2.5.2, http://pyserial.sourceforge.net/pyserial_api.html).

    The board to which I'm trying to connect works correctly with serial
    as some other guys did some TCL scripts to manage it.
    My problem is that every time I open a new connection, the device is
    reset. I'd like to not have the device reset.

    The code is the following :

    handler = serial.Serial(port=self.portname, baudrate=9600,
    bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE,
    stopbits=serial.STOPBITS_ONE, timeout=None, dsrdtr=False)
    # here the device is reset ...

    handler.close()


    I found the following post http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1274205532
    but I haven't tested it yet as I don't like the idea to change files
    managed by the system (and it is for Windows).

    Is there any possibility to not reset the device when opening the
    connection ?

    Thanks,
    Yorickopbits=serial.STOPBITS_ONE, timeout=None, dsrdtr=False)
    # here the device is reset ...

    handler.close()


    I found the following post http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1274205532
    but I haven't tested it yet as I don't like the idea to change files
    managed by the system (and it is for Windows).

    Is there any possibility to not reset the device when opening the
    connection ?

    Thanks,
    Yorick
    yorick, Jul 7, 2011
    #1
    1. Advertising

  2. yorick

    Tim Chase Guest

    On 07/08/2011 02:45 AM, Tim Roberts wrote:
    > yorick<> wrote:
    >> I'm trying to access a hardware board of my company through a serial
    >> connection using a Python script and the pyserial module.
    >>
    >> The board to which I'm trying to connect works correctly with serial
    >> as some other guys did some TCL scripts to manage it.
    >> My problem is that every time I open a new connection, the device is
    >> reset. I'd like to not have the device reset.

    >
    > I'm not sure what that means. The RS-232 standard does not have the
    > concept of "reset". What is it that triggers a device reset?


    While not a "reset" per-se, it might be triggered by the RTS/CTS,
    DSR/DTR, or carrier-detect pins depending on the configuration.
    Without the code and with minimal pySerial experience, I don't
    know whether opening a serial-port in pySerial automatically
    lights up one of those aux. lines and unsignals it when the
    connection is closed. If the device expects a "power on" signal
    on one of those pins, I'd start by looking to see if pySerial's
    ..close() drops the signal on those pins and if it offers a way to
    keep the signal high while releasing the port. Otherwise, you
    may have to open once, do all your work and only close the port
    when you're done (and the device can be reset)

    -tkc
    Tim Chase, Jul 8, 2011
    #2
    1. Advertising

  3. On 2011-07-08, Tim Chase <> wrote:
    > On 07/08/2011 02:45 AM, Tim Roberts wrote:
    >> yorick<> wrote:
    >>> I'm trying to access a hardware board of my company through a serial
    >>> connection using a Python script and the pyserial module.
    >>>
    >>> The board to which I'm trying to connect works correctly with serial
    >>> as some other guys did some TCL scripts to manage it. My problem is
    >>> that every time I open a new connection, the device is reset. I'd
    >>> like to not have the device reset.

    >>
    >> I'm not sure what that means. The RS-232 standard does not have the
    >> concept of "reset". What is it that triggers a device reset?

    >
    > While not a "reset" per-se, it might be triggered by the RTS/CTS,
    > DSR/DTR, or carrier-detect pins depending on the configuration.
    > Without the code and with minimal pySerial experience, I don't
    > know whether opening a serial-port in pySerial automatically
    > lights up one of those aux. lines and unsignals it when the
    > connection is closed.


    On Unix, the serial port device driver generally turns DTR and RTS off
    when a port is closed and turns them on when it's opened. I don't
    know what Windows does. A quick glance through the pyserial sources
    shows that it turns on DTR and RTS when a port is opened, and does
    nothing with them when a port is closed.

    If you need RTS/DTR to stay in a known state, then open the port, set
    them to the state you want them, and keep the port open.

    --
    Grant Edwards grant.b.edwards Yow! Remember, in 2039,
    at MOUSSE & PASTA will
    gmail.com be available ONLY by
    prescription!!
    Grant Edwards, Jul 8, 2011
    #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. nishadixit
    Replies:
    5
    Views:
    1,252
    Joe Discar
    Jun 1, 2005
  2. bronby
    Replies:
    0
    Views:
    490
    bronby
    Jun 17, 2005
  3. dev

    interfacing a serial device

    dev, Sep 16, 2006, in forum: C Programming
    Replies:
    6
    Views:
    287
    Default User
    Sep 20, 2006
  4. Replies:
    1
    Views:
    426
    santosh
    Nov 27, 2006
  5. Matt
    Replies:
    0
    Views:
    466
Loading...

Share This Page