Skip to content

Commit

Permalink
Mount: Siyi waits for cam version for 30 sec only
Browse files Browse the repository at this point in the history
  • Loading branch information
rmackay9 committed Apr 19, 2024
1 parent 913ec4b commit 57a50b9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion libraries/AP_Mount/AP_Mount_Siyi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,21 @@ void AP_Mount_Siyi::process_packet()
_fw_version.gimbal.minor = _msg_buff[_msg_buff_data_start+5]; // firmware minor version
_fw_version.gimbal.patch = _msg_buff[_msg_buff_data_start+4]; // firmware revision (aka patch)

// check how long we've been trying to get the firmware version
const uint32_t now_ms = AP_HAL::millis();
if (_fw_version_first_recv_ms == 0) {
_fw_version_first_recv_ms = now_ms;
}

// wait for camera version for up to 30 seconds
const bool giveup = (now_ms - _fw_version_first_recv_ms) > 30000;

// camera firmware version may be all zero soon after startup. giveup and try again later
if (_fw_version.camera.major == 0 && _fw_version.camera.minor == 0 && _fw_version.camera.patch == 0) {
if (!giveup && _fw_version.camera.major == 0 && _fw_version.camera.minor == 0 && _fw_version.camera.patch == 0) {
GCS_SEND_TEXT(MAV_SEVERITY_INFO, "Mount: Siyi camera fw v%u.%u.%u",
_fw_version.camera.major,
_fw_version.camera.minor,
_fw_version.camera.patch);
break;
}

Expand Down
1 change: 1 addition & 0 deletions libraries/AP_Mount/AP_Mount_Siyi.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ class AP_Mount_Siyi : public AP_Mount_Backend
bool _got_hardware_id; // true once hardware id ha been received

FirmwareVersion _fw_version; // firmware version (for reporting for GCS)
uint32_t _fw_version_first_recv_ms; // system time firmware version was first received (we giveup eventually)

// buffer holding bytes from latest packet. This is only used to calculate the crc
uint8_t _msg_buff[AP_MOUNT_SIYI_PACKETLEN_MAX];
Expand Down

0 comments on commit 57a50b9

Please sign in to comment.