/[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 54 by torben, Mon Feb 5 10:10:18 2007 UTC revision 77 by torben, Wed Jun 4 13:08:30 2008 UTC
# Line 9  Line 9 
9  #include <vector>  #include <vector>
10  #include <string>  #include <string>
11  #include <stdexcept>  #include <stdexcept>
 typedef std::vector<unsigned char> UCVector;  
12    
13  #ifndef _MSC_VER //  #ifndef _MSC_VER //
14  inline void Sleep(int x) { usleep(x*1000);}  inline void Sleep(int x) { usleep(x*1000);}
# Line 34  public: //public enumerations Line 33  public: //public enumerations
33                  Baud57600,                  Baud57600,
34                  Baud115200                  Baud115200
35          };          };
 private: // member vars  
 #ifdef _MSC_VER  
         HANDLE mComport;  
         DCB mDcbRestore;  
 #else  
         int mFiledescriptor;  
         termios mOldtio;  
 #endif  
           
         char* mPortstr;  
         Baudrate mBitrate;  
         bool mIsopen;  
36    
37  public: //public methods  public: //public methods
38          CSerial();          CSerial();
# Line 58  public: //public methods Line 45  public: //public methods
45          int readByte();          int readByte();
46          void writeByte(unsigned char out);          void writeByte(unsigned char out);
47    
48            void writeBytes(unsigned char* buf, unsigned int len);
49            int readBytes(unsigned char* buf, unsigned int maxLen);
50    
51  #ifdef _MSC_VER  #ifdef _MSC_VER
52          COMSTAT getComstat() const;          COMSTAT getComstat() const;
53  #endif  #endif
# Line 68  public: //public methods Line 58  public: //public methods
58    
59          bool isOpen() { return mIsopen; }          bool isOpen() { return mIsopen; }
60    
         //void writeBytes(UCVector out);  
         //UCVector readBytes(int maxcount);  
61  protected:  protected:
62                    
63          void printByte(char* description, unsigned char byte);          void printByte(char* description, unsigned char byte);
64          int convertBaudrate(Baudrate rate);          int convertBaudrate(Baudrate rate);
65    
66  #ifdef _MSC_VER  #ifdef _MSC_VER
67          void openWindows();          void openWindows();
68            int readBytesWindows(unsigned char*buf, unsigned int maxLen);
69            void writeBytesWindows(unsigned char* buf, unsigned int len);
70  #else  #else
71          void openLinux();          void openLinux();
72            int readBytesLinux(unsigned char* buf, unsigned int maxLen);
73            void writeBytesLinux(unsigned char* buf, unsigned int len);
74  #endif  #endif
75    
76    
77    private: // member vars
78    #ifdef _MSC_VER
79            HANDLE mComport;
80            DCB mDcbRestore;
81    #else
82            int mFiledescriptor;
83            termios mOldtio;
84    #endif
85            
86            char* mPortstr;
87            Baudrate mBitrate;
88            bool mIsopen;
89  };  };

Legend:
Removed from v.54  
changed lines
  Added in v.77

  ViewVC Help
Powered by ViewVC 1.1.20