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>
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:
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_ */
SerialStream(const std::string &port_name, const BaudRate &baud_rate=BaudRate_115200, const DataBits &data_bits=DataBits_8, const StopBits &stop_bits=StopBits_1, const Parity &parity=NoParity) ecl_throw_decl(StandardException)
Convenience constructor for serial text streams.
#define ecl_throw(exception)
Convenience class for Serial TextStream definitions.
#define LOC
StopBits_1
DataBits_8
#define ecl_streams_PUBLIC
Definition: macros.hpp:37
Convenience header for various text streams.
BaudRate_115200
A text streaming interface.
Definition: text_stream.hpp:94
SerialStream()
Default constructor, underlying device must be manually opened.
#define ecl_catch(exception)
virtual ~SerialStream()
#define ecl_try


ecl_streams
Author(s): Daniel Stonier
autogenerated on Wed Jun 28 2017 02:26:44