]> git.tdb.fi Git - libs/core.git/blob - source/serial.h
069789c85097a69e8510d347ca43a02630009a2a
[libs/core.git] / source / serial.h
1 #ifndef MSP_IO_SERIAL_H_
2 #define MSP_IO_SERIAL_H_
3
4 #include "base.h"
5
6 namespace Msp {
7 namespace IO {
8
9 class Serial: public Base
10 {
11 public:
12         enum Parity
13         {
14                 NONE,
15                 EVEN,
16                 ODD
17         };
18
19 private:
20         Handle handle;
21
22 public:
23         Serial(const std::string &);
24         virtual ~Serial();
25
26 private:
27         void close();
28
29 public:
30         virtual void set_block(bool);
31
32         void set_baud_rate(unsigned);
33         void set_data_bits(unsigned);
34         void set_parity(Parity);
35         void set_stop_bits(unsigned);
36         void set_parameters(const std::string &);
37
38 private:
39         virtual unsigned do_write(const char *, unsigned);
40         virtual unsigned do_read(char *, unsigned);
41
42 public:
43         virtual Handle get_event_handle();
44 };
45
46 } // namespace IO
47 } // namespace Msp
48
49 #endif