Syntax
operator bool();
ContentsIndex
PreviousUpNext
UARTClass::bool Operator
UARTClass Class | Example
Syntax
operator bool();
Description

Check if the serail port is ready. 

For Serial (USB port), it will check DTR signal to know that if the USB CDC serial connection is established or not (i.e. return true if PC side application opens the corresponding COM port, and return false if the application closes the port). 

For Serial1, it will always return true.

Returns

For Serial

  • true: DTR is 1, PC application has opened the COM port.
  • false: DTR is 0, no application open the COM port.
For Serial1

  • always return true
 

Example
void setup() 
{
    Serial.begin(9600);
    while (!Serial)
    {
        ; // wait for serial port to connect. 
    }
}
File

UARTClass.h

Class