]> git.tdb.fi Git - libs/core.git/blob - source/serial.h
0e873619c14777f9402a74e2d7012f367ee2275f
[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         struct Private;
28
29         Handle handle;
30         Private *priv;
31
32 public:
33         Serial(const std::string &);
34         virtual ~Serial();
35
36         virtual void set_block(bool);
37
38         void set_baud_rate(unsigned);
39         void set_data_bits(unsigned);
40         void set_parity(Parity);
41         void set_stop_bits(unsigned);
42         void set_parameters(const std::string &);
43
44         virtual Handle get_event_handle() { return handle; }
45
46 private:
47         void close();
48         virtual unsigned do_write(const char *, unsigned);
49         virtual unsigned do_read(char *, unsigned);
50 };
51
52 } // namespace IO
53 } // namespace Msp
54
55 #endif