X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fio%2Fserial.cpp;h=ac4f2b764d8666332de5cf932e62e66cd5d764b2;hp=74af366856cd6ceaf99866e00d977e2108c1803c;hb=82d74297d5b469b0a506d7010a84ab5115cd88ee;hpb=6c40658510b68788fd5ef0488b20873b6aa32938 diff --git a/source/io/serial.cpp b/source/io/serial.cpp index 74af366..ac4f2b7 100644 --- a/source/io/serial.cpp +++ b/source/io/serial.cpp @@ -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,11 @@ unsigned Serial::do_read(char *buf, unsigned size) if(size==0) return 0; - return sys_read(handle, buf, size); -} + unsigned ret = reader.read(buf, size); + if(ret==0) + set_eof(); -const Handle &Serial::get_event_handle() -{ -#ifdef WIN32 - throw logic_error("Serial port events not supported on win32 yet"); -#else - return handle; -#endif + return ret; } } // namespace IO