mirror of
https://github.com/wjwwood/serial.git
synced 2026-01-22 19:54:57 +08:00
Merge branch 'Konstantinacc-master'
This commit is contained in:
commit
23770f9581
@ -437,8 +437,13 @@ Serial::SerialImpl::close ()
|
||||
{
|
||||
if (is_open_ == true) {
|
||||
if (fd_ != -1) {
|
||||
::close (fd_); // Ignoring the outcome
|
||||
fd_ = -1;
|
||||
int ret;
|
||||
ret = ::close (fd_);
|
||||
if (ret == 0) {
|
||||
fd_ = -1;
|
||||
} else {
|
||||
THROW (IOException, errno);
|
||||
}
|
||||
}
|
||||
is_open_ = false;
|
||||
}
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
|
||||
/* Copyright 2012 William Woodall and John Harrison */
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "serial/impl/win.h"
|
||||
|
||||
using std::string;
|
||||
@ -260,8 +262,15 @@ Serial::SerialImpl::close ()
|
||||
{
|
||||
if (is_open_ == true) {
|
||||
if (fd_ != INVALID_HANDLE_VALUE) {
|
||||
CloseHandle(fd_);
|
||||
fd_ = INVALID_HANDLE_VALUE;
|
||||
int ret;
|
||||
ret = CloseHandle(fd_);
|
||||
if (ret == 0) {
|
||||
stringstream ss;
|
||||
ss << "Error while closing serial port: " << GetLastError();
|
||||
THROW (IOException, ss.str().c_str());
|
||||
} else {
|
||||
fd_ = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
}
|
||||
is_open_ = false;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user