Using Crash Reports

I have a Teensy (4.1) application that will periodically reset and I'm trying to figure out what might be causing the reset. However when I attempt to use code that includes CrashReport the Teensy's associated serial port on my computer never becomes available (as if it's not connected). Immediately after I upload an application to Teensy that uses CrashReport I lose serial comm and it won't reappear until I "hard" reset the board (hold pin down for 16sec) and then load code that doesn't contain CrashReport.
I have tried a few different iterations of the following in the setup() function, for example I have tried removing the while loop as it appears to be stuck in an infinite loop or I have it wait less time etc..

Serial.begin(115200);
while (!Serial); // wait for serial monitor open
if (CrashReport) {
Serial.print(CrashReport);
delay(5000);
}

For the environment I'm using Visual Micro/Visual Studio on a Windows 11 Pro VM (MAC w/Parallels), to date I haven't had any issues using this environment.
I must be missing/misunderstanding something, any ideas?
 
Change while (!Serial); // wait for serial monitor open to while (!Serial && (millis() < 3000)); // wait for serial monitor open for 3 seconds only
 
If there is a Crash when not connected code like that will clear it unseen however.

To run unconnected until the Crash - then recognizing it by restarts, Then connect it to a Host with SerMon and code like this will then spit it out without it getting lost.

Code:
// Once called CrashReport data is cleared - even if not usably printed.
// Code like below should only test CrashReport when Serial is online
// Also note an SD card or other usably permanent 'Stream' can be used
if ( Serial && CrashReport) {
 
Last edited:
The issue happens when either calling CrashReport or calling Serial.print(CrashReport). After running a test last night Teensy restarted but when I upload code that calls if(CrashReport){ Serial.print...the teensy goes into limbo and there is isn't any serial comm available and the only way to recover is to hard reset the unit and upload code without CrashReport. The only change to the code that was running when it restarted was the addition of if(CrashReport), the serial comm has not presented any issues so I assume it should be available. Is there anything else required by Teensy to run CrashReport?
 
I don't see how this is at all possible. You say the serial port never shows up but from the code you posted, the while (!Serial); line would block until an app connected to the com port. So the code checking CrashReport wouldn't even get executed until the serial port was connected to something.

There must be something else in your code that is the problem, so please post a complete program that shows the issue (and use the code tags).
 
I tried an empty project (Visual Micro teensy extension for Visual Studio) and only included printing the CrashReport and got the same results (serial port in limbo on the Teensy). So I created an empty sketch in Arduino and did the same and it runs fine, so I'm guessing there must be an issue with Visual Micro and using CrashReport. I think I have a way to print CrashReport now, thanks for the suggestions.
 
Just out of curiosity will loading a program that calls CrashReport print a previous programs "crashes", i.e. does the values written by the fault handler remain after new code loads?
 
Only if the Teensy isn't powered off in-between. The CrashReport data is in volatile memory at the end of RAM2.
 
Note: if power is removed from the Teensy any CrashReport findings will be lost. The data for that only survives across powered warm restarts.

Opps - wrote long ago and left without posting ...
 
Back
Top