11 |
#include <stdexcept> |
#include <stdexcept> |
12 |
typedef std::vector<unsigned char> UCVector; |
typedef std::vector<unsigned char> UCVector; |
13 |
|
|
14 |
#ifndef _WINDOWS // |
#ifndef _MSC_VER // |
15 |
inline void Sleep(int x) { usleep(x*1000);} |
inline void Sleep(int x) { usleep(x*1000);} |
16 |
#include <termios.h> |
#include <termios.h> |
17 |
#endif |
#endif |
19 |
|
|
20 |
class CSerial |
class CSerial |
21 |
{ |
{ |
22 |
#ifdef _WINDOWS |
#ifdef _MSC_VER |
23 |
HANDLE mComport; |
HANDLE mComport; |
24 |
DCB mDcbRestore; |
DCB mDcbRestore; |
25 |
#else |
#else |
42 |
int readByte(); |
int readByte(); |
43 |
void writeByte(unsigned char out); |
void writeByte(unsigned char out); |
44 |
|
|
45 |
#ifdef _WINDOWS |
#ifdef _MSC_VER |
46 |
COMSTAT getComstat() const; |
COMSTAT getComstat() const; |
47 |
#endif |
#endif |
48 |
int bytesReady() const; |
int bytesReady() const; |
57 |
protected: |
protected: |
58 |
|
|
59 |
void printByte(char* description, unsigned char byte); |
void printByte(char* description, unsigned char byte); |
60 |
#ifdef _WINDOWS |
#ifdef _MSC_VER |
61 |
void openWindows(); |
void openWindows(); |
62 |
#else |
#else |
63 |
void openLinux(); |
void openLinux(); |