Renaming serial ports on Arduino Zero

this works on Arduino Zero for the Serial1

HardwareSerial & Emic = Serial1;

But not for the SerialUSB

HardwareSerial & Terminal = SerialUSB;

It give a compilation error :

invalid initialization of reference of type 'HardwareSerial&' from expression of type 'Serial_'

Any Idea why ?

HardwareSerial & Emic = Serial1;
HardwareSerial & Terminal = SerialUSB;

void setup ()
  {
  Emic.begin (9600);
  Terminal.begin (115200);
  }  // end of setup
  
void loop ()
  {
  Terminal.println ("Hi there!");
  }  // end of loop

Thx

Because the SerialUSB is not a member of HardwareSerial, it's the USB device one. You should change the type of Terminal to "Serial_" (with underscore)

It works using :

Serial_ & Terminal = SerialUSB;

Thanks a lot !

Another method used a lot is to define some macro :

#define Emic         Serial1
#define Terminal    SerialUSB