/[H7]/trunk/H7 Server/Serial.h
ViewVC logotype

Annotation of /trunk/H7 Server/Serial.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 34 - (hide annotations) (download)
Wed Jan 31 17:32:22 2007 UTC (17 years, 4 months ago) by hedin
File MIME type: text/plain
File size: 916 byte(s)
Enable selection of which com port to use
1 torben 23 /*
2     * Serial.h & Serial.cpp - (C) 2007 by Torben H. Nielsen
3     *
4     * A wrapper class for communicating with a serial port
5     */
6    
7     #pragma once
8    
9     #include <vector>
10    
11     typedef std::vector<unsigned char> UCVector;
12    
13     class CSerial
14     {
15     HANDLE mComport;
16     DCB mDcbRestore;
17     CString mPortstr;
18     int mBitrate;
19     bool mIsopen;
20    
21     protected:
22     void printByte(char* description, unsigned char byte);
23     public:
24     CSerial();
25     CSerial(char* port, int bitrate);
26     ~CSerial(void);
27    
28     void close();
29 hedin 34 void open(CString port, int bitrate);
30 torben 23
31     unsigned char readByte();
32     void writeByte(unsigned char out);
33    
34    
35     COMSTAT getComstat() const;
36     int bytesReady() const;
37     int outQueueSize() const;
38     CString getPort() const {return mPortstr;}
39     int getBitrate() const {return mBitrate;}
40    
41     bool isOpen() { return mIsopen; }
42    
43     //void writeBytes(UCVector out);
44     //UCVector readBytes(int maxcount);
45     protected:
46     void open();
47     };

  ViewVC Help
Powered by ViewVC 1.1.20