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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 44 - (hide annotations) (download)
Sun Feb 4 21:22:44 2007 UTC (17 years, 3 months ago) by torben
File MIME type: text/plain
File size: 1119 byte(s)
Clean the MFC heavy code, so it at least will compile with G++


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     typedef std::vector<unsigned char> UCVector;
11    
12 torben 44 #ifndef _WINDOWS //
13     inline void Sleep(int x) { usleep(x*1000);}
14     #endif
15    
16    
17 torben 38 class CSerial
18     {
19 torben 44 #ifdef _WINDOWS
20 torben 38 HANDLE mComport;
21     DCB mDcbRestore;
22 torben 44 #else
23     int mFiledescriptor;
24     #endif
25    
26     char* mPortstr;
27 torben 38 int mBitrate;
28     bool mIsopen;
29    
30 torben 44 //void printByte(char* description, unsigned char byte);
31 torben 38 public:
32     CSerial();
33     CSerial(char* port, int bitrate);
34     ~CSerial(void);
35    
36     void close();
37     void open(char* port, int bitrate);
38    
39     unsigned char readByte();
40     void writeByte(unsigned char out);
41    
42 torben 44 #ifdef _WINDOWS
43 torben 38 COMSTAT getComstat() const;
44 torben 44 #endif
45 torben 38 int bytesReady() const;
46     int outQueueSize() const;
47 torben 44 char* getPort() const {return mPortstr;}
48 torben 38 int getBitrate() const {return mBitrate;}
49    
50     bool isOpen() { return mIsopen; }
51    
52     //void writeBytes(UCVector out);
53     //UCVector readBytes(int maxcount);
54     protected:
55 torben 44
56     #ifdef _WINDOWS
57     void openWindows();
58     #else
59     void openLinux();
60     #endif
61 torben 38 };

  ViewVC Help
Powered by ViewVC 1.1.20