serial_stream.hpp
Go to the documentation of this file.
1 
8 /*****************************************************************************
9 ** Ifdefs
10 *****************************************************************************/
11 
12 #ifndef ECL_STREAMS_SERIAL_STREAM_HPP_
13 #define ECL_STREAMS_SERIAL_STREAM_HPP_
14 
15 /*****************************************************************************
16 ** Includes
17 *****************************************************************************/
18 
19 #include <string>
20 #include <ecl/config/macros.hpp>
21 #include <ecl/devices/serial.hpp>
22 #include <ecl/exceptions/standard_exception.hpp>
23 #include "text_stream.hpp"
24 
25 /*****************************************************************************
26 ** Namespaces
27 *****************************************************************************/
28 
29 namespace ecl {
30 
31 /*****************************************************************************
32 ** Interfaces [SerialStream]
33 *****************************************************************************/
42 class ecl_streams_PUBLIC SerialStream : public TextStream<Serial> {
43 public:
50  SerialStream() {};
65  SerialStream(const std::string& port_name, const BaudRate &baud_rate = BaudRate_115200, const DataBits &data_bits = DataBits_8,
66  const StopBits &stop_bits = StopBits_1, const Parity &parity = NoParity) ecl_throw_decl(StandardException)
67  {
68  ecl_try {
69  this->device().open(port_name, baud_rate, data_bits, stop_bits, parity);
70  if ( !this->device().open() ) {
71  error = this->device().error();
72  }
73  } ecl_catch(StandardException &e) {
74  ecl_throw(StandardException(LOC,e));
75  }
76  }
77  virtual ~SerialStream() {};
78 
79 };
80 
81 } // namespace ecl
82 
83 
84 #endif /* ECL_STREAMS_SERIAL_STREAM_HPP_ */
StopBits
#define ecl_throw(exception)
Standard ecl throw exception throw.
#define ecl_streams_PUBLIC
#define ecl_throw_decl(exception)
Standard ecl throw exception declaration.
#define LOC
Stringify the line of code you are at.
StopBits_1
DataBits_8
Parity
DataBits
BaudRate_115200
#define ecl_catch(exception)
The catch part of a try-catch macro matching ecl_throw calls.
BaudRate
#define ecl_try
The try part of a try-catch macro matching ecl_throw calls.


xbot_node
Author(s): Roc, wangpeng@droid.ac.cn
autogenerated on Sat Oct 10 2020 03:28:13