FAQ
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�00,
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�00,
bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE, timeout=None, dsrdtr�lse)
# here the device is reset ...

handler.close()


I found the following post http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num74205532
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�lse)
# here the device is reset ...

handler.close()


I found the following post http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num74205532
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

Search Discussions

  • Dan Stromberg at Jul 8, 2011 at 4:22 am

    On Thu, Jul 7, 2011 at 12:34 PM, yorick wrote:

    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.<http://mail.python.org/mailman/listinfo/python-list>

    A few suggestions:

    1) You could try strace'ing the TCL, and then strace'ing the Python, and
    comparing - especially if you're comfortable with low-level I/O in C, but
    not only. Hunt for the open() call to the relevant device file, and other
    system calls near it. Even if you aren't that cozy with C, you could try
    putting the strace results on a website or ftp server, and posting links to
    them here.

    2) Check and double check and triple check your line discipline parameters:
    bits per second, parity, word size, start/stop bits.

    3) It's also possible the cable is bad (or merely inappropriate), especially
    if the TCL is accessing such a device over a different cable. There is no
    "one true serial (RS-232) cable standard" - RS-232 is a rather large
    collection of ways of doing communications, and they are frequently not
    compatible with one another.

    4) One of the more likely causes of a reset of a device that is accessed
    serially, is sending it a break signal. There are official ways of sending
    a break, and accidental ways. Sometimes the two boil down to the same thing
    behind the scenes, but look very different in the code. A break signal is a
    longish sequence of unframed 0 bits (IE, with no start/stop bits separating
    one byte from another). An accidental way of sending a break, is to set
    your bits per second too low, and then sending a 0 byte - because those 8 0
    bits at the too-low speed will look like a long series of unframed 0's from
    the perspective of the reader process that's running at the correct speed.
    So I guess the gist of point #4 (this point), is "make sure your bps is set
    correctly" and "check the device doc to see if a break signal causes a
    reset"

    5) If the protocol layered over the serial communication is ASCII-based, you
    could try connecting to the device using something like minicom, to make
    sure the device is behaving as expected. If the device is speaking a binary
    protocol, this is unlikely to help much

    HTH
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://mail.python.org/pipermail/python-list/attachments/20110707/6ee72ab3/attachment-0001.html>
  • Tim Roberts at Jul 8, 2011 at 7:45 am

    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.

    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.
    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?
    --
    Tim Roberts, timr at probo.com
    Providenza & Boekelheide, Inc.
  • Tim Chase at Jul 8, 2011 at 12:58 pm

    On 07/08/2011 02:45 AM, Tim Roberts wrote:
    yorickwrote:
    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
  • Grant Edwards at Jul 8, 2011 at 1:56 pm

    On 2011-07-08, Tim Chase wrote:
    On 07/08/2011 02:45 AM, Tim Roberts wrote:
    yorickwrote:
    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!!

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJul 7, '11 at 7:34p
activeJul 8, '11 at 1:56p
posts5
users5
websitepython.org

People

Translate

site design / logo © 2023 Grokbase