Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Kestrel Collaboration
Kestrel Firmware
serial
Commits
4eb3e51a
Commit
4eb3e51a
authored
14 years ago
by
William Woodall
Browse files
Options
Download
Email Patches
Plain Diff
Added isOpen, and credited John Harrison as an author as well.
parent
50581b4c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
0 deletions
+19
-0
include/serial.h
include/serial.h
+7
-0
src/serial.cpp
src/serial.cpp
+6
-0
src/test_serial.cpp
src/test_serial.cpp
+6
-0
No files found.
include/serial.h
View file @
4eb3e51a
/**
* @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
();
...
...
This diff is collapsed.
Click to expand it.
src/serial.cpp
View file @
4eb3e51a
...
...
@@ -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
();
...
...
This diff is collapsed.
Click to expand it.
src/test_serial.cpp
View file @
4eb3e51a
...
...
@@ -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."
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment