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