Go to the documentation of this file.
53 CSerialPort(
const std::string& portName,
bool openNow =
true);
80 void open(
const std::string& COM_name);
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;
bool isOpen() const
Returns if port has been correctly open.
void close()
Close the port.
~CSerialPort() override
Destructor.
uint64_t getPosition() const override
not applicable in a serial port
A high-performance stopwatch, with typical resolution of nanoseconds.
CSerialPort()=default
Default constructor: it does not open any port - later you must call "setSerialPortName" and then "op...
A communications serial port built as an implementation of a utils::CStream.
Serial and networking devices and utilities.
size_t Write(const void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for writing to the stream.
uint64_t Seek(int64_t off, CStream::TSeekOrigin o=sFromBeginning) override
not applicable in a serial port
void purgeBuffers()
Purge tx and rx buffers.
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.
int m_interBytesTimeout_ms
void open()
Open the port.
mrpt::system::CTicTac m_timer
std::string ReadString(const int total_timeout_ms=-1, bool *out_timeout=nullptr, const char *eol_chars="\r\n")
Reads one text line from the serial port in POSIX "canonical mode".
void setTimeouts(int ReadIntervalTimeout, int ReadTotalTimeoutMultiplier, int ReadTotalTimeoutConstant, int WriteTotalTimeoutMultiplier, int WriteTotalTimeoutConstant)
Changes the timeouts of the port, in milliseconds.
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).
friend class PosixSignalDispatcherImpl
std::string m_serialName
The complete name of the serial port device (i.e.
size_t Read(void *Buffer, size_t Count) override
Implements the virtual method responsible for reading from the stream - Unlike CStream::ReadBuffer,...
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Page generated by Doxygen 1.8.17 for MRPT 2.0.4 at Sun Jul 19 17:54:30 UTC 2020 | |