Commit 4eb3e51a authored by William Woodall's avatar William Woodall
Browse files

Added isOpen, and credited John Harrison as an author as well.

parent 50581b4c
/**
* @file serial.h
* @author William Woodall <wjwwood@gmail.com>
* @author John Harrison <ash.gti@gmail.com>
* @version 0.1
*
* @section LICENSE
......@@ -143,6 +144,12 @@ public:
*/
void open();
/** Gets the status of the serial port.
*
* @return A boolean value that represents whether or not the serial port is open.
*/
const bool isOpen();
/** Closes the serial port and terminates threads. */
void close();
......
......@@ -182,6 +182,12 @@ void Serial::open() {
}
}
const bool Serial::isOpen() {
if(this->serial_port != NULL)
return this->serial_port->is_open();
return false;
}
void Serial::close() {
// Cancel the current timeout timer and async reads
this->timeout_timer.cancel();
......
......@@ -13,6 +13,12 @@ int main(int argc, char **argv)
serial::Serial serial(port, 115200, 250);
std::cout << "Is the serial port open?";
if(serial.isOpen())
std::cout << " Yes." << std::endl;
else
std::cout << " No." << std::endl;
int count = 0;
while (count >= 0) {
int bytes_wrote = serial.write("Testing.");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment