When I use dual serial USB ports, the == operator does not appear to distinguish between Serial and SerialUSB1, as illustrated in the code below.
Although there are workarounds, things would be cleaner and easier if this worked properly. For example, if I have a #defined DEBUG_PORT that may point either to Serial or to SerialUSB1, I may wish to test which one is currently mapped.
Frankly, I would prefer it if all serial ports had a public Name attribute.
Code:
// Compile this for USB type = dual serial
void setup()
{
Serial.begin(9600);
SerialUSB1.begin(115200);
if (Serial == SerialUSB1)
Serial.println("Serial and SerialUSB1 think they are the same device."); // This is what is printed
else
Serial.println("Serial and SerialUSB1 are recognized as different."); // This is what is expected
}
void loop()
{}
Although there are workarounds, things would be cleaner and easier if this worked properly. For example, if I have a #defined DEBUG_PORT that may point either to Serial or to SerialUSB1, I may wish to test which one is currently mapped.
Frankly, I would prefer it if all serial ports had a public Name attribute.