Line data Source code
1 : #pragma once 2 : 3 : #include "AP_RCProtocol_config.h" 4 : 5 : #if AP_RCPROTOCOL_UDP_ENABLED 6 : 7 : /* 8 : * Reads fixed-length packets containing either 8 or 16 2-byte values, 9 : * and interprets them as RC input. 10 : */ 11 : 12 : #include "AP_RCProtocol_Backend.h" 13 : 14 : #include <AP_Common/missing/endian.h> 15 : #include <AP_HAL/utility/Socket_native.h> 16 : 17 : class AP_RCProtocol_UDP : public AP_RCProtocol_Backend { 18 : public: 19 : 20 : using AP_RCProtocol_Backend::AP_RCProtocol_Backend; 21 : 22 : void update() override; 23 : 24 : #if AP_RCPROTOCOL_FDM_ENABLED 25 2094 : void set_fdm_backend(class AP_RCProtocol_FDM *_fdm_backend) { 26 2094 : fdm_backend = _fdm_backend; 27 2094 : } 28 : #endif 29 : 30 : private: 31 : 32 : bool init(); 33 : bool init_done; 34 : bool init_error_reported = false; 35 : 36 : uint32_t last_input_ms; 37 : 38 : void read_all_socket_input(void); 39 : SocketAPM_native rc_in{true}; // "true" means "datagram" 40 : 41 : // these are the values that will be fed into the autopilot. 42 : // Packets we receive usually only contain a subset of channel 43 : // values to insert into here: 44 : uint16_t pwm_input[16]; 45 : uint8_t num_channels; 46 : 47 : void set_default_pwm_input_values(); 48 : 49 : #if AP_RCPROTOCOL_FDM_ENABLED 50 : AP_RCProtocol_FDM *fdm_backend; 51 : #endif 52 : }; 53 : 54 : 55 : #endif // AP_RCPROTOCOL_UDP_ENABLED