2 * \file serial/impl/windows.h
3 * \author William Woodall <wjwwood@gmail.com>
4 * \author John Harrison <ash@greaterthaninfinity.com>
11 * Copyright (c) 2012 William Woodall, John Harrison
13 * Permission is hereby granted, free of charge, to any person obtaining a
14 * copy of this software and associated documentation files (the "Software"),
15 * to deal in the Software without restriction, including without limitation
16 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 * and/or sell copies of the Software, and to permit persons to whom the
18 * Software is furnished to do so, subject to the following conditions:
20 * The above copyright notice and this permission notice shall be included in
21 * all copies or substantial portions of the Software.
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 * DEALINGS IN THE SOFTWARE.
31 * \section DESCRIPTION
33 * This provides a windows implementation of the Serial class interface.
37 #ifndef SERIAL_IMPL_WINDOWS_H
38 #define SERIAL_IMPL_WINDOWS_H
40 #include "serial/serial.h"
47 using std::invalid_argument;
49 using serial::SerialExecption;
50 using serial::IOException;
52 class serial::Serial::SerialImpl {
54 SerialImpl (const string &port,
55 unsigned long baudrate,
59 flowcontrol_t flowcontrol);
61 virtual ~SerialImpl ();
76 read (uint8_t *buf, size_t size = 1);
79 write (const uint8_t *data, size_t length);
91 sendBreak (int duration);
94 setBreak (bool level);
118 setPort (const string &port);
124 setTimeout (Timeout &timeout);
130 setBaudrate (unsigned long baudrate);
133 getBaudrate () const;
136 setBytesize (bytesize_t bytesize);
139 getBytesize () const;
142 setParity (parity_t parity);
148 setStopbits (stopbits_t stopbits);
151 getStopbits () const;
154 setFlowcontrol (flowcontrol_t flowcontrol);
157 getFlowcontrol () const;
172 void reconfigurePort ();
175 string port_; // Path to the file descriptor
180 Timeout timeout_; // Timeout for read operations
181 unsigned long baudrate_; // Baudrate
183 parity_t parity_; // Parity
184 bytesize_t bytesize_; // Size of the bytes
185 stopbits_t stopbits_; // Stop Bits
186 flowcontrol_t flowcontrol_; // Flow Control
188 // Mutex used to lock the read functions
190 // Mutex used to lock the write functions
196 #endif // SERIAL_IMPL_WINDOWS_H