#131 flushInput() breaks connection

v2.6
pending-works-for-me
Chris Liechti
None
5
1 hour ago
2012-11-12
Phil
No

The flushInput() command seems to break my serial connection and doesn't allow for further reads. I can set up a connection, read perfectly fine, but after a flushInput() command any further read statements return no data. The inWaiting() command also returns 0. In order to receive more data I have to power cycle my device and restart the connection.

I'm using Python version 2.7.2, pyserial version 2.6, and mac OS X version 10.6.8

At the moment I'm hooked up to an arduino Uno. I had this same problem hooked up to a rs422 - usb converter.

Here's the commands I use:

>>> import serial as sr
>>> ser = sr.Serial('/dev/tty.usbmodem621',9600)
>>> ser.inWaiting()
1020
>>> ser.flushInput()
>>> ser.inWaiting()
0
>>> ser.inWaiting()
0
>>> ser.inWaiting()
0
>>>

It will continue to contain 0 data indefinitely.

Discussion

  • Chris Liechti
    Chris Liechti
    2013-10-11

    • status: open --> pending-works-for-me
    • Group: --> v1.0 (example)
     
  • Chris Liechti
    Chris Liechti
    2013-10-11

    Works for me. So my guess is that either that other device is no longer sending data or the serial port driver could be buggy.

     
  • Chris Liechti
    Chris Liechti
    2013-10-17

    • assigned_to: Chris Liechti
    • Group: v1.0 (example) --> v2.6
     
  • Jacob Pfeifer
    Jacob Pfeifer
    2 hours ago

    I am having the same error on OS X 10.10.5 python 2.7.10 pyserial 2.7, it seems to only happen when the input buffer is full before the flush happens

     
  • Jacob Pfeifer
    Jacob Pfeifer
    1 hour ago

    Iterestingly it appears that if you call cat on the tty twice pyserial will resume communication. the first cat returns nothing while the second returns a stream of data (or at least with my device it does)