13 #include <mrpt/config.h>
46 friend class PosixSignalDispatcherImpl;
53 CSerialPort(
const std::string &portName,
bool openNow =
true );
69 m_serialName = COM_name;
80 void open(
const std::string &COM_name)
82 if (isOpen() && m_serialName!=COM_name)
THROW_EXCEPTION(
"Cannot change serial port while open");
85 setSerialPortName(COM_name);
117 bool enableFlowControl=
false);
123 int ReadIntervalTimeout,
124 int ReadTotalTimeoutMultiplier,
125 int ReadTotalTimeoutConstant,
126 int WriteTotalTimeoutMultiplier,
127 int WriteTotalTimeoutConstant );
133 size_t Read(
void *Buffer,
size_t Count);
143 std::string ReadString(
const int total_timeout_ms=-1,
bool *out_timeout =NULL,
const char *eol_chars =
"\r\n");
149 size_t Write(
const void *Buffer,
size_t Count);
164 THROW_EXCEPTION(
"Method not applicable to serial communications port CStream!");
173 THROW_EXCEPTION(
"Method not applicable to serial communications port CStream!");
182 THROW_EXCEPTION(
"Method not applicable to serial communications port CStream!");
196 #ifdef MRPT_OS_WINDOWS
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
A communications serial port built as an implementation of a utils::CStream.
#define THROW_EXCEPTION(msg)
CTicTac m_timer
Used only in ReadString.
uint64_t Seek(uint64_t Offset, CStream::TSeekOrigin Origin=sFromBeginning)
Introduces a pure virtual method for moving to a specified position in the streamed resource...
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
This class implements a high-performance stopwatch.
TSeekOrigin
Used in CStream::Seek.
uint64_t getPosition()
Method for getting the current cursor position, where 0 is the first byte and TotalBytesCount-1 the l...
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).
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void open(const std::string &COM_name)
Open the given serial port.
int hCOM
The file handle (-1: Not open)
uint64_t getTotalBytesCount()
Returns the total amount of bytes in the stream.
std::string m_serialName
The complete name of the serial port device (i.e.