7 |
#pragma once |
#pragma once |
8 |
|
|
9 |
#include <vector> |
#include <vector> |
10 |
|
#include <string> |
11 |
|
#include <stdexcept> |
12 |
typedef std::vector<unsigned char> UCVector; |
typedef std::vector<unsigned char> UCVector; |
13 |
|
|
14 |
#ifndef _WINDOWS // |
#ifndef _WINDOWS // |
15 |
inline void Sleep(int x) { usleep(x*1000);} |
inline void Sleep(int x) { usleep(x*1000);} |
16 |
|
#include <termios.h> |
17 |
#endif |
#endif |
18 |
|
|
19 |
|
|
24 |
DCB mDcbRestore; |
DCB mDcbRestore; |
25 |
#else |
#else |
26 |
int mFiledescriptor; |
int mFiledescriptor; |
27 |
|
termios mOldtio; |
28 |
#endif |
#endif |
29 |
|
|
30 |
char* mPortstr; |
char* mPortstr; |
31 |
int mBitrate; |
int mBitrate; |
32 |
bool mIsopen; |
bool mIsopen; |
33 |
|
|
|
//void printByte(char* description, unsigned char byte); |
|
34 |
public: |
public: |
35 |
CSerial(); |
CSerial(); |
36 |
CSerial(char* port, int bitrate); |
CSerial(char* port, int bitrate); |
37 |
~CSerial(void); |
virtual ~CSerial(void); |
38 |
|
|
39 |
void close(); |
void close(); |
40 |
void open(char* port, int bitrate); |
void open(char* port, int bitrate); |
41 |
|
|
42 |
unsigned char readByte(); |
int readByte(); |
43 |
void writeByte(unsigned char out); |
void writeByte(unsigned char out); |
44 |
|
|
45 |
#ifdef _WINDOWS |
#ifdef _WINDOWS |
56 |
//UCVector readBytes(int maxcount); |
//UCVector readBytes(int maxcount); |
57 |
protected: |
protected: |
58 |
|
|
59 |
|
void printByte(char* description, unsigned char byte); |
60 |
#ifdef _WINDOWS |
#ifdef _WINDOWS |
61 |
void openWindows(); |
void openWindows(); |
62 |
#else |
#else |