Rilevare porta seriale

Non voglio fare il pedante, però almeno leggetela la reference.

Description
Indicates if the specified Serial port is ready.
On the Leonardo, if (Serial) indicates wether or not the USB CDC serial connection is open. For all other instances, including if (Serial1) on the Leonardo, this will always returns true.
This was introduced in Arduino 1.0.1.

Returns
boolean : returns true if the specified serial port is available. This will only return false if querying the Leonardo's USB CDC serial connection before it is ready.

Da notare che la variabile Serial è stata introdotta specificamente per la Leonardo, il suo uso primario è sapere se c'è una connessione USB CDC attiva.

Definizione di "Serial" nel core.

Serial_::operator bool() {
	bool result = false;
	if (_usbLineInfo.lineState > 0) 
		result = true;
	delay(10);
	return result;
}

Serial_ Serial;