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

Thread: Teensy Serial Differences?

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    15

    Teensy Serial Differences?

    Background: I have two Teensy 3's with RF serial transceivers attached to each to communicate back and forth. One of them REQUIRES the serial communication to use pins 7 and 8 (Serial3 device as indicated on the pinout card).

    Problem: Teensy A (using Serial 1) Can send data to Teensy B (using Serial 3) and Teensy B receives it fine. Teensy B (using Serial 3) can NOT send data to Teensy A (using Serial 1). However, if I switch Teensy B RF device to use Serial 1 instead of Serial 3, it works as intended.

    Earlier Trials: On a single Teensy, I can communicate from Serial 1 to 3 just fine, but not from Serial 3 to Serial 1.

    Code:
    Teensy A:
    Code:
    void setup()
    {
      Serial.begin(9600);
      Serial1.begin(9600);
    }
    
    void loop()
    {
      String stringRead;
      char incomingByte;
      
      if( Serial1.available() > 0 )
      {
        incomingByte = Serial1.read();
        Serial.print(incomingByte);
      }
      
      while (Serial.available()) {
        char c = Serial.read();
        stringRead += c;
      }
      
      if( stringRead.length() > 0 )
      {
        Serial1.print( "Daniel: " );
        Serial1.print( stringRead );
        Serial.print( "Me: " );
        Serial.print( stringRead );
      }
    }
    Teensy B:
    Code:
    void setup()
    {
      Serial.begin(9600);
      Serial3.begin(9600);
    }
    
    void loop()
    {
      String stringRead;
      
      stringRead = gatherRFData(); //Read data from RF communication
      processRFData( stringRead ); //Do something with it
      
      stringRead = gatherLocalData(); //Read data from local Serial (testing)
      processLocalData( stringRead ); //Do something with it
    }
    
    String gatherRFData()
    {
      String result;
      char c;
      
      while( Serial3.available() )
      {
        c = Serial3.read();
        result += c;
      }
      
      return result;
    }
    
    void processRFData( String rfData )
    {
      if( rfData.length() )
      {
        Serial.print( rfData );
      }
    }
    
    String gatherLocalData()
    {
      String result;
      
      while( Serial.available() )
      {
        char c = Serial.read();
        result += c;
      }
      
      return result;
    }
    
    void processLocalData( String localData )
    {
      if( localData.length() > 0 )
      {
        Serial3.print( "Serial 3: " );
        Serial3.print( localData );
        Serial.print( "Me: " );
        Serial.print( localData );
      }
    }

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,956
    Please try 1.15-rc1. Version 1.14 has a bug with Serial2 and Serial3. Maybe you're hitting that bug?

    http://forum.pjrc.com/threads/23777-...te-1-Available

  3. #3
    Junior Member
    Join Date
    Jun 2013
    Posts
    15
    Quote Originally Posted by PaulStoffregen View Post
    Please try 1.15-rc1. Version 1.14 has a bug with Serial2 and Serial3. Maybe you're hitting that bug?

    http://forum.pjrc.com/threads/23777-...te-1-Available
    Thanks, Paul. Works like a charm with the new 1.15-rc1!

Posting Permissions

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