2

I have a strange problem with my serial port. It seems that sth has changed after ubuntu actualizations and reboot.

przem@przem:~/Pulpit/bat/scripts$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import serial
>>> ser = serial.Serial("/dev/ttyUSB0", 57600)
>>> ser.read()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/serial/serialposix.py", line 475, in read
    raise SerialException('device reports readiness to read but returned no data (device disconnected or multiple access on port?)')
serial.serialutil.SerialException: device reports readiness to read but returned no data (device disconnected or multiple access on port?)
>>> 

I know that I should have ' ' (empty sign) result from my device but instead of it I get exception:

'device reports readiness to read but returned no data (device disconnected or multiple access on port?)'

This question is an introduction to my problem: https://stackoverflow.com/questions/32844942/serialport-doenst-work-correctly-after-ubuntu-update?noredirect=1#comment53527004_32844942

Please help me.

3 Answers 3

2

I experience the same problem. It does not seem to be limited to serial port hardware. You can create two pseudo terminals using socat:

$ socat -d -d pty,raw,echo=0 pty,raw,echo=0
2015/09/30 09:46:18 socat[6296] N PTY is /dev/pts/17
2015/09/30 09:46:18 socat[6296] N PTY is /dev/pts/18
2015/09/30 09:46:18 socat[6296] N starting data transfer loop with FDs [3,3] and [5,5]

You can connect with both devices, for example using cu

cu -l /dev/pts/17 -s 115200

and

cu -l /dev/pts/18 -s 115200

and send data in both directions, no problem.

But connecting with Python 2.7 fails with the error message you mentioned

$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import serial
>>> ser = serial.Serial("/dev/pts/17", 230400, timeout=0.2)
>>> ser.read()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 460, in read
    raise SerialException('device reports readiness to read but returned no data (device disconnected?)')
serial.serialutil.SerialException: device reports readiness to read but returned no data (device disconnected?)

This code worked before installing the updates for Ubuntu 14.04 yesterday.

Any ideas?

5
  • Thank you for your answer. I have reported it: bugs.launchpad.net/ubuntu/+source/python2.7/+bug/1501240 Is it possible to undo update?
    – pb.
    Sep 30, 2015 at 9:18
  • You look into the update log in /var/log/apt/history.log. One of the packages in the last block must have caused the trouble. See here for reverting updates.
    – Philipp R.
    Sep 30, 2015 at 11:41
  • Here is the list of last updates: snag.gy/Q55wX.jpg I tried to revert lprevious libgudev-1.0.0 and gir1.2-gudev-10 but nothing changed. I don't know which update has influence on this serialport
    – pb.
    Sep 30, 2015 at 13:48
  • Could be a kernel issue, see here: mail-archive.com/[email protected]/…
    – Philipp R.
    Sep 30, 2015 at 14:14
  • Thank you so much. I have done downgrade and now is OK. solved!
    – pb.
    Oct 1, 2015 at 14:43
1

I do not endorse this, but I stopped seeing these errors after making this change:

--- serialposix.py.stock    2015-10-03 06:53:45.241261071 -0700 
+++ serialposix.py  2015-10-03 06:55:07.481262475 -0700
@@ -457,7 +457,11 @@
             # Disconnected devices, at least on Linux, show the
             # behavior that they are always ready to read immediately
             # but reading returns nothing.
-                raise SerialException('device reports readiness to read but returned no data (device disconnected?)')
+                # retrying the read seems to get me past this error:
+                # [ERROR] Can't read from printer (disconnected?)     (SerialException): device reports readiness to read but returned no data (device disconnected?)
+
+                #raise SerialException('device reports readiness to read but returned no data (device disconnected?)')
+                pass
         read.extend(buf)
     return bytes(read)
2
  • Why are you posting an answer you don't endorse?
    – DavidPostill
    Oct 3, 2015 at 22:14
  • 1
    Because it's useful. Oct 20, 2015 at 14:34
1

This may be a kernel bug. See here: https://bugs.launchpad.net/ubuntu/+source/python2.7/+bug/1501240

The workaround it seems is to use kernel 3.13.0-63-generic.

You can change the kernel for a one-time boot by holding shift while starting up. To make the change persistent, you need to edit /etc/default/grub: https://askubuntu.com/questions/262965/grub-timeout-set-to-0-cant-access-grub-menu-anymore?rq=1

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .