/[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

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

Legend:
Removed from v.38  
changed lines
  Added in v.47

  ViewVC Help
Powered by ViewVC 1.1.20