Public Member Functions |
| bool | connect (const std::string &device, const uint baudrate=115200) |
| | connect establish connection to serial device
|
| | MSP () |
| | MSP construct MSP communication without establishing a connection.
|
| | MSP (const std::string &device, const uint baudrate=115200) |
| | MSP constructor for MSP communication.
|
| DataID | receiveData () |
| | receiveData receive raw data from flight controller
|
| bool | request (msp::Request &request) |
| | request send command and request data from FC once
|
| bool | request_block (msp::Request &request) |
| | request_block continuously send command and request data until data has been received
|
| bool | request_wait (msp::Request &request, const uint wait_ms, const uint min_payload_size=0) |
| | request_wait wait for data while continuously sending command
|
| bool | respond (const msp::Response &response) |
| | respond send data to FC and read acknowledge
|
| bool | respond_block (const msp::Response &response) |
| | respond_block send data to FC until acknowledge has been received
|
| bool | send (const msp::Response &response) |
| | send encode message and send payload
|
| bool | sendData (const uint8_t id, const ByteVector &data=ByteVector(0)) |
| | sendData send raw data and ID to flight controller, accepts any uint8 id
|
| bool | sendData (const msp::ID id, const ByteVector &data=ByteVector(0)) |
| | sendData send raw data and ID to flight controller, only accepts registered message ID
|
| void | setWait (unsigned int wait_us) |
| | setWait set time (microseconds) between sending and receiving After sending a request to the FC, we need to wait a small amount of time for the FC to process our request and to respond.
|
Private Member Functions |
| void | clear () |
| | clear flush the serial buffer to remove old data
|
| uint8_t | crc (const uint8_t id, const ByteVector &data) |
| | crc compute checksum of data package
|
| int | hasData () |
| | hasData check if data is available
|
| size_t | read (std::vector< uint8_t > &data) |
| | read read data vector from device
|
| std::vector< uint8_t > | read (std::size_t n_bytes) |
| | read read given amount of bytes from device
|
| uint8_t | read () |
| | read read a single byte from device
|
| bool | write (const std::vector< uint8_t > &data) |
| | write write data vector to device
|
Private Attributes |
| std::string | device |
| asio::io_service | io |
| | ! io service
|
| std::mutex | lock_read |
| std::mutex | lock_write |
| asio::serial_port | port |
| | ! port for serial device
|
| unsigned int | wait |
| | time (micro seconds) to wait before waiting for response
|
The MSP class.
Definition at line 80 of file MSP.hpp.