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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 43 by torben, Sun Feb 4 20:11:41 2007 UTC revision 46 by torben, Sun Feb 4 23:11:02 2007 UTC
# Line 7  Line 7 
7  #pragma once  #pragma once
8    
9  #include <vector>  #include <vector>
   
10  typedef std::vector<unsigned char> UCVector;  typedef std::vector<unsigned char> UCVector;
11    
12    #ifndef _WINDOWS //
13    inline void Sleep(int x) { usleep(x*1000);}
14    #include <termios.h>
15    #endif
16    
17    
18  class CSerial  class CSerial
19  {  {
20    #ifdef _WINDOWS
21          HANDLE mComport;          HANDLE mComport;
22          DCB mDcbRestore;          DCB mDcbRestore;
23          CString mPortstr;  #else
24            int mFiledescriptor;
25            termios mOldtio;
26    #endif
27            
28            char* mPortstr;
29          int mBitrate;          int mBitrate;
30          bool mIsopen;          bool mIsopen;
31    
 protected:  
         void printByte(char* description, unsigned char byte);  
32  public:  public:
33          CSerial();          CSerial();
34          CSerial(char* port, int bitrate);          CSerial(char* port, int bitrate);
# Line 31  public: Line 40  public:
40          unsigned char readByte();          unsigned char readByte();
41          void writeByte(unsigned char out);          void writeByte(unsigned char out);
42    
43    #ifdef _WINDOWS
44          COMSTAT getComstat() const;          COMSTAT getComstat() const;
45    #endif
46          int bytesReady() const;          int bytesReady() const;
47          int outQueueSize() const;          int outQueueSize() const;
48          CString getPort() const {return mPortstr;}          char* getPort() const {return mPortstr;}
49          int getBitrate() const {return mBitrate;}          int getBitrate() const {return mBitrate;}
50    
51          bool isOpen() { return mIsopen; }          bool isOpen() { return mIsopen; }
# Line 43  public: Line 53  public:
53          //void writeBytes(UCVector out);          //void writeBytes(UCVector out);
54          //UCVector readBytes(int maxcount);          //UCVector readBytes(int maxcount);
55  protected:  protected:
56          void open();          
57            void printByte(char* description, unsigned char byte);
58    #ifdef _WINDOWS
59            void openWindows();
60    #else
61            void openLinux();
62    #endif
63  };  };

Legend:
Removed from v.43  
changed lines
  Added in v.46

  ViewVC Help
Powered by ViewVC 1.1.20