To read and write data, a BSerialPort object must first open one of the serial ports by name. To find the names of all the serial ports on the computer, use the CountDevices() and GetDeviceName() functions:
BSerialPort serial; char devName[B_OS_NAME_LENGTH]; int32 n = 0; for (int32 n = serial.CountDevices()-1; n >= 0; n--) { serial.GetDeviceName(n, devName); if ( serial.Open(devName) > 0 ) .... }
The BSerialPort object communicates with the driver for the port it has open. The driver maintains an input buffer to collect incoming data and a smaller output buffer to hold outgoing data. When the object reads and writes data, it reads from and writes to these buffers.
The serial port drivers, and therefore BSerialPort objects, send and receive data asynchronously only.