1
0
mirror of https://github.com/wjwwood/serial.git synced 2026-01-22 11:44:53 +08:00

style fixup

This commit is contained in:
William Woodall 2014-07-02 15:01:53 -07:00
parent 04d4763926
commit 051824894b
2 changed files with 21 additions and 21 deletions

View File

@ -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<long> (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.

View File

@ -2,6 +2,8 @@
/* Copyright 2012 William Woodall and John Harrison */
#include <sstream>
#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;
}