namespace Msp {
namespace IO {
-Serial::Serial(const string &descr)
+Serial::Serial(const string &descr):
+ reader(handle, 1024)
{
string::size_type comma = descr.find(',');
string port = descr.substr(0, comma);
if(size==0)
return 0;
- return sys_read(handle, buf, size);
-}
-
-const Handle &Serial::get_event_handle()
-{
-#ifdef WIN32
- throw logic_error("Serial port events not supported on win32 yet");
-#else
- return handle;
-#endif
+ return reader.read(buf, size);
}
} // namespace IO
#define MSP_IO_SERIAL_H_
#include "eventobject.h"
+#include "eventreader.h"
#include "handle.h"
namespace Msp {
private:
Handle handle;
+ EventReader reader;
public:
Serial(const std::string &);
virtual unsigned do_read(char *, unsigned);
public:
- virtual const Handle &get_event_handle();
+ virtual const Handle &get_event_handle() { return reader.get_event(); }
};
} // namespace IO