Scope
scope::SerialConnection Class Reference

#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
 

Detailed Description

Class around a Win32 API serial connection.

Not thread-safe.

Definition at line 6 of file SerialConnection.h.

Constructor & Destructor Documentation

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.

Member Function Documentation

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.

Parameters
[in]_toreadno of bytes to read
[in]_waitformilliseconds to wait (throws if not received all _toread bytes in time)

Definition at line 59 of file SerialConnection.cpp.

Member Data Documentation

HANDLE scope::SerialConnection::hCom
protected

the connection handle

Definition at line 10 of file SerialConnection.h.

BOOL scope::SerialConnection::status
protected

current status

Definition at line 13 of file SerialConnection.h.

bool scope::SerialConnection::initialized
protected

is connection already initialized?

Definition at line 16 of file SerialConnection.h.


The documentation for this class was generated from the following files: