Pyserial not getting response every time, input/output errors

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rainy

    Pyserial not getting response every time, input/output errors

    Hello!

    I'm having some trouble with pyserial package, I'm sending commands
    and reading responses from a custom pcb, and sometimes I get a proper
    response, at other times I get nothing, and sometimes I get about half
    of the response string with beginning cut off. About half the time an
    empty string is returned, the other ~half time good response, and more
    rarely I get partial response.

    When I try to use the same Serial instance to send/receive a few
    times, I end up getting an input/output error.

    Here are some examples:
    >>ser = serial.Serial('/dev/ttyAM1', 115200, timeout=0.1)
    >>ser.write(chr (2) + chr(1) + chr(6) + chr(12) + chr(34) + chr(0) + chr(0))
    >>ser.read(60 )
    ''
    >>ser.close()
    >>ser = serial.Serial('/dev/ttyAM1', 115200, timeout=0.1)
    >>ser.write(chr (2) + chr(1) + chr(6) + chr(12) + chr(34) + chr(0) + chr(0))
    >>ser.read(60 )
    '\x02\x00\'\x0c "\x00My Thermostat R1.0B'
    >>ser.write(chr (2) + chr(1) + chr(6) + chr(12) + chr(34) + chr(0) + chr(0))
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    File "/usr/lib/python2.3/site-packages/serial/serialposix.py" , line
    372, in write
    n = os.write(self.f d, d)
    OSError: [Errno 5] Input/output error


    I tried timeout values from 0.1 to 3sec. Doesn't make a difference.

    Aside from the possibility of hw issue (I'm investigating this now),
    what else could it be? We tested this from a different computer from a
    Ferret terminal program using a different cable, and it worked without
    problem. I tried many different things, using miniterm.py provided
    with pyserial, getting newest version of pyserial, sending one char at
    a time, etc etc. I get same intermittent problems..

    If anyone have an idea on what else I can try, please help! thanks!
  • Carsten Haese

    #2
    Re: Pyserial not getting response every time, input/output errors

    Rainy wrote:
    Hello!
    >
    I'm having some trouble with pyserial package, I'm sending commands
    and reading responses from a custom pcb, and sometimes I get a proper
    response, at other times I get nothing, and sometimes I get about half
    of the response string with beginning cut off. About half the time an
    empty string is returned, the other ~half time good response, and more
    rarely I get partial response.
    >
    When I try to use the same Serial instance to send/receive a few
    times, I end up getting an input/output error.
    >
    Here are some examples:
    >
    >>>ser = serial.Serial('/dev/ttyAM1', 115200, timeout=0.1)
    One possible point of failure is that you're not supplying any
    parameters for the data format (byte size, parity, stop bits) and flow
    control. The Serial object will assume defaults, and those defaults may
    or may not be correct.

    Try to find out what data format and flow control you should be using
    and set explicit Serial parameters accordingly.

    Hope this helps,

    --
    Carsten Haese

    Comment

    • Rainy

      #3
      Re: Pyserial not getting response every time, input/output errors



      Carsten Haese wrote:
      Rainy wrote:
      Hello!

      I'm having some trouble with pyserial package, I'm sending commands
      and reading responses from a custom pcb, and sometimes I get a proper
      response, at other times I get nothing, and sometimes I get about half
      of the response string with beginning cut off. About half the time an
      empty string is returned, the other ~half time good response, and more
      rarely I get partial response.

      When I try to use the same Serial instance to send/receive a few
      times, I end up getting an input/output error.

      Here are some examples:
      >>ser = serial.Serial('/dev/ttyAM1', 115200, timeout=0.1)
      >
      One possible point of failure is that you're not supplying any
      parameters for the data format (byte size, parity, stop bits) and flow
      control. The Serial object will assume defaults, and those defaults may
      or may not be correct.
      >
      Try to find out what data format and flow control you should be using
      and set explicit Serial parameters accordingly.
      >
      Hope this helps,
      >
      --
      Carsten Haese
      http://informixdb.sourceforge.net
      Thanks for the reply, Carsten, I should have mentioned.. yes, I did
      confirm
      that defaults pyserial's providing are correct with pcb maker.

      Comment

      • Grant Edwards

        #4
        Re: Pyserial not getting response every time, input/output errors

        On 2008-08-12, Carsten Haese <carsten.haese@ gmail.comwrote:
        Rainy wrote:
        >Hello!
        >>
        >I'm having some trouble with pyserial package, I'm sending commands
        >and reading responses from a custom pcb, and sometimes I get a proper
        >response, at other times I get nothing, and sometimes I get about half
        >of the response string with beginning cut off. About half the time an
        >empty string is returned, the other ~half time good response, and more
        >rarely I get partial response.
        >>
        >When I try to use the same Serial instance to send/receive a few
        >times, I end up getting an input/output error.
        >>
        >Here are some examples:
        >>
        >>>>ser = serial.Serial('/dev/ttyAM1', 115200, timeout=0.1)
        >
        One possible point of failure is that you're not supplying any
        parameters for the data format (byte size, parity, stop bits) and flow
        control. The Serial object will assume defaults, and those defaults may
        or may not be correct.
        None of those things are capable of creating an input/output
        error -- you'll just get goofy data values (or no answer from
        the device at the other end of cable). An input/output error
        usually means that there are issues with the underlying bus or
        there are hardware failures.
        Try to find out what data format and flow control you should
        be using and set explicit Serial parameters accordingly.
        --
        Grant Edwards grante Yow! ... If I had heart
        at failure right now,
        visi.com I couldn't be a more
        fortunate man!!

        Comment

        Working...