Serial communication on Win32 platforms involves the following functions/structures:
COMMTIMEOUTS - for setting up your, you guessed it, time outs for reads and writes
DCB - structure containing all the communications options for your port
CreateFile() - creates a file for I/O
WriteFile() - writes data to the port
ReadFile() - reads data from the port
GetCommState() - retrieves information (using a DCB) about the port
SetCommState() - sets port options (again with a DCB)
GetCommTimeouts() - uses COMMTIMEOUTS to retrieve timeout information
SetCommTimeouts() - sets timeout options via a COMMTIMEOUTS structure
And now some examples of using these functions (this is from a class I wrote):
SerialConnection::SerialConnection(string port_name, BaudRate baud, Parity parity, DataBits data_bits, StopBits stop_bits)
{
old_dcb = new DCB; //Pointers for Get/SetCommState
new_dcb = new DCB;
COMMTIMEOUTS timeout;
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.