Go to the documentation of this file.
48 #define THROW(exceptionClass, message) throw exceptionClass(__FILE__, \
102 static uint32_t
max() {
return std::numeric_limits<uint32_t>::max();}
131 explicit Timeout (uint32_t inter_byte_timeout_=0,
132 uint32_t read_timeout_constant_=0,
133 uint32_t read_timeout_multiplier_=0,
134 uint32_t write_timeout_constant_=0,
135 uint32_t write_timeout_multiplier_=0)
180 Serial (
const std::string &port =
"",
181 uint32_t baudrate = 9600,
265 read (uint8_t *buffer,
size_t size);
279 read (std::vector<uint8_t> &buffer,
size_t size = 1);
293 read (std::string &buffer,
size_t size = 1);
306 read (
size_t size = 1);
322 readline (std::string &buffer,
size_t size = 65536, std::string eol =
"\n");
337 readline (
size_t size = 65536, std::string eol =
"\n");
353 std::vector<std::string>
354 readlines (
size_t size = 65536, std::string eol =
"\n");
372 write (
const uint8_t *
data,
size_t size);
387 write (
const std::vector<uint8_t> &
data);
413 setPort (
const std::string &port);
463 setTimeout (uint32_t inter_byte_timeout, uint32_t read_timeout_constant,
464 uint32_t read_timeout_multiplier, uint32_t write_timeout_constant,
465 uint32_t write_timeout_multiplier)
468 read_timeout_multiplier, write_timeout_constant,
469 write_timeout_multiplier);
609 setRTS (
bool level =
true);
613 setDTR (
bool level =
true);
663 read_ (uint8_t *buffer,
size_t size);
666 write_ (
const uint8_t *data,
size_t length);
677 std::stringstream ss;
678 ss <<
"SerialException " << description <<
" failed.";
683 virtual const char*
what ()
const throw () {
699 std::stringstream ss;
700 #if defined(_WIN32) && !defined(__MINGW32__)
701 char error_str [1024];
702 strerror_s(error_str, 1024, errnum);
704 char * error_str = strerror(errnum);
706 ss <<
"IO Exception (" <<
errno_ <<
"): " << error_str;
707 ss <<
", file " <<
file_ <<
", line " <<
line_ <<
".";
710 explicit IOException (std::string file,
int line,
const char * description)
712 std::stringstream ss;
713 ss <<
"IO Exception: " << description;
714 ss <<
", file " <<
file_ <<
", line " <<
line_ <<
".";
722 virtual const char*
what ()
const throw () {
734 std::stringstream ss;
735 ss <<
"PortNotOpenedException " << description <<
" failed.";
740 virtual const char*
what ()
const throw () {
768 std::vector<PortInfo>
void setBaudrate(uint32_t baudrate)
IOException(std::string file, int line, const char *description)
void setTimeout(uint32_t inter_byte_timeout, uint32_t read_timeout_constant, uint32_t read_timeout_multiplier, uint32_t write_timeout_constant, uint32_t write_timeout_multiplier)
IOException(std::string file, int line, int errnum)
IOException & operator=(const IOException &)
void setParity(parity_t parity)
void setTimeout(Timeout &timeout)
PortNotOpenedException(const PortNotOpenedException &other)
uint32_t read_timeout_multiplier
uint32_t write_timeout_constant
parity_t getParity() const
SerialException & operator=(const SerialException &)
SerialException(const SerialException &other)
virtual const char * what() const
std::string getPort() const
std::vector< PortInfo > list_ports()
void setRTS(bool level=true)
void setBytesize(bytesize_t bytesize)
uint32_t write_timeout_multiplier
IOException(const IOException &other)
virtual const char * what() const
size_t read_(uint8_t *buffer, size_t size)
stopbits_t getStopbits() const
Serial(const std::string &port="", uint32_t baudrate=9600, Timeout timeout=Timeout(), bytesize_t bytesize=eightbits, parity_t parity=parity_none, stopbits_t stopbits=stopbits_one, flowcontrol_t flowcontrol=flowcontrol_none)
size_t write_(const uint8_t *data, size_t length)
virtual const char * what() const
static Timeout simpleTimeout(uint32_t timeout)
virtual ~PortNotOpenedException()
uint32_t inter_byte_timeout
void setPort(const std::string &port)
size_t readline(std::string &buffer, size_t size=65536, std::string eol="\n")
std::vector< std::string > readlines(size_t size=65536, std::string eol="\n")
uint32_t read_timeout_constant
void setFlowcontrol(flowcontrol_t flowcontrol)
uint32_t getBaudrate() const
void sendBreak(int duration)
flowcontrol_t getFlowcontrol() const
void setStopbits(stopbits_t stopbits)
@ stopbits_one_point_five
virtual ~SerialException()
const PortNotOpenedException & operator=(PortNotOpenedException)
Timeout getTimeout() const
void setDTR(bool level=true)
bytesize_t getBytesize() const
void waitByteTimes(size_t count)
SerialException(const char *description)
void setBreak(bool level=true)
PortNotOpenedException(const char *description)
size_t write(const uint8_t *data, size_t size)
size_t read(uint8_t *buffer, size_t size)
Timeout(uint32_t inter_byte_timeout_=0, uint32_t read_timeout_constant_=0, uint32_t read_timeout_multiplier_=0, uint32_t write_timeout_constant_=0, uint32_t write_timeout_multiplier_=0)
Serial & operator=(const Serial &)