2019-11-07 00:03:44 -04:00
|
|
|
/*
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
/*
|
2021-10-25 18:41:11 -03:00
|
|
|
Simulator for the USD1 v1 rangefinder
|
2019-11-07 00:03:44 -04:00
|
|
|
*/
|
|
|
|
|
2021-10-25 18:41:11 -03:00
|
|
|
#include "SIM_RF_USD1_v1.h"
|
2019-11-07 00:03:44 -04:00
|
|
|
|
|
|
|
using namespace SITL;
|
|
|
|
|
2021-10-25 18:41:11 -03:00
|
|
|
uint32_t RF_USD1_v1::packet_for_alt(uint16_t alt_cm, uint8_t *buffer, uint8_t buflen)
|
2019-11-07 00:03:44 -04:00
|
|
|
{
|
|
|
|
buffer[0] = 0xFE;
|
|
|
|
buffer[1] = 0; // unused?
|
|
|
|
buffer[2] = alt_cm & 0xff;
|
|
|
|
buffer[3] = alt_cm >> 8;
|
|
|
|
buffer[4] = 0; // unused?
|
|
|
|
// checksum:
|
|
|
|
buffer[5] = buffer[1] + buffer[2] + buffer[3] + buffer[4];
|
|
|
|
|
|
|
|
return 6;
|
|
|
|
}
|