From e1a7d9347a3fb5169ee093cc4a7c2994d4de2df0 Mon Sep 17 00:00:00 2001 From: Geoffrey Hunter Date: Sat, 12 Feb 2022 13:36:29 +1300 Subject: [PATCH] Renamed method to get num. of RX bytes to 'Available'. Updated CHANGELOG. --- CHANGELOG.md | 5 +++++ include/CppLinuxSerial/SerialPort.hpp | 9 ++++----- src/SerialPort.cpp | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f8564b..5ed05b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [v2.4.0] - 2022-02-12 + +- Added `Available()` method to return number of bytes ready to be read from the receive buffer (thanks lotricekCZ). +- Added CMake option for shared library (thanks lotricekCZ). + ## [v2.3.0] - 2021-12-23 - Added support for setting the num. data bits. diff --git a/include/CppLinuxSerial/SerialPort.hpp b/include/CppLinuxSerial/SerialPort.hpp index b20dc01..62eb88e 100644 --- a/include/CppLinuxSerial/SerialPort.hpp +++ b/include/CppLinuxSerial/SerialPort.hpp @@ -168,13 +168,12 @@ namespace mn { /// \throws CppLinuxSerial::Exception if state != OPEN. void ReadBinary(std::vector& data); - /// \brief Use to get number of bytes available in buffer + /// \brief Use to get number of bytes available in receive buffer. + /// \returns The number of bytes available in the receive buffer (ready to be read). /// \throws CppLinuxSerial::Exception if state != OPEN. - int32_t InWaiting(); - private: + int32_t Available(); - /// \brief Returns a populated termios structure for the passed in file descriptor. - // termios GetTermios(); + private: /// \brief Configures the tty device as a serial port. /// \warning Device must be open (valid file descriptor) when this is called. diff --git a/src/SerialPort.cpp b/src/SerialPort.cpp index 5980105..bf168e8 100644 --- a/src/SerialPort.cpp +++ b/src/SerialPort.cpp @@ -630,7 +630,7 @@ namespace CppLinuxSerial { timeout_ms_ = timeout_ms; } - int32_t SerialPort::InWaiting() { + int32_t SerialPort::Available() { if(state_ != State::OPEN) THROW_EXCEPT(std::string() + __PRETTY_FUNCTION__ + " called but state != OPEN. Please call Open() first."); int32_t ret = 0; -- libgit2 0.21.4