From 051824894b0d9b71ab45636e4f151b19d0b3bc1b Mon Sep 17 00:00:00 2001 From: William Woodall Date: Wed, 2 Jul 2014 15:01:53 -0700 Subject: [PATCH] style fixup --- src/impl/unix.cc | 25 ++++++++++++------------- src/impl/win.cc | 17 +++++++++-------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/impl/unix.cc b/src/impl/unix.cc index d464bd3..6c1dbe4 100755 --- a/src/impl/unix.cc +++ b/src/impl/unix.cc @@ -420,11 +420,11 @@ Serial::SerialImpl::reconfigurePort () // activate settings ::tcsetattr (fd_, TCSANOW, &options); - + // Update byte_time_ based on the new settings. uint32_t bit_time_ns = 1e9 / baudrate_; byte_time_ns_ = bit_time_ns * (1 + bytesize_ + parity_ + stopbits_); - + // Compensate for the stopbits_one_point_five enum being equal to int 3, // and not 1.5. if (stopbits_ == stopbits_one_point_five) { @@ -437,14 +437,13 @@ Serial::SerialImpl::close () { if (is_open_ == true) { if (fd_ != -1) { - int retVal; - retVal=::close (fd_); - if (retVal==0) - fd_ = -1; - else - { - THROW (IOException, errno); - } + int ret; + ret = ::close (fd_); + if (ret == 0) { + fd_ = -1; + } else { + THROW (IOException, errno); + } } is_open_ = false; } @@ -488,7 +487,7 @@ Serial::SerialImpl::waitReadable (uint32_t timeout) // Otherwise there was some error THROW (IOException, errno); } - // Timeout occurred + // Timeout occurred if (r == 0) { return false; } @@ -522,7 +521,7 @@ Serial::SerialImpl::read (uint8_t *buf, size_t size) total_timeout_ms += timeout_.read_timeout_multiplier * static_cast (size); MillisecondTimer total_timeout(total_timeout_ms); - // Pre-fill buffer with available bytes + // Pre-fill buffer with available bytes { ssize_t bytes_read_now = ::read (fd_, buf, size); if (bytes_read_now > 0) { @@ -549,7 +548,7 @@ Serial::SerialImpl::read (uint8_t *buf, size_t size) size_t bytes_available = available(); if (bytes_available + bytes_read < size) { waitByteTimes(size - (bytes_available + bytes_read)); - } + } } // This should be non-blocking returning only what is available now // Then returning so that select can block again. diff --git a/src/impl/win.cc b/src/impl/win.cc index d8ecb3d..d933fe9 100644 --- a/src/impl/win.cc +++ b/src/impl/win.cc @@ -2,6 +2,8 @@ /* Copyright 2012 William Woodall and John Harrison */ +#include + #include "serial/impl/win.h" using std::string; @@ -260,16 +262,15 @@ Serial::SerialImpl::close () { if (is_open_ == true) { if (fd_ != INVALID_HANDLE_VALUE) { - int retVal; - retVal=CloseHandle(fd_); - if (retVal==0) - { + int ret; + ret = CloseHandle(fd_); + if (ret == 0) { stringstream ss; ss << "Error while closing serial port: " << GetLastError(); - THROW (IOException, ss.str().c_str()); + THROW (IOException, ss.str().c_str()); + } else { + fd_ = INVALID_HANDLE_VALUE; } - else - fd_ = INVALID_HANDLE_VALUE; } is_open_ = false; } @@ -298,7 +299,7 @@ Serial::SerialImpl::available () bool Serial::SerialImpl::waitReadable (uint32_t timeout) -{ +{ THROW (IOException, "waitReadable is not implemented on Windows."); return false; }