37 #ifndef ROSFLIGHT_FIRMWARE_UDP_BOARD_H 38 #define ROSFLIGHT_FIRMWARE_UDP_BOARD_H 43 #include <boost/asio.hpp> 44 #include <boost/thread.hpp> 54 UDPBoard(std::string bind_host =
"localhost",
55 uint16_t bind_port = 14525,
56 std::string remote_host =
"localhost",
57 uint16_t remote_port = 14520);
60 void serial_init(uint32_t baud_rate, uint32_t dev)
override;
61 void serial_write(
const uint8_t* src,
size_t len)
override;
66 void set_ports(std::string bind_host, uint16_t bind_port, std::string remote_host, uint16_t remote_port);
77 Buffer(
const uint8_t* src,
size_t length) : len(length), pos(0)
80 memcpy(data, src, length);
83 const uint8_t*
dpos()
const {
return data +
pos; }
85 void add_byte(uint8_t byte) { data[len++] = byte; }
91 typedef boost::lock_guard<boost::recursive_mutex>
MutexLock;
124 #endif // ROSFLIGHT_FIRMWARE_UDP_BOARD_H void serial_flush() override
boost::asio::ip::udp::socket socket_
std::list< Buffer * > write_queue_
static volatile bool error
void serial_init(uint32_t baud_rate, uint32_t dev) override
void serial_write(const uint8_t *src, size_t len) override
void add_byte(uint8_t byte)
UDPBoard(std::string bind_host="localhost", uint16_t bind_port=14525, std::string remote_host="localhost", uint16_t remote_port=14520)
boost::asio::ip::udp::endpoint bind_endpoint_
#define MAVLINK_MAX_PACKET_LEN
Maximum packet length.
boost::asio::ip::udp::endpoint remote_endpoint_
void async_write(bool check_write_state)
void async_read_end(const boost::system::error_code &error, size_t bytes_transferred)
boost::lock_guard< boost::recursive_mutex > MutexLock
boost::recursive_mutex write_mutex_
uint16_t serial_bytes_available(void) override
const uint8_t * dpos() const
void set_ports(std::string bind_host, uint16_t bind_port, std::string remote_host, uint16_t remote_port)
uint8_t serial_read(void) override
boost::recursive_mutex read_mutex_
uint8_t data[MAVLINK_MAX_PACKET_LEN]
boost::asio::io_service io_service_
std::list< Buffer * > read_queue_
Buffer(const uint8_t *src, size_t length)
void async_write_end(const boost::system::error_code &error, size_t bytes_transferred)
uint8_t read_buffer_[MAVLINK_MAX_PACKET_LEN]