(Edit: Problem solved! See below.)
Hello,
If someone has faced this issue before, or similar, could you please advise me on what may be causing this? Below is a summary of the problem, and below that some more relevat facts.
Thank You in advance!!
-Geof
Summary:
I am using the latest PlatformIO to program a Teensy4 on a long-running big project, which involves use of serial communication (via Serial) to a COM port. Suddenly, for no reason I can think of, when the Teensy4 is plugged in and running the program, I hear the descending "blip blip" that the operation system gives when a device is unplugged, and it repeats every 10.5 seconds (I measured it- it is regular). When this happens, I am unable to establish a COM port link with the Teeny4. The program compiles and uses no dynamic memory allocation (other than what standard Arduino/Teensy functions may already perform).
More details:
* Windows 11
* Using PlatformIO with the Teensy40 framework and Teensy40 environment
* It is a large program that I have been working on / building for several years without issue, even with fast speed serial communications between the Teensy4 and MATLAB. I've reduced array sizes to allow plenty extra heap memory in case.
* I've tried a) a fresh Teensy4 with nothing attached (other than USB to computer), b) rebooting the PC, c) restarting PlatformIO, d) different USB cable, e) different USB port
* For commenting out code I've tried commenting out code. Sometimes with code commented out it stops behaving like this, but with differnet code commented out the error returns. I haven't found any logic between code commented out and not. Though there is one handler that monitors Serial bytes coming in from the PC (essentially checking Serial.available() and running a handler if data has been received). That handler is unchanged for two years. When I comment it out the error disappears. When I comment it out and replace it with a simple Serial.available() check the error still disappears. However with different code commented out, I can have that function uncommented and the program runs fine.
I have not yet tried a different PC or reinstalling PlatformIO. Also I have not yet tried the Arduino IDE, however my program has a complex library and header structure that I'd rather not subject to the Arduino IDE.
Could this be something particular to PlatformIO? I've enjoyed it immensly in the past but it may be that I should try another IDE. I'm curious your thoughts on this.
Again, I really appreciate your help. Can I send a bottle of whisky?
Edit: Problem is solved. I am summarizing what I learned here in case anyone else faces this:
(1) The regular disconnecting was due to the Teensy4 crashing and rebooting due to some fault.
(2) In my case, the error was due to a function that was declared to return an "int", however the body of the function did not return anything.
(3) Also in my case, I was using code that compiled and worked over a year ago, but no longer worked recently. This is because the toolchain has had a substantial update, including using a different compiler, and the new compiler is less tolerant to poor coding such as my (2) above
(4) It is recommended that one address not only the "errors" that the compiler finds, but "warnings" as well, as some of these warnings identify issues that may cause the Teensy4 to crash, even sporadically or seemingly without logic (such as crashes occurring or not occurring due to commenting out different unassociated code)
(5) Tools that can also help identify the cause of a crash include the CrashReport added in Teensyduino 1.54 and the associated "breadcrumbs" feature added in Teensyduino 1.57.
Hello,
If someone has faced this issue before, or similar, could you please advise me on what may be causing this? Below is a summary of the problem, and below that some more relevat facts.
Thank You in advance!!
-Geof
Summary:
I am using the latest PlatformIO to program a Teensy4 on a long-running big project, which involves use of serial communication (via Serial) to a COM port. Suddenly, for no reason I can think of, when the Teensy4 is plugged in and running the program, I hear the descending "blip blip" that the operation system gives when a device is unplugged, and it repeats every 10.5 seconds (I measured it- it is regular). When this happens, I am unable to establish a COM port link with the Teeny4. The program compiles and uses no dynamic memory allocation (other than what standard Arduino/Teensy functions may already perform).
More details:
* Windows 11
* Using PlatformIO with the Teensy40 framework and Teensy40 environment
* It is a large program that I have been working on / building for several years without issue, even with fast speed serial communications between the Teensy4 and MATLAB. I've reduced array sizes to allow plenty extra heap memory in case.
* I've tried a) a fresh Teensy4 with nothing attached (other than USB to computer), b) rebooting the PC, c) restarting PlatformIO, d) different USB cable, e) different USB port
* For commenting out code I've tried commenting out code. Sometimes with code commented out it stops behaving like this, but with differnet code commented out the error returns. I haven't found any logic between code commented out and not. Though there is one handler that monitors Serial bytes coming in from the PC (essentially checking Serial.available() and running a handler if data has been received). That handler is unchanged for two years. When I comment it out the error disappears. When I comment it out and replace it with a simple Serial.available() check the error still disappears. However with different code commented out, I can have that function uncommented and the program runs fine.
I have not yet tried a different PC or reinstalling PlatformIO. Also I have not yet tried the Arduino IDE, however my program has a complex library and header structure that I'd rather not subject to the Arduino IDE.
Could this be something particular to PlatformIO? I've enjoyed it immensly in the past but it may be that I should try another IDE. I'm curious your thoughts on this.
Again, I really appreciate your help. Can I send a bottle of whisky?
Edit: Problem is solved. I am summarizing what I learned here in case anyone else faces this:
(1) The regular disconnecting was due to the Teensy4 crashing and rebooting due to some fault.
(2) In my case, the error was due to a function that was declared to return an "int", however the body of the function did not return anything.
(3) Also in my case, I was using code that compiled and worked over a year ago, but no longer worked recently. This is because the toolchain has had a substantial update, including using a different compiler, and the new compiler is less tolerant to poor coding such as my (2) above
(4) It is recommended that one address not only the "errors" that the compiler finds, but "warnings" as well, as some of these warnings identify issues that may cause the Teensy4 to crash, even sporadically or seemingly without logic (such as crashes occurring or not occurring due to commenting out different unassociated code)
(5) Tools that can also help identify the cause of a crash include the CrashReport added in Teensyduino 1.54 and the associated "breadcrumbs" feature added in Teensyduino 1.57.
Last edited: