mirror of
https://github.com/wjwwood/serial.git
synced 2026-01-22 19:54:57 +08:00
Merge pull request #35 from daniser/patch-1
Implemented Serial::available() for Windows
This commit is contained in:
commit
a20acb2a00
@ -274,7 +274,16 @@ Serial::SerialImpl::isOpen () const
|
|||||||
size_t
|
size_t
|
||||||
Serial::SerialImpl::available ()
|
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
|
size_t
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user