I recently experienced a Teensy crash/reset while controlling a motor on a lathe. Quite often, there isn't even a console attached, just an ILI9341. Trying to install bread crumbs and whatnot in my code now.
I want to both write to serial AND to overwrite the whole display with the CrashReport output. I think a code crash is important enough to do this. This fault is infrequent, having only happened once in 18 months, so if it's a code problem I want a fighting chance at capturing it.
I'm using @KurtE 's ILI9341_t3n driver. It's been a while since I've set something like this up. The example crash report file prints out character by character, until the logfile is empty. Is the correct method to type out a single character on the display simply
? Does
mean that characters that go past the 320 pixels in x, will be automatically wrapped to the next line?
Here's what I have written so far. I call this routine to check if a crash has occurred, any hopefully it would print out the CrashReport and any bread crumbs I set. The LittleFS and tft libraries have been imported in other files, don't want to import them twice.
I logged the data to a small part of the flash, so that it would be retrievable, without modifying units in the field. If I were starting from scratch, maybe I'd use an SD card.
Obviously this routine won't work, if the display routines died, but I'm hoping not! A display is always present, but a serial console isn't. I obviously don't have a routine to delete the file, I'll need to write that... If there's a crash report, I'd like to know it happened and the operator knows something serious occurred.
Grateful for any additional insight. This is a tough nut to crack. The application has never crashed before, including when I was operating it at rates that were 17 times faster on the lathe. I'd like to isolate the problem before releasing this latest branch of my code... Thanks.
I want to both write to serial AND to overwrite the whole display with the CrashReport output. I think a code crash is important enough to do this. This fault is infrequent, having only happened once in 18 months, so if it's a code problem I want a fighting chance at capturing it.
I'm using @KurtE 's ILI9341_t3n driver. It's been a while since I've set something like this up. The example crash report file prints out character by character, until the logfile is empty. Is the correct method to type out a single character on the display simply
Code:
tft.drawFontChar( char c);
Code:
tft.setTextWrap(true);
Here's what I have written so far. I call this routine to check if a crash has occurred, any hopefully it would print out the CrashReport and any bread crumbs I set. The LittleFS and tft libraries have been imported in other files, don't want to import them twice.
I logged the data to a small part of the flash, so that it would be retrievable, without modifying units in the field. If I were starting from scratch, maybe I'd use an SD card.
C++:
/* This takes over the tft screen if there's a major crash logged by the Teensy. Such a crash is a
big deal and we want to know it happened. Print out message to serial console if attached and
take over the tft screen entirely.
*/
void crashreporter() {
char c;
File logFile = myfs.open("crashlog.txt");
if (logFile) {
tft.fillScreen(thisGREY);
tft.setCursor(0,0);
tft.setTextColor(ILI9341_WHITE);
tft.setTextDatum(TL_DATUM);
tft.setFont(Arial_10); // Make text small enought to fit the message
tft.setTextWrap(true);
while (logFile.available()) {
c = logFile.read();
Serial.write(c);
tft.drawFontChar(c);
}
while(1); // hang forever
}
else {
Serial.println("Sorry, no crashlog.txt stored");
}
}
Obviously this routine won't work, if the display routines died, but I'm hoping not! A display is always present, but a serial console isn't. I obviously don't have a routine to delete the file, I'll need to write that... If there's a crash report, I'd like to know it happened and the operator knows something serious occurred.
Grateful for any additional insight. This is a tough nut to crack. The application has never crashed before, including when I was operating it at rates that were 17 times faster on the lathe. I'd like to isolate the problem before releasing this latest branch of my code... Thanks.
Last edited:
