Scope
|
#include <SerialConnection.h>
Public Member Functions | |
SerialConnection (const std::wstring &_comstring, const DWORD &_baud=CBR_9600, const BYTE &_bytesize=8, const BYTE &_parity=NOPARITY, const BYTE &_stopbits=ONESTOPBIT) | |
~SerialConnection (void) | |
void | Send (const std::string &_string) |
std::vector< BYTE > | Receive (const uint32_t &_toread, const uint32_t &_waitfor=100) |
Protected Attributes | |
HANDLE | hCom |
BOOL | status |
bool | initialized |
Class around a Win32 API serial connection.
Not thread-safe.
Definition at line 6 of file SerialConnection.h.
scope::SerialConnection::SerialConnection | ( | const std::wstring & | _comstring, |
const DWORD & | _baud = CBR_9600 , |
||
const BYTE & | _bytesize = 8 , |
||
const BYTE & | _parity = NOPARITY , |
||
const BYTE & | _stopbits = ONESTOPBIT |
||
) |
Initializes connection.
Definition at line 7 of file SerialConnection.cpp.
scope::SerialConnection::~SerialConnection | ( | void | ) |
Closes connection.
Definition at line 48 of file SerialConnection.cpp.
void scope::SerialConnection::Send | ( | const std::string & | _string | ) |
send command string over connection
Definition at line 52 of file SerialConnection.cpp.
std::vector< BYTE > scope::SerialConnection::Receive | ( | const uint32_t & | _toread, |
const uint32_t & | _waitfor = 100 |
||
) |
Receive bytes from connection, does only wait 100ms for the bytes to be ready, otherwise throws.
[in] | _toread | no of bytes to read |
[in] | _waitfor | milliseconds to wait (throws if not received all _toread bytes in time) |
Definition at line 59 of file SerialConnection.cpp.
|
protected |
the connection handle
Definition at line 10 of file SerialConnection.h.
|
protected |
current status
Definition at line 13 of file SerialConnection.h.
|
protected |
is connection already initialized?
Definition at line 16 of file SerialConnection.h.