]> git.tdb.fi Git - libs/core.git/blob - source/serial.h
fd34cdef2069df6dc7d2f568d5bd47c5bb51c61b
[libs/core.git] / source / serial.h
1 /* $Id$
2
3 This file is part of libmspio
4 Copyright © 2010 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_IO_SERIAL_H_
9 #define MSP_IO_SERIAL_H_
10
11 #include "base.h"
12
13 namespace Msp {
14 namespace IO {
15
16 class Serial: public Base
17 {
18 public:
19         enum Parity
20         {
21                 NONE,
22                 EVEN,
23                 ODD
24         };
25
26 private:
27         Handle handle;
28
29 public:
30         Serial(const std::string &);
31         virtual ~Serial();
32
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         virtual Handle get_event_handle();
42
43 private:
44         void close();
45         virtual unsigned do_write(const char *, unsigned);
46         virtual unsigned do_read(char *, unsigned);
47 };
48
49 } // namespace IO
50 } // namespace Msp
51
52 #endif