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

Thread: Weird program restart, and then Serial doesn't output until button or power cycle

Threaded View

  1. #1
    Senior Member
    Join Date
    Mar 2017
    Location
    Oakland, CA, USA
    Posts
    171

    Weird program restart, and then Serial doesn't output until button or power cycle

    I'd love some help diagnosing this weird issue. It's one of those cases where commenting out code that should have nothing to do with the error makes the code work, but uncommenting it makes the program restart somehow and then `Serial` no longer can send data. Maybe it's something dumb I'm doing? Maybe it's in my interrupt code in the library? I don't know, but it's strange and I want to see if others (who are willing) can duplicate the issue.

    I've found another case where `Serial` output stops working—input works still—but the program keeps running. I'll reference this as maybe being similar (but maybe it isn't) to this (`Serial` can no longer output, but the program keeps working):
    https://forum.pjrc.com/threads/58908...on-a-Teensy-LC

    Here, `Serial` is only being used outside any ISR code. It's only accessed from `setup()` and `loop()`.

    Summary

    This test program is the "main" example for the TeensyDMX library (attached as an INO file). It reads bytes from `Serial` to choose a sub-program that either listens to DMX (Flasher), sends DMX (Chaser), or does nothing (Null). When Flasher is running, it flashes the LED according to the DMX input. Sending 'f' to the program starts this mode and, if there's no DMX input, the LED will turn off. Sending 'c' starts the Chaser mode and the LED will flash once a second. When the program starts, the LED is on because the first mode is the Null program.

    Thus, there's a way to determine the three modes: On for Null, off for Flasher, and brief flashes at 1Hz for Chaser.

    My system:
    Catalina version of Teensyduino, v1.49-beta5
    OS: macOS Mojave, v10.14.6

    Steps to reproduce

    1. Install the TeensyDMX library (latest as of this writing is v4.0.0-beta).
    2. Run the attached program on a Teensy 3.2.
    3. The LED should be on because it starts in the Null mode.
    4. Send 'f' in the serial monitor and note that it switches to the Flasher mode. (The restart also happens when sending a 'c' for Chaser.)
    5. The LED should turn off after a moment to indicate that it's not receiving data. (Or flash at 1Hz if Chaser is running.)
    6. After a short while, the LED will turn back on again, indicating that it returned to the Null mode.
    7. Notice that there's some additional random character that appeared in the serial monitor just before the program restarted. This doesn't always appear, however. Its presence means that the Teensy is sending some serial data? Perhaps one of the characters that `setup()` sends when it restarts?
    8. Also notice that sending additional characters to the program changes the mode (because the LED changes modes) but there's no `Serial` output. No `Serial` output actually only happens about half the time for me, it seems random (racey?).


    The kicker

    The program doesn't seem to crash/restart if the `switch` statement on lines 170-187 is commented out. (Or just comment out the `case '?'` part, lines 80-86.) I can't figure out why. Is there something weird about the produced program size? Is this one of those things where it looks like it's one cause but it's really another? Did I miss something dumb that might actually be obvious in hindsight? Is it some weird interaction with the UART ISR functions (in the TeensyDMX library; there's no `Serial` calls in there). I'm stumped. There's nothing in that `switch` statement that should cause a problem.

    Maybe it's time to go through my UART ISR code again (in the TeensyDMX library)... but I just can't find an issue. I don't expect anyone to debug all that for me, I'd just love it if someone can reproduce the error and perhaps propose something I haven't thought of; this'll prove it's not just my setup. Collective wisdom and all.
    Attached Files Attached Files

Posting Permissions

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