serialDevice.h

Go to the documentation of this file.
00001 #ifndef SERIAL_DEVICE_H
00002 #define SERIAL_DEVICE_H
00003 
00014 #include "connectionDevice.h"
00015 #include "detect_os.h"
00016 #ifdef Linux
00017 #include <sys/poll.h>
00018 #include <termios.h>
00019 #else
00020 #include <windows.h>
00021 #include <string>
00022 #include <vector>
00023 #endif
00024 
00025 
00029 class SerialDevice : public ConnectionDevice {
00030   int fd;
00031 #ifdef Linux
00032   struct termios sio;           
00033   struct pollfd nfds;           
00034 #else
00035   HANDLE hComm;
00036 #endif
00037 
00038   std::string error_message;
00039   int raw_connect(const char* device, long baudrate);
00040   int raw_setBaudrate(long baudrate);
00041   void raw_flush(void);
00042   void raw_check(int size, long timeout);
00043 
00044 protected:
00045   virtual void raw_disconnect(void);
00046   virtual int raw_send(const char* data, int len);
00047 
00048 public:
00054   SerialDevice(int buffer_size = BufferSize -1);
00055   ~SerialDevice(void);
00056 
00057   const char* what(void);
00058   bool isConnected(void);
00059 
00060 #ifdef Windows
00061   //static std::vector<std::string> getComPorts(void);
00062 #endif
00063 };
00064 
00065 #endif /* !SERIAL_DEVICE_H */
00066 

Generated on Mon Apr 13 22:52:05 2009 by  doxygen 1.5.7.1