X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fserial.h;fp=source%2Fserial.h;h=0e873619c14777f9402a74e2d7012f367ee2275f;hp=0000000000000000000000000000000000000000;hb=463240ea92d65693f76c0e0991c322b3c4527ffe;hpb=53782f997e03e4f05b06624a47de29414696a5a8 diff --git a/source/serial.h b/source/serial.h new file mode 100644 index 0000000..0e87361 --- /dev/null +++ b/source/serial.h @@ -0,0 +1,55 @@ +/* $Id$ + +This file is part of libmspio +Copyright © 2010 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + +#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: + struct Private; + + Handle handle; + Private *priv; + +public: + Serial(const std::string &); + virtual ~Serial(); + + 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 &); + + virtual Handle get_event_handle() { return handle; } + +private: + void close(); + virtual unsigned do_write(const char *, unsigned); + virtual unsigned do_read(char *, unsigned); +}; + +} // namespace IO +} // namespace Msp + +#endif