1 |
#pragma once
|
2 |
|
3 |
#include <vector>
|
4 |
|
5 |
typedef std::vector<unsigned char> UCVector;
|
6 |
|
7 |
class CSerial
|
8 |
{
|
9 |
HANDLE mComport;
|
10 |
DCB mDcbRestore;
|
11 |
CString mPortstr;
|
12 |
int mBitrate;
|
13 |
bool mIsopen;
|
14 |
|
15 |
protected:
|
16 |
void printByte(char* description, unsigned char byte);
|
17 |
void open();
|
18 |
|
19 |
public:
|
20 |
CSerial();
|
21 |
CSerial(char* port, int bitrate);
|
22 |
~CSerial(void);
|
23 |
|
24 |
void close();
|
25 |
void open(CString port, int bitrate);
|
26 |
|
27 |
unsigned char readByte();
|
28 |
void writeByte(unsigned char out);
|
29 |
|
30 |
|
31 |
COMSTAT getComstat() const;
|
32 |
int bytesReady() const;
|
33 |
int outQueueSize() const;
|
34 |
CString getPort() const {return mPortstr;}
|
35 |
int getBitrate() const {return mBitrate;}
|
36 |
|
37 |
bool isOpen() { return mIsopen; }
|
38 |
|
39 |
};
|