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

Thread: Teensy port, IDE 2.0.2 Serial Monitor and resetFunc()

  1. #1

    Teensy port, IDE 2.0.2 Serial Monitor and resetFunc()

    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

    Code:
    #define MAX_INPUT 256
    int buffCount=0;
    unsigned char inputBuff[256];
    
    void setup() {
      Serial.begin(9600);
      // 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
        inputBuff[buffCount]=ch;
        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);
          buffCount=0;
          if(strcmp(&inputBuff[0], "reset\n")==0) {
            Serial.print("resetting...");
            void(* resetFunc) (void) = 0;//declare reset function at address 0
            resetFunc(); //call reset  
            }
          }
        } // if(!(ch&0x80))
      }

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,422
    Quote Originally Posted by W5ZZO View Post
    after exercising a reset the SM gets into a funky state where it only sends every other line to the Teensy.
    Maybe you're experiencing this bug?

    https://forum.pjrc.com/threads/71370...l=1#post316273

  3. #3
    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

Posting Permissions

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