]> git.tdb.fi Git - libs/core.git/blobdiff - source/io/serial.cpp
Use EventReader in Serial as well
[libs/core.git] / source / io / serial.cpp
index 74af366856cd6ceaf99866e00d977e2108c1803c..5d335b6faa82e0226c043d14ba3a158e8a84d8ae 100644 (file)
@@ -149,7 +149,8 @@ void set_stop_bits(DeviceState &state, unsigned bits)
 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);
@@ -291,16 +292,7 @@ unsigned Serial::do_read(char *buf, unsigned size)
        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