win.h
Go to the documentation of this file.
00001 
00037 #if defined(_WIN32)
00038 
00039 #ifndef SERIAL_IMPL_WINDOWS_H
00040 #define SERIAL_IMPL_WINDOWS_H
00041 
00042 #include "serial/serial.h"
00043 
00044 #include "windows.h"
00045 
00046 namespace serial {
00047 
00048 using std::string;
00049 using std::wstring;
00050 using std::invalid_argument;
00051 
00052 using serial::SerialException;
00053 using serial::IOException;
00054 
00055 class serial::Serial::SerialImpl {
00056 public:
00057   SerialImpl (const string &port,
00058               unsigned long baudrate,
00059               bytesize_t bytesize,
00060               parity_t parity,
00061               stopbits_t stopbits,
00062               flowcontrol_t flowcontrol);
00063 
00064   virtual ~SerialImpl ();
00065 
00066   void
00067   open ();
00068 
00069   void
00070   close ();
00071 
00072   bool
00073   isOpen () const;
00074 
00075   size_t
00076   available ();
00077   
00078   bool
00079   waitReadable (uint32_t timeout);
00080 
00081   void
00082   waitByteTimes (size_t count);
00083 
00084   size_t
00085   read (uint8_t *buf, size_t size = 1);
00086 
00087   size_t
00088   write (const uint8_t *data, size_t length);
00089 
00090   void
00091   flush ();
00092 
00093   void
00094   flushInput ();
00095 
00096   void
00097   flushOutput ();
00098 
00099   void
00100   sendBreak (int duration);
00101 
00102   void
00103   setBreak (bool level);
00104 
00105   void
00106   setRTS (bool level);
00107 
00108   void
00109   setDTR (bool level);
00110 
00111   bool
00112   waitForChange ();
00113 
00114   bool
00115   getCTS ();
00116 
00117   bool
00118   getDSR ();
00119 
00120   bool
00121   getRI ();
00122 
00123   bool
00124   getCD ();
00125 
00126   void
00127   setPort (const string &port);
00128 
00129   string
00130   getPort () const;
00131 
00132   void
00133   setTimeout (Timeout &timeout);
00134 
00135   Timeout
00136   getTimeout () const;
00137 
00138   void
00139   setBaudrate (unsigned long baudrate);
00140 
00141   unsigned long
00142   getBaudrate () const;
00143 
00144   void
00145   setBytesize (bytesize_t bytesize);
00146 
00147   bytesize_t
00148   getBytesize () const;
00149 
00150   void
00151   setParity (parity_t parity);
00152 
00153   parity_t
00154   getParity () const;
00155 
00156   void
00157   setStopbits (stopbits_t stopbits);
00158 
00159   stopbits_t
00160   getStopbits () const;
00161 
00162   void
00163   setFlowcontrol (flowcontrol_t flowcontrol);
00164 
00165   flowcontrol_t
00166   getFlowcontrol () const;
00167 
00168   void
00169   readLock ();
00170 
00171   void
00172   readUnlock ();
00173 
00174   void
00175   writeLock ();
00176 
00177   void
00178   writeUnlock ();
00179 
00180 protected:
00181   void reconfigurePort ();
00182 
00183 private:
00184   wstring port_;               // Path to the file descriptor
00185   HANDLE fd_;
00186 
00187   bool is_open_;
00188 
00189   Timeout timeout_;           // Timeout for read operations
00190   unsigned long baudrate_;    // Baudrate
00191 
00192   parity_t parity_;           // Parity
00193   bytesize_t bytesize_;       // Size of the bytes
00194   stopbits_t stopbits_;       // Stop Bits
00195   flowcontrol_t flowcontrol_; // Flow Control
00196 
00197   // Mutex used to lock the read functions
00198   HANDLE read_mutex;
00199   // Mutex used to lock the write functions
00200   HANDLE write_mutex;
00201 };
00202 
00203 }
00204 
00205 #endif // SERIAL_IMPL_WINDOWS_H
00206 
00207 #endif // if defined(_WIN32)


serial
Author(s): William Woodall , John Harrison
autogenerated on Sat Jan 21 2017 03:55:47