Easy way to switch or re-direct between serial ports.

Status
Not open for further replies.

t3andy

Well-known member
Easy way to switch or re-direct between serial ports. :confused:

I have numerous serial port statements like Serial.println("xxxx"); scattered in my code. Is there an easy way "to program"
the code to re-direct the serial port statements to another serial port? For instance change, USB Serial.println("xxxx") to Serial1.println("xxxx");

Of course, an IDE "find/search and replace" will do the job BUT having no IDE presents a problem. I am using a serial CLI (command line interface)
hooked-up to the Teensy 3 via serial port.


Any ideas welcomed ?
 
Maybe something like this?

Code:
void setup()
{
  Serial1.begin(9600);
  Serial2.begin(38400);
}

Stream &mySerial = Serial2;

void loop()
{
  mySerial.println("Hello World");
}
 
Status
Not open for further replies.
Back
Top