#include <serial.h>
|
| void | close () |
| | Stops communication and closes the port. More...
|
| |
| void | open () |
| | Opens the port and begins communication. More...
|
| |
| void | register_listener (SerialListener *const listener) |
| | Register a listener for received bytes. More...
|
| |
| | Serial (std::__cxx11::string port, int baud_rate) |
| | Instantiates the class and begins communication on the specified serial port. More...
|
| |
| void | write (const uint8_t *buffer, uint8_t len) |
| | write data More...
|
| |
| | ~Serial () |
| | Stops communication and closes the serial port before the object is destroyed. More...
|
| |
|
| typedef boost::lock_guard< boost::recursive_mutex > | mutex_lock |
| | Convenience typedef for mutex lock. More...
|
| |
|
| void | async_read () |
| | Initiate an asynchronous read operation. More...
|
| |
| void | async_read_end (const boost::system::error_code &error, size_t bytes_transferred) |
| | Handler for end of asynchronous read operation. More...
|
| |
| void | async_write (bool check_write_state) |
| | Initialize an asynchronous write operation. More...
|
| |
| void | async_write_end (const boost::system::error_code &error, size_t bytes_transferred) |
| | Handler for end of asynchronous write operation. More...
|
| |
Definition at line 59 of file include/serial.h.
◆ mutex_lock
◆ Serial()
| Serial::Serial |
( |
std::__cxx11::string |
port, |
|
|
int |
baud_rate |
|
) |
| |
Instantiates the class and begins communication on the specified serial port.
- Parameters
-
| port | Name of the serial port (e.g. "/dev/ttyUSB0") |
| baud_rate | Serial communication baud rate |
Definition at line 43 of file serial.cpp.
◆ ~Serial()
Stops communication and closes the serial port before the object is destroyed.
Definition at line 53 of file serial.cpp.
◆ async_read()
| void Serial::async_read |
( |
| ) |
|
|
private |
Initiate an asynchronous read operation.
Definition at line 100 of file serial.cpp.
◆ async_read_end()
| void Serial::async_read_end |
( |
const boost::system::error_code & |
error, |
|
|
size_t |
bytes_transferred |
|
) |
| |
|
private |
Handler for end of asynchronous read operation.
- Parameters
-
| error | Error code |
| bytes_transferred | Number of bytes received |
Definition at line 113 of file serial.cpp.
◆ async_write()
| void Serial::async_write |
( |
bool |
check_write_state | ) |
|
|
private |
Initialize an asynchronous write operation.
- Parameters
-
| check_write_state | If true, only start another write operation if a write sequence is not already running |
Definition at line 147 of file serial.cpp.
◆ async_write_end()
| void Serial::async_write_end |
( |
const boost::system::error_code & |
error, |
|
|
size_t |
bytes_transferred |
|
) |
| |
|
private |
Handler for end of asynchronous write operation.
- Parameters
-
| error | Error code |
| bytes_transferred | Number of bytes sent |
Definition at line 168 of file serial.cpp.
◆ close()
Stops communication and closes the port.
Definition at line 79 of file serial.cpp.
◆ open()
Opens the port and begins communication.
Definition at line 57 of file serial.cpp.
◆ register_listener()
Register a listener for received bytes.
- Parameters
-
| listener | Pointer to an object that implements the SerialListener interface |
Definition at line 92 of file serial.cpp.
◆ write()
| void Serial::write |
( |
const uint8_t * |
buffer, |
|
|
uint8_t |
len |
|
) |
| |
write data
- Parameters
-
| buffer | The message to send |
| len | The number of bytes |
- Todo:
- Do something less catastrophic here
Definition at line 128 of file serial.cpp.
◆ baud_rate_
◆ compid_
◆ io_service_
| boost::asio::io_service Serial::io_service_ |
◆ io_thread_
| boost::thread Serial::io_thread_ |
|
private |
◆ listener_
◆ mutex_
| boost::recursive_mutex Serial::mutex_ |
|
private |
◆ port_
| std::string Serial::port_ |
|
private |
◆ read_buf_raw_
◆ serial_port_
| boost::asio::serial_port Serial::serial_port_ |
|
private |
◆ sysid_
◆ write_in_progress_
| bool Serial::write_in_progress_ |
|
private |
flag for whether async_write is already running
Definition at line 184 of file include/serial.h.
◆ write_queue_
queue of buffers to be written to the serial port
Definition at line 183 of file include/serial.h.
The documentation for this class was generated from the following files: