Line data Source code
1 : #pragma once 2 : 3 : #include <SITL/SITL.h> 4 : #include "SIM_SerialDevice.h" 5 : #include <AP_HAL/utility/DataRateLimit.h> 6 : #include <AP_HAL/utility/Socket_native.h> 7 : 8 : namespace SITL { 9 : 10 : class ELRS : public SerialDevice { 11 : public: 12 : ELRS(const uint8_t portNumber, HALSITL::SITL_State_Common *sitl_state); 13 : 14 0 : uint32_t device_baud() const override { return 460800; } 15 : 16 : void update(); 17 : 18 : private: 19 : void sendQueuedData(); 20 : 21 : struct { 22 : mavlink_message_t rxmsg; 23 : mavlink_status_t status; 24 : } mavlink; 25 : 26 : uint8_t mavlink_parse_char_helper(uint8_t c, mavlink_message_t* r_message, mavlink_status_t* r_mavlink_status); 27 : 28 : ByteBuffer mavlinkInputBuffer; 29 : ByteBuffer mavlinkOutputBuffer; 30 : 31 : DataRateLimit input_limit; 32 : DataRateLimit output_limit; 33 : 34 : uint32_t lastSentFlowCtrl; 35 : 36 : const uint8_t this_system_id; 37 : const uint8_t this_component_id; 38 : 39 : // Air data rate limits in bytes per second 40 : const float input_data_rate; 41 : const float output_data_rate; 42 : 43 : // Sockets for communicating with GCS 44 : SocketAPM_native listener {false}; 45 : SocketAPM_native *sock = nullptr; 46 : const char *target_address; 47 : const uint16_t target_port; 48 : 49 : }; 50 : 51 : }