USB Serial dying on Ubuntu 18.04

Status
Not open for further replies.

cermak

Member
Hi!
Recently (past week), I have been _consistently_ (3 separate machines) observing problems with Serial communication over USB on Ubuntu 18.04. My sketch is below, and have tested each computer using a fresh install of Arduino 1.8.13 and Teensyduino 1.53, and have also copied the udev rules, and apt purged modemmanager. I have obtained the same results using a Teensy 3.2 and 3.6.

The issue is that when I run the following code to just print out one number per millisecond, I get 481 to 569 printed out, and then the data stops.
Code:
void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.println(millis());
  delay(1); 
}

If I unplug the teensy and replug it (or otherwise reboot it), I get a variable number of lines but it typically starts and stops in the 400 and 500 millisecond range.

I have modified the code to say blink when touchRead(0) exceeds a value; this continues to happen, demonstrating that at least my code is still running even when the serial stops.

Additionally, I run into the same issue using pyserial, suggesting this is a serial port related issue.

In my minimal experimentation on other systems, I have not observed this issue on windows.

Is anyone aware of any recent Ubuntu updates, changes to the udev rules, or other changes that might explain this behavior? In the past I've never had these issues, although my Teensy-related work has been minimal over the last two months or so, so I'm hardpressed to pinpoint exactly when this change happened other than within the last couple months.

Any help would be very very much appreciated!!
 
Are you using the Arduino Serial Monitor to view the incoming data, or some other software?

Hi Paul,
I've used both the Arduino serial monitor to observe this problem and my own simple viewer in python using the pyserial module (code below). When I run the python serial monitor (at least a second after plugging in the Teensy), I never observe any output. Are there any other monitors you'd suggest trying? Thanks!


Code:
import serial

ser = serial.Serial('/dev/ttyACM0', baudrate = 1e6, timeout=3)

while True:
    data = ser.read(100).decode("utf-8")
    print(data, end='')
 
I can't really help with Python code. But I did run it here on Ubuntu 18.04. As you can see in this screen capture after 1 minute, it runs perfectly fine when I test on Ubuntu 18.04, x86-64 bit.

sc.png

It's still running and just passed 200000, no signs of stopping.

I don't know why it's stopping on your 3 systems. I can't reproduce the problem.
 
I have seen this problem on older sketches. I just ran your sketch on my T3.2 1.8.13/1.53 on Ubuntu 18.04 and it hangs after printing 516. If I add while(!Serial); after Serial.begin(), the sketch does not hang.
 
Status
Not open for further replies.
Back
Top