48 #define THROW(exceptionClass, message) throw exceptionClass(__FILE__, \ 102 static uint32_t
max() {
return std::numeric_limits<uint32_t>::max();}
113 return Timeout(
max(), timeout, 0, timeout, 0);
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)
136 : inter_byte_timeout(inter_byte_timeout_),
137 read_timeout_constant(read_timeout_constant_),
138 read_timeout_multiplier(read_timeout_multiplier_),
139 write_timeout_constant(write_timeout_constant_),
140 write_timeout_multiplier(write_timeout_multiplier_)
180 Serial (
const std::string &port =
"",
181 uint32_t baudrate = 9600,
234 waitByteTimes (
size_t count);
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);
402 write (
const std::string &data);
413 setPort (
const std::string &port);
469 Timeout timeout(inter_byte_timeout, read_timeout_constant,
470 read_timeout_multiplier, write_timeout_constant,
471 write_timeout_multiplier);
472 return setTimeout(timeout);
498 setBaudrate (uint32_t baudrate);
509 getBaudrate ()
const;
529 getBytesize ()
const;
558 setStopbits (stopbits_t stopbits);
567 getStopbits ()
const;
578 setFlowcontrol (flowcontrol_t flowcontrol);
587 getFlowcontrol ()
const;
603 sendBreak (
int duration);
607 setBreak (
bool level =
true);
611 setRTS (
bool level =
true);
615 setDTR (
bool level =
true);
665 read_ (uint8_t *buffer,
size_t size);
668 write_ (
const uint8_t *data,
size_t length);
679 std::stringstream ss;
680 ss <<
"SerialException " << description <<
" failed.";
685 virtual const char*
what ()
const throw () {
686 return e_what_.c_str();
700 : file_(file), line_(line), errno_(errnum) {
701 std::stringstream ss;
702 #if defined(_WIN32) && !defined(__MINGW32__) 703 char error_str [1024];
704 strerror_s(error_str, 1024, errnum);
706 char * error_str = strerror(errnum);
708 ss <<
"IO Exception (" << errno_ <<
"): " << error_str;
709 ss <<
", file " << file_ <<
", line " << line_ <<
".";
712 explicit IOException (std::string file,
int line,
const char * description)
713 : file_(file), line_(line), errno_(0) {
714 std::stringstream ss;
715 ss <<
"IO Exception: " << description;
716 ss <<
", file " << file_ <<
", line " << line_ <<
".";
724 virtual const char*
what ()
const throw () {
725 return e_what_.c_str();
736 std::stringstream ss;
737 ss <<
"PortNotOpenedException " << description <<
" failed.";
742 virtual const char*
what ()
const throw () {
743 return e_what_.c_str();
770 std::vector<PortInfo>
IOException(std::string file, int line, int errnum)
std::vector< PortInfo > list_ports()
uint32_t write_timeout_constant
ROSCPP_DECL uint32_t getPort()
PortNotOpenedException(const PortNotOpenedException &other)
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)
IOException(std::string file, int line, const char *description)
virtual ~PortNotOpenedException()
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)
SerialException(const SerialException &other)
uint32_t read_timeout_multiplier
uint32_t read_timeout_constant
PortNotOpenedException(const char *description)
virtual const char * what() const
static Timeout simpleTimeout(uint32_t timeout)
virtual const char * what() const
SerialException(const char *description)
IOException(const IOException &other)
virtual ~SerialException()
uint32_t write_timeout_multiplier
uint32_t inter_byte_timeout
int getErrorNumber() const
virtual const char * what() const