/[H7]/branches/linux-serial/Serial.h
ViewVC logotype

Annotation of /branches/linux-serial/Serial.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 38 - (hide annotations) (download)
Thu Feb 1 10:03:52 2007 UTC (17 years, 3 months ago) by torben
Original Path: trunk/PIC/Testprogram/Serial.h
File MIME type: text/plain
File size: 914 byte(s)
Added test-program for  serial communication module
1 torben 38 /*
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     void open(char* port, int bitrate);
30    
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