AP_Mount: prevent SIYI driver crash if serial port not setup

if MNT1_TYPE=8 and no serial protocol set to gimbal then a camera
trigger can crash the vehicle
This commit is contained in:
Andrew Tridgell 2023-07-11 19:56:12 +10:00 committed by Randy Mackay
parent ff95aa929d
commit 9454b54a1d
1 changed files with 3 additions and 0 deletions

View File

@ -485,6 +485,9 @@ void AP_Mount_Siyi::process_packet()
// returns true on success, false if outgoing serial buffer is full
bool AP_Mount_Siyi::send_packet(SiyiCommandId cmd_id, const uint8_t* databuff, uint8_t databuff_len)
{
if (!_initialised) {
return false;
}
// calculate and sanity check packet size
const uint16_t packet_size = AP_MOUNT_SIYI_PACKETLEN_MIN + databuff_len;
if (packet_size > AP_MOUNT_SIYI_PACKETLEN_MAX) {