X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fio%2Fserial.cpp;h=2ed11ae9fddd900b4ab695a2acc05770deaf5e18;hp=5d335b6faa82e0226c043d14ba3a158e8a84d8ae;hb=a97f614de0984d6dda2173ca72815ac1062faf7a;hpb=d85465dd66a6fc80a9fb7868d1193a86abfe5b7c diff --git a/source/io/serial.cpp b/source/io/serial.cpp index 5d335b6..2ed11ae 100644 --- a/source/io/serial.cpp +++ b/source/io/serial.cpp @@ -158,7 +158,7 @@ Serial::Serial(const string &descr): #ifdef WIN32 port = "\\\\.\\"+port; - *handle = CreateFile(port.c_str(), GENERIC_READ|GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); + *handle = CreateFile(port.c_str(), GENERIC_READ|GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED, 0); if(!handle) throw system_error(format("CreateFile(%s)", port)); mode = M_READ|M_WRITE; @@ -292,7 +292,11 @@ unsigned Serial::do_read(char *buf, unsigned size) if(size==0) return 0; - return reader.read(buf, size); + unsigned ret = reader.read(buf, size); + if(ret==0) + set_eof(); + + return ret; } } // namespace IO