#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;
termios t;
tcgetattr(*handle, &t);
- t.c_lflag &= ~(ECHO|ICANON);
- t.c_oflag &= ~OPOST;
+ t.c_iflag &= ~(ISTRIP|INLCR|IGNCR|ICRNL|IXON);
+ t.c_lflag &= ~(ECHO|ICANON|ISIG|IEXTEN);
+ t.c_oflag &= ~(OPOST|OCRNL|ONOCR|ONLRET);
+ t.c_cc[VMIN] = 1;
+ t.c_cc[VTIME] = 0;
tcsetattr(*handle, TCSADRAIN, &t);
#endif
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