Teensy port, IDE 2.0.2 Serial Monitor and resetFunc()


Well-known member
Using the code I posted below for a minimal example, with my Serial Monitor (on the Teensy 4.1 port) after exercising a reset the SM gets into a funky state where it only sends every other line to the Teensy.
The code below should echo whatever you type, line by line. Unless you type "reset", then it will emit "resetting..." and execute a reset.
After the actual reset finishes, only every second line will echo. I only tested this with T4.1 because I don't have any older versions here.

- Wes, W5ZZO

#define MAX_INPUT 256
int buffCount=0;
unsigned char inputBuff[256];

void setup() {
  // put your setup code here, to run once:

void loop() {
  // put your main code here, to run repeatedly:
  if(Serial.available()>0) {handleConsoleInput();}

void handleConsoleInput() {   // this should not be called when Serial has no chars available
  unsigned char ch=Serial.read();
  if(!(ch&0x80)) { // filter to remove Serial garbage sometime found on Due board
    if(buffCount>=(MAX_INPUT-2)) {
      ch=inputBuff[buffCount]='\n'; // force a line end
    inputBuff[++buffCount]='\0';  // ensure null termination
    if(ch=='\n') {
//        if(g.echoInput) {Serial.print((char *)&g.inputBuff[0]);}
      Serial.print((char *)inputBuff);
      if(strcmp(&inputBuff[0], "reset\n")==0) {
        void(* resetFunc) (void) = 0;//declare reset function at address 0
        resetFunc(); //call reset  
    } // if(!(ch&0x80))
That's it. I had 1.57.1 installed, but the version for the teensy monitor was still 1.57.0, why IDK. The file attachment fixed the issue.

- Wes