1
0
mirror of https://github.com/wjwwood/serial.git synced 2026-01-23 04:04:54 +08:00

Merge 079615f11f9f01e4eaf1224d45c5ace2eaa01d52 into c455d053bf1d99a521fed605d7a7d41c57cee9cc

This commit is contained in:
daniser 2013-08-05 16:08:23 -07:00
commit 2c3de26ed7

View File

@ -274,7 +274,16 @@ Serial::SerialImpl::isOpen () const
size_t
Serial::SerialImpl::available ()
{
THROW (IOException, "available is not implemented on Windows.");
if (!is_open_) {
return 0;
}
COMSTAT cs;
if(!ClearCommError(fd_, NULL, &cs)) {
stringstream ss;
ss << "Error while checking status of the serial port: " << GetLastError();
THROW (IOException, ss.str().c_str());
}
return static_cast<size_t>(cs.cbInQue);
}
size_t