Serialport doens't work correctly after ubuntu update?

2

1

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.

pb.

Posted 2015-09-29T15:04:42.540

Reputation: 43

Answers

1

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?

Philipp R.

Posted 2015-09-29T15:04:42.540

Reputation: 26

Thank you for your answer. I have reported it: https://bugs.launchpad.net/ubuntu/+source/python2.7/+bug/1501240

Is it possible to undo update?

– pb. – 2015-09-30T09:18:52.350

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. – 2015-09-30T11:41:05.207

Here is the list of last updates: http://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. – 2015-09-30T13:48:53.207

Could be a kernel issue, see here: https://www.mail-archive.com/kernel-packages@lists.launchpad.net/msg137077.html

– Philipp R. – 2015-09-30T14:14:08.017

Thank you so much. I have done downgrade and now is OK. solved! – pb. – 2015-10-01T14:43:29.823

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)

chinacat

Posted 2015-09-29T15:04:42.540

Reputation: 11

Why are you posting an answer you don't endorse? – DavidPostill – 2015-10-03T22:14:07.157

1Because it's useful. – Stavros Korokithakis – 2015-10-20T14:34:41.830

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

jtpereyda

Posted 2015-09-29T15:04:42.540

Reputation: 2 079

For me this was the issue – Eduard Florinescu – 2015-10-27T17:22:48.780