#include "comport.hpp" void someFunction () { COMPort aPort ("COM2"); aPort.setBitRate (COMPort::br9600); aPort.setParity (COMPort::Even); aPort.setDataBits (COMPort::db7); aPort.setStopBits (COMPort::sb1); while (1) { char aData = aPort.read (); // do processing . . . } } // end someFunction
The code above opens serial port COM2 and configures it to 9600 bps baud rate, even parity, 7 data bits, 1 stop bit. Then data is read and processed in continuos loop.
In case of problems when writtin to COM port, try change hardware handshake mode by calling function setHandshaking (false).
Back to win32 source code downloads