30 #ifndef PT_SYSTEM_SERIALDEVICE_H
31 #define PT_SYSTEM_SERIALDEVICE_H
33 #include <Pt/System/Api.h>
34 #include <Pt/System/IODevice.h>
75 class SerialDeviceImpl* _impl;
97 BaudRate19200 = 19200,
98 BaudRate38400 = 38400,
99 BaudRate57600 = 57600,
100 BaudRate115200 = 115200
102 , BaudRate230400 = 230400
150 void open(
const std::string& file, std::ios::openmode mode);
154 void open(
const char* file, std::ios::openmode mode);
187 void setRts(
bool on);
189 void setDtr(
bool on);
191 void setBreak(
bool on);
193 void sendBreak(
int duration = 0);
206 void onSetTimeout(std::size_t timeout);
209 std::size_t onBeginRead(
EventLoop& loop,
char* buffer, std::size_t n,
bool& eof);
212 std::size_t onEndRead(
EventLoop& loop,
char* buffer, std::size_t n,
bool& eof);
215 std::size_t onBeginWrite(
EventLoop& loop,
const char* buffer, std::size_t n);
218 std::size_t onEndWrite(
EventLoop& loop,
const char* buffer, std::size_t n);
221 std::size_t onRead(
char* buffer, std::size_t count,
bool& eof);
224 std::size_t onWrite(
const char* buffer, std::size_t count);
240 #endif // PT_SYSTEM_SERIALDEVICE_H
Core module.
Definition: pt-gfx-images.dox:14
Parity parity() const
Gets the current parity.
Parity
Parity values.
Definition: SerialDevice.h:109
SerialDevice()
Default constructor.
void onCancel()
Blocks until operation has cancelled.
void setBaudRate(unsigned rate)
Sets the baud rate.
void setParity(Parity parity)
Sets the parity.
virtual ~SerialDevice()
Destructor.
SerialDevice(const char *file, std::ios::openmode mode)
Constructs a serial device and open the specified device file.
BaudRate
Baud rates.
Definition: SerialDevice.h:82
int charSize() const
Gets the current char size.
void setFlowControl(FlowControl flowControl)
Sets the flow control kind.
bool onRun()
Check if ready and run.
StopBits
Stop bits values.
Definition: SerialDevice.h:127
void open(const char *file, std::ios::openmode mode)
Open the specified device file.
Thread-safe event loop supporting I/O multiplexing and Timers.
Definition: EventLoop.h:74
Endpoint for I/O operations.
Definition: IODevice.h:56
Serial device.
Definition: SerialDevice.h:73
uint_type uint32_t
Unsigned 32-bit integer type.
Definition: Types.h:42
void open(const std::string &file, std::ios::openmode mode)
Open the specified device file.
SerialDevice(const std::string &file, std::ios::openmode mode)
Constructs a serial device and open the specified device file.
unsigned baudRate() const
Gets the baud rate.
StopBits stopBits() const
Gets the current number of stop bits.
void setCharSize(int size)
Sets the char size.
void setStopBits(StopBits bits)
Sets the number of stop bits.
FlowControl
Flow control values.
Definition: SerialDevice.h:118
FlowControl flowControl() const
Gets the current flow control kind.