# serial: include/serial/impl/windows.h Source File

serial 1.0 Cross-platform serial port library for C++

- Main Page
- Namespaces
- Data Structures
- Files

- File List
- Globals

All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Defines
include/serial/impl/windows.h
Go to the documentation of this file.

    00001
    00037 #ifndef SERIAL_IMPL_WINDOWS_H
    00038 #define SERIAL_IMPL_WINDOWS_H
    00039
    00040 #include "serial/serial.h"
    00041
    00042 namespace serial {
    00043
    00044 using std::string;
    00045 using std::invalid_argument;
    00046
    00047 using serial::SerialExecption;
    00048 using serial::IOException;
    00049
    00050 class serial::Serial::SerialImpl {
    00051 public:
    00052   SerialImpl (const string &port,
    00053               unsigned long baudrate,
    00054               long timeout,
    00055               bytesize_t bytesize,
    00056               parity_t parity,
    00057               stopbits_t stopbits,
    00058               flowcontrol_t flowcontrol);
    00059
    00060   virtual ~SerialImpl ();
    00061
    00062   void
    00063   open ();
    00064
    00065   void
    00066   close ();
    00067
    00068   bool
    00069   isOpen () const;
    00070
    00071   size_t
    00072   available ();
    00073
    00074   size_t
    00075   read (char* buf, size_t size = 1);
    00076
    00077   size_t
    00078   write (const string &data);
    00079
    00080   void
    00081   flush ();
    00082
    00083   void
    00084   flushInput ();
    00085
    00086   void
    00087   flushOutput ();
    00088
    00089   void
    00090   sendBreak(int duration);
    00091
    00092   void
    00093   setBreak(bool level);
    00094
    00095   void
    00096   setRTS(bool level);
    00097
    00098   void
    00099   setDTR(bool level);
    00100
    00101   bool
    00102   getCTS();
    00103
    00104   bool
    00105   getDSR();
    00106
    00107   bool
    00108   getRI();
    00109
    00110   bool
    00111   getCD();
    00112
    00113   void
    00114   setPort (const string &port);
    00115
    00116   string
    00117   getPort () const;
    00118
    00119   void
    00120   setTimeout (long timeout);
    00121
    00122   long
    00123   getTimeout () const;
    00124
    00125   void
    00126   setBaudrate (unsigned long baudrate);
    00127
    00128   unsigned long
    00129   getBaudrate () const;
    00130
    00131   void
    00132   setBytesize (bytesize_t bytesize);
    00133
    00134   bytesize_t
    00135   getBytesize () const;
    00136
    00137   void
    00138   setParity (parity_t parity);
    00139
    00140   parity_t
    00141   getParity () const;
    00142
    00143   void
    00144   setStopbits (stopbits_t stopbits);
    00145
    00146   stopbits_t
    00147   getStopbits () const;
    00148
    00149   void
    00150   setFlowcontrol (flowcontrol_t flowcontrol);
    00151
    00152   flowcontrol_t
    00153   getFlowcontrol () const;
    00154
    00155 protected:
    00156   void reconfigurePort ();
    00157
    00158 private:
    00159   string port_;               // Path to the file descriptor
    00160   int fd_;                    // The current file descriptor
    00161
    00162   bool isOpen_;
    00163   bool xonxoff_;
    00164   bool rtscts_;
    00165
    00166   long timeout_;              // Timeout for read operations
    00167   unsigned long baudrate_;    // Baudrate
    00168
    00169   parity_t parity_;           // Parity
    00170   bytesize_t bytesize_;       // Size of the bytes
    00171   stopbits_t stopbits_;       // Stop Bits
    00172   flowcontrol_t flowcontrol_; // Flow Control
    00173 };
    00174
    00175 }
    00176
    00177 #endif // SERIAL_IMPL_WINDOWS_H