Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: Serial print lockup

  1. #1
    Senior Member
    Join Date
    Dec 2016
    Posts
    127

    Serial print lockup

    The serial printing works for about 5 seconds and then printing locks up. The Teensy is still running, but nothing prints, suggesting it is the at the PC end. This started out in a big program, but remains after paring down to the trivial level. What am I doing wrong???

    Environment:
    Teensy 3.6 unmodified, no additional hardware
    Arduino 1.8.9 fresh from the download
    Teensyduino 1.46 fresh from the download
    Ubuntu 18.4 64-bit
    Program:
    Code:
    // EVALCodec1.ino  Bob Larkin 24 June 2019
    
    #if (TEENSYDUINO < 146)
    #error "Teensydunio < 1.46"
    #endif
      
    /* Print j++ added to LED Blink, Teensyduino Tutorial #1 */
    const int ledPin = 13;
    uint16_t j;
    
    void setup() {
      pinMode(ledPin, OUTPUT);
      Serial.begin(9600);
      delay(1000);   // For serial print
      j=0;
    }
    
    void loop() {
      digitalWrite(ledPin, HIGH);   // set the LED on
      delay(1000);                  // wait for a second
      digitalWrite(ledPin, LOW);    // set the LED off
      delay(1000);                  // wait for a second
      Serial.print(j++);
    }
    This will print "01" corresponding to about 5 seconds. Changing the blink delays will change the number of j values printed, but it is always about 5 seconds worth. The blink of the LED continues on and on. What is the deal?? Thanks, Bob

  2. #2
    Senior Member
    Join Date
    Dec 2016
    Posts
    127
    Here are the tool settings
    Click image for larger version. 

Name:	ScreenNoPrint.gif 
Views:	15 
Size:	83.6 KB 
ID:	16870

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,111
    I'm running it here on Ubuntu 18.04. Can't reproduce the problem. As you can see in this screenshot, it's been running for about 1 minute without issues.

    Click image for larger version. 

Name:	sc.jpg 
Views:	8 
Size:	78.5 KB 
ID:	16871

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,111
    Here's some suggestions to try.

    1: Make sure you have the latest udev rules file installed. It was updated several weeks ago for a change Ubuntu pushed in updates.

    https://www.pjrc.com/teensy/49-teensy.rules

    2: Check if ModemManager is running or even installed. If it is, and you don't use a modem, get rid of ModemManager. With apt-get, you might need a "purge" option or something? Usually when serial works for a few seconds then fails, it's ModemManager interfering. Linux is the only system that allows more than 1 program to open a port, but it doesn't actually have the code to allow 2 to really work correctly at the same time (as is commonly done in HID drivers). Theoretically any other program on your PC could also be interfering, but ModemManager is the usual culprit.

    3: Try adding a "while (!Serial) ;" near the beginning of setup(), so your program doesn't access the port until Linux is ready. So far this sort of problem confusing the driver has only been reported on Raspberry Pi, but who knows, maybe it could be an issue?

  5. #5
    Senior Member
    Join Date
    Dec 2016
    Posts
    127
    SOLVED!!

    Quote Originally Posted by PaulStoffregen View Post
    Here's some suggestions to try.

    1: Make sure you have the latest udev rules file installed. It was updated several weeks ago for a change Ubuntu pushed in updates.

    https://www.pjrc.com/teensy/49-teensy.rules
    ...snip
    The update to the udev rule cured the problem. Many thanks, Paul, for getting me going again. Bob

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •