Line data Source code
1 : /* 2 : This program is free software: you can redistribute it and/or modify 3 : it under the terms of the GNU General Public License as published by 4 : the Free Software Foundation, either version 3 of the License, or 5 : (at your option) any later version. 6 : 7 : This program is distributed in the hope that it will be useful, 8 : but WITHOUT ANY WARRANTY; without even the implied warranty of 9 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 : GNU General Public License for more details. 11 : 12 : You should have received a copy of the GNU General Public License 13 : along with this program. If not, see <http://www.gnu.org/licenses/>. 14 : */ 15 : /* 16 : Simulated CRSF device 17 : 18 : ./Tools/autotest/sim_vehicle.py --gdb --debug -v ArduCopter -A --serial5=sim:crsf --speedup=1 19 : 20 : param set SERIAL5_PROTOCOL 23 21 : reboot 22 : 23 : arm throttle 24 : rc 3 1600 25 : 26 : */ 27 : 28 : #pragma once 29 : 30 : #include "SIM_config.h" 31 : 32 : #if AP_SIM_CRSF_ENABLED 33 : 34 : #include "SIM_Aircraft.h" 35 : #include <SITL/SITL.h> 36 : #include "SIM_SerialDevice.h" 37 : 38 : namespace SITL { 39 : 40 : class CRSF : public SerialDevice { 41 : public: 42 : 43 0 : CRSF() {}; 44 : 45 : // update state 46 : void update(); 47 : 48 : protected: 49 : enum DataID { 50 : VTX_FRAME = 0x00, 51 : VTX_TELEM = 0x01, 52 : VTX_UNKNOWN = 0x02, 53 : MAX_DATA_FRAMES = 0x03 54 : }; 55 : 56 : const char* dataid_string(DataID id, ssize_t& len); 57 : 58 : char _buffer[64]; 59 : uint16_t _buflen = 0; 60 : uint8_t _id; 61 : uint32_t _last_update_ms; 62 : }; 63 : 64 : } 65 : 66 : #endif // AP_SIM_CRSF_ENABLED