From 3d69d04c86667b6582f453ba5b419a0022dbe737 Mon Sep 17 00:00:00 2001 From: William Woodall Date: Sat, 26 Mar 2011 18:19:12 -0500 Subject: [PATCH] Added the set and get port functions, probably should have been in there from the start... --- include/serial.h | 16 ++++++++++++++++ src/serial.cpp | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/include/serial.h b/include/serial.h index 537e58e..b35d256 100644 --- a/include/serial.h +++ b/include/serial.h @@ -217,6 +217,22 @@ public: */ const bool getDSR() const; + /** Sets the serial port identifier. + * + * @param port A std::string containing the address of the serial port, + * which would be something like 'COM1' on Windows and '/dev/ttyS0' + * on Linux. + */ + void setPort(std::string port); + + /** Gets the serial port identifier. + * + * @return A std::string containing the address of the serial port, + * which would be something like 'COM1' on Windows and '/dev/ttyS0' + * on Linux. + */ + const std::string getPort() const; + /** Sets the timeout for reads in seconds. * * @param timeout A long that represents the time (in milliseconds) until a diff --git a/src/serial.cpp b/src/serial.cpp index 19abbb8..5a90376 100644 --- a/src/serial.cpp +++ b/src/serial.cpp @@ -281,6 +281,14 @@ const bool Serial::getDSR() const { return false; } +void Serial::setPort(std::string port) { + this->port = port; +} + +const std::string Serial::getPort() const { + return this->port; +} + void Serial::setTimeoutMilliseconds(long timeout) { // If timeout > 0 then read until size or timeout occurs // If timeout == 0 then read nonblocking, return data available immediately up to size