From d1bcd2c5e15ed76753809283a4240141c5b9617c Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Sat, 2 Sep 2023 15:21:35 +1000 Subject: [PATCH] AP_Mount: allow more libraries to compile with no HAL_GCS_ENABLED --- libraries/AP_Mount/AP_Mount.cpp | 2 ++ libraries/AP_Mount/AP_Mount_Backend.cpp | 4 +++- libraries/AP_Mount/AP_Mount_Siyi.cpp | 15 ++++++++------- libraries/AP_Mount/AP_Mount_config.h | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/libraries/AP_Mount/AP_Mount.cpp b/libraries/AP_Mount/AP_Mount.cpp index cde20c1b16..5f582ffdbb 100644 --- a/libraries/AP_Mount/AP_Mount.cpp +++ b/libraries/AP_Mount/AP_Mount.cpp @@ -582,6 +582,7 @@ void AP_Mount::handle_mount_control(const mavlink_message_t &msg) } #endif +#if HAL_GCS_ENABLED // send a GIMBAL_DEVICE_ATTITUDE_STATUS message to GCS void AP_Mount::send_gimbal_device_attitude_status(mavlink_channel_t chan) { @@ -614,6 +615,7 @@ void AP_Mount::send_gimbal_manager_status(mavlink_channel_t chan) } } } +#endif // HAL_GCS_ENABLED // get mount's current attitude in euler angles in degrees. yaw angle is in body-frame // returns true on success diff --git a/libraries/AP_Mount/AP_Mount_Backend.cpp b/libraries/AP_Mount/AP_Mount_Backend.cpp index d0e71daffc..c50ab5a5d5 100644 --- a/libraries/AP_Mount/AP_Mount_Backend.cpp +++ b/libraries/AP_Mount/AP_Mount_Backend.cpp @@ -116,6 +116,7 @@ void AP_Mount_Backend::handle_mount_configure(const mavlink_mount_configure_t &p } #endif +#if HAL_GCS_ENABLED // send a GIMBAL_DEVICE_ATTITUDE_STATUS message to GCS void AP_Mount_Backend::send_gimbal_device_attitude_status(mavlink_channel_t chan) { @@ -146,6 +147,7 @@ void AP_Mount_Backend::send_gimbal_device_attitude_status(mavlink_channel_t chan std::numeric_limits::quiet_NaN(), // delta_yaw_velocity (NaN for unknonw) _instance + 1); // gimbal_device_id } +#endif // return gimbal manager capability flags used by GIMBAL_MANAGER_INFORMATION message uint32_t AP_Mount_Backend::get_gimbal_manager_capability_flags() const @@ -654,7 +656,7 @@ void AP_Mount_Backend::send_warning_to_GCS(const char* warning_str) return; } - gcs().send_text(MAV_SEVERITY_WARNING, "Mount: %s", warning_str); + GCS_SEND_TEXT(MAV_SEVERITY_WARNING, "Mount: %s", warning_str); _last_warning_ms = now_ms; } diff --git a/libraries/AP_Mount/AP_Mount_Siyi.cpp b/libraries/AP_Mount/AP_Mount_Siyi.cpp index 5435b6c5df..1c81b32679 100644 --- a/libraries/AP_Mount/AP_Mount_Siyi.cpp +++ b/libraries/AP_Mount/AP_Mount_Siyi.cpp @@ -334,20 +334,20 @@ void AP_Mount_Siyi::process_packet() _msg_buff[_msg_buff_data_start+0] // firmware revision (aka patch) }; - gcs().send_text(MAV_SEVERITY_INFO, "Mount: SiyiCam fw:%u.%u.%u", + GCS_SEND_TEXT(MAV_SEVERITY_INFO, "Mount: SiyiCam fw:%u.%u.%u", (unsigned)_cam_firmware_version.major, // firmware major version (unsigned)_cam_firmware_version.minor, // firmware minor version (unsigned)_cam_firmware_version.patch); // firmware revision // display gimbal info to user - gcs().send_text(MAV_SEVERITY_INFO, "Mount: Siyi fw:%u.%u.%u", + GCS_SEND_TEXT(MAV_SEVERITY_INFO, "Mount: Siyi fw:%u.%u.%u", (unsigned)_msg_buff[_msg_buff_data_start+6], // firmware major version (unsigned)_msg_buff[_msg_buff_data_start+5], // firmware minor version (unsigned)_msg_buff[_msg_buff_data_start+4]); // firmware revision // display zoom firmware version for those that have it if (_parsed_msg.data_bytes_received >= 12) { - gcs().send_text(MAV_SEVERITY_INFO, "Mount: SiyiZoom fw:%u.%u.%u", + GCS_SEND_TEXT(MAV_SEVERITY_INFO, "Mount: SiyiZoom fw:%u.%u.%u", (unsigned)_msg_buff[_msg_buff_data_start+10], // firmware major version (unsigned)_msg_buff[_msg_buff_data_start+9], // firmware minor version (unsigned)_msg_buff[_msg_buff_data_start+8]); // firmware revision @@ -362,7 +362,7 @@ void AP_Mount_Siyi::process_packet() for (uint8_t i=1; i 0; if (recording != _last_record_video) { - gcs().send_text(MAV_SEVERITY_INFO, "Siyi: recording %s", recording ? "ON" : "OFF"); + GCS_SEND_TEXT(MAV_SEVERITY_INFO, "Siyi: recording %s", recording ? "ON" : "OFF"); } _last_record_video = recording; debug("GimConf hdr:%u rec:%u foll:%u mntdir:%u", (unsigned)_msg_buff[_msg_buff_data_start+1], @@ -449,12 +449,13 @@ void AP_Mount_Siyi::process_packet() } const uint8_t func_feedback_info = _msg_buff[_msg_buff_data_start]; const char* err_prefix = "Mount: Siyi"; + (void)err_prefix; // in case !HAL_GCS_ENABLED switch ((FunctionFeedbackInfo)func_feedback_info) { case FunctionFeedbackInfo::SUCCESS: debug("FnFeedB success"); break; case FunctionFeedbackInfo::FAILED_TO_TAKE_PHOTO: - gcs().send_text(MAV_SEVERITY_ERROR, "%s failed to take picture", err_prefix); + GCS_SEND_TEXT(MAV_SEVERITY_ERROR, "%s failed to take picture", err_prefix); break; case FunctionFeedbackInfo::HDR_ON: debug("HDR on"); @@ -463,7 +464,7 @@ void AP_Mount_Siyi::process_packet() debug("HDR off"); break; case FunctionFeedbackInfo::FAILED_TO_RECORD_VIDEO: - gcs().send_text(MAV_SEVERITY_ERROR, "%s failed to record video", err_prefix); + GCS_SEND_TEXT(MAV_SEVERITY_ERROR, "%s failed to record video", err_prefix); break; default: debug("FnFeedB unexpected val:%u", (unsigned)func_feedback_info); diff --git a/libraries/AP_Mount/AP_Mount_config.h b/libraries/AP_Mount/AP_Mount_config.h index 9967ad312a..3195a5ce38 100644 --- a/libraries/AP_Mount/AP_Mount_config.h +++ b/libraries/AP_Mount/AP_Mount_config.h @@ -34,7 +34,7 @@ #endif #ifndef HAL_MOUNT_STORM32MAVLINK_ENABLED -#define HAL_MOUNT_STORM32MAVLINK_ENABLED AP_MOUNT_BACKEND_DEFAULT_ENABLED +#define HAL_MOUNT_STORM32MAVLINK_ENABLED AP_MOUNT_BACKEND_DEFAULT_ENABLED && HAL_GCS_ENABLED #endif #ifndef HAL_MOUNT_STORM32SERIAL_ENABLED