From 534141aa8fa6bda0c3bace4c159ebf6051c1ee82 Mon Sep 17 00:00:00 2001 From: Ben Moyer Date: Sat, 13 Jan 2018 12:15:36 -0800 Subject: [PATCH] implement flushInput and flushOutput for windows (#153) --- src/impl/win.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/impl/win.cc b/src/impl/win.cc index c807ea2..4bc2f66 100644 --- a/src/impl/win.cc +++ b/src/impl/win.cc @@ -471,13 +471,19 @@ Serial::SerialImpl::flush () void Serial::SerialImpl::flushInput () { - THROW (IOException, "flushInput is not supported on Windows."); + if (is_open_ == false) { + throw PortNotOpenedException("Serial::flushInput"); + } + PurgeComm(fd_, PURGE_RXCLEAR); } void Serial::SerialImpl::flushOutput () { - THROW (IOException, "flushOutput is not supported on Windows."); + if (is_open_ == false) { + throw PortNotOpenedException("Serial::flushOutput"); + } + PurgeComm(fd_, PURGE_TXCLEAR); } void