LCOV - code coverage report
Current view: top level - SITL - SIM_RF_Lanbao.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 10 10 100.0 %
Date: 2026-09-09 11:02:08 Functions: 1 1 100.0 %

          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             :   Simulator for the Lanbao rangefinder 
      17             : */
      18             : 
      19             : #include "SIM_RF_Lanbao.h"
      20             : 
      21             : #include <GCS_MAVLink/GCS.h>
      22             : #include <stdio.h>
      23             : 
      24             : 
      25             : using namespace SITL;
      26             : 
      27         353 : uint32_t RF_Lanbao::packet_for_alt(float alt_m, uint8_t *buffer, uint8_t buflen)
      28             : {
      29         353 :     const uint16_t alt_mm = alt_m * 1000;
      30             : 
      31         353 :     buffer[0] = 0xA5;
      32         353 :     buffer[1] = 0x5A;
      33         353 :     buffer[2] = alt_mm >> 8;
      34         353 :     buffer[3] = alt_mm & 0xff;
      35             : 
      36         353 :     const uint16_t crc = calc_crc_modbus(buffer, 4);
      37         353 :     buffer[4] = crc & 0xff;
      38         353 :     buffer[5] = crc >> 8;
      39             : 
      40         353 :     return 6;
      41             : }

Generated by: LCOV version 1.14