]> git.tdb.fi Git - libs/core.git/blobdiff - source/io/serial.h
Move files to prepare for assimilation into core
[libs/core.git] / source / io / serial.h
diff --git a/source/io/serial.h b/source/io/serial.h
new file mode 100644 (file)
index 0000000..069789c
--- /dev/null
@@ -0,0 +1,49 @@
+#ifndef MSP_IO_SERIAL_H_
+#define MSP_IO_SERIAL_H_
+
+#include "base.h"
+
+namespace Msp {
+namespace IO {
+
+class Serial: public Base
+{
+public:
+       enum Parity
+       {
+               NONE,
+               EVEN,
+               ODD
+       };
+
+private:
+       Handle handle;
+
+public:
+       Serial(const std::string &);
+       virtual ~Serial();
+
+private:
+       void close();
+
+public:
+       virtual void set_block(bool);
+
+       void set_baud_rate(unsigned);
+       void set_data_bits(unsigned);
+       void set_parity(Parity);
+       void set_stop_bits(unsigned);
+       void set_parameters(const std::string &);
+
+private:
+       virtual unsigned do_write(const char *, unsigned);
+       virtual unsigned do_read(char *, unsigned);
+
+public:
+       virtual Handle get_event_handle();
+};
+
+} // namespace IO
+} // namespace Msp
+
+#endif