105 int baudRate,
int parity = 0,
int bits = 8,
int nStopBits = 1,
106 bool enableFlowControl =
false);
112 int ReadIntervalTimeout,
int ReadTotalTimeoutMultiplier,
113 int ReadTotalTimeoutConstant,
int WriteTotalTimeoutMultiplier,
114 int WriteTotalTimeoutConstant);
122 size_t Read(
void* Buffer,
size_t Count)
override;
137 const int total_timeout_ms = -1,
bool* out_timeout =
nullptr,
138 const char* eol_chars =
"\r\n");
141 size_t Write(
const void* Buffer,
size_t Count)
override;
size_t Read(void *Buffer, size_t Count) override
Implements the virtual method responsible for reading from the stream - Unlike CStream::ReadBuffer, this method will not raise an exception on zero bytes read, as long as there is not any fatal error in the communications.
A communications serial port built as an implementation of a utils::CStream.
std::string ReadString(const int total_timeout_ms=-1, bool *out_timeout=nullptr, const char *eol_chars="\")
Reads one text line from the serial port in POSIX "canonical mode".
A high-performance stopwatch, with typical resolution of nanoseconds.
void open()
Open the port.
uint64_t getTotalBytesCount() const override
not applicable in a serial port
void setConfig(int baudRate, int parity=0, int bits=8, int nStopBits=1, bool enableFlowControl=false)
Changes the configuration of the port.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
int m_interBytesTimeout_ms
void setSerialPortName(const std::string &COM_name)
Sets the serial port to open (it is an error to try to change this while open yet).
bool isOpen() const
Returns if port has been correctly open.
size_t Write(const void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for writing to the stream.
void purgeBuffers()
Purge tx and rx buffers.
mrpt::system::CTicTac m_timer
GLsizei const GLchar ** string
void close()
Close the port.
void setTimeouts(int ReadIntervalTimeout, int ReadTotalTimeoutMultiplier, int ReadTotalTimeoutConstant, int WriteTotalTimeoutMultiplier, int WriteTotalTimeoutConstant)
Changes the timeouts of the port, in milliseconds.
unsigned __int64 uint64_t
friend class PosixSignalDispatcherImpl
~CSerialPort() override
Destructor.
std::string m_serialName
The complete name of the serial port device (i.e.
uint64_t Seek(int64_t off, CStream::TSeekOrigin o=sFromBeginning) override
not applicable in a serial port
Serial and networking devices and utilities.
uint64_t getPosition() const override
not applicable in a serial port
CSerialPort()=default
Default constructor: it does not open any port - later you must call "setSerialPortName" and then "op...