Go to the documentation of this file.
13 #include <mrpt/config.h>
45 friend class PosixSignalDispatcherImpl;
52 CSerialPort(
const std::string &portName,
bool openNow =
true );
68 m_serialName = COM_name;
79 void open(
const std::string &COM_name)
81 if (isOpen() && m_serialName!=COM_name)
THROW_EXCEPTION(
"Cannot change serial port while open");
84 setSerialPortName(COM_name);
116 bool enableFlowControl=
false);
122 int ReadIntervalTimeout,
123 int ReadTotalTimeoutMultiplier,
124 int ReadTotalTimeoutConstant,
125 int WriteTotalTimeoutMultiplier,
126 int WriteTotalTimeoutConstant );
132 size_t Read(
void *Buffer,
size_t Count);
142 std::string
ReadString(
const int total_timeout_ms=-1,
bool *out_timeout =NULL,
const char *eol_chars =
"\r\n");
148 size_t Write(
const void *Buffer,
size_t Count);
158 uint64_t
Seek(uint64_t Offset, CStream::TSeekOrigin Origin = sFromBeginning)
163 THROW_EXCEPTION(
"Method not applicable to serial communications port CStream!");
172 THROW_EXCEPTION(
"Method not applicable to serial communications port CStream!");
181 THROW_EXCEPTION(
"Method not applicable to serial communications port CStream!");
195 #ifdef MRPT_OS_WINDOWS
#define THROW_EXCEPTION(msg)
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.
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
bool isOpen() const
Returns if port has been correctly open.
void purgeBuffers()
Purge tx and rx buffers.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
size_t Write(const void *Buffer, size_t Count)
Implements the virtual method responsible for writing to the stream.
void setTimeouts(int ReadIntervalTimeout, int ReadTotalTimeoutMultiplier, int ReadTotalTimeoutConstant, int WriteTotalTimeoutMultiplier, int WriteTotalTimeoutConstant)
Changes the timeouts of the port, in milliseconds.
This class implements a high-performance stopwatch.
CSerialPort(const std::string &portName, bool openNow=true)
Constructor.
mrpt::utils::CTicTac m_timer
Used only in ReadString.
uint64_t getPosition()
Method for getting the current cursor position, where 0 is the first byte and TotalBytesCount-1 the l...
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
void setConfig(int baudRate, int parity=0, int bits=8, int nStopBits=1, bool enableFlowControl=false)
Changes the configuration of the port.
std::string ReadString(const int total_timeout_ms=-1, bool *out_timeout=NULL, const char *eol_chars="\r\n")
Reads one text line from the serial port in POSIX "canonical mode".
int hCOM
The file handle (-1: Not open)
A communications serial port built as an implementation of a utils::CStream.
void open(const std::string &COM_name)
Open the given serial port.
void open()
Open the port.
uint64_t getTotalBytesCount()
Returns the total amount of bytes in the stream.
CSerialPort()
Default constructor: it does not open any port - later you must call "setSerialPortName" and then "op...
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).
void close()
Close the port.
std::string m_serialName
The complete name of the serial port device (i.e.
virtual ~CSerialPort()
Destructor.
size_t Read(void *Buffer, size_t Count)
Implements the virtual method responsible for reading from the stream - Unlike CStream::ReadBuffer,...
Page generated by Doxygen 1.8.20 for MRPT 1.4.0 SVN: at Thu Aug 27 02:40:23 UTC 2020 | | |