From 787d03c1a36d984f89b6f1ef058e59541a7c3b29 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 11 Jul 2023 19:56:12 +1000 Subject: [PATCH] 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 --- libraries/AP_Mount/AP_Mount_Siyi.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/AP_Mount/AP_Mount_Siyi.cpp b/libraries/AP_Mount/AP_Mount_Siyi.cpp index dacbb4d1c1..6737c06bbc 100644 --- a/libraries/AP_Mount/AP_Mount_Siyi.cpp +++ b/libraries/AP_Mount/AP_Mount_Siyi.cpp @@ -475,6 +475,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) {