diff --git a/src/modules/uavcan/uavcan_servers.cpp b/src/modules/uavcan/uavcan_servers.cpp index f63aafe3e0..7206e739cd 100644 --- a/src/modules/uavcan/uavcan_servers.cpp +++ b/src/modules/uavcan/uavcan_servers.cpp @@ -504,7 +504,6 @@ pthread_addr_t UavcanServers::run(pthread_addr_t) _esc_enumeration_active = command_id; _esc_enumeration_index = 0; _esc_count = 0; - beep(_esc_enumeration_active ? 500.0F : 1000.0F); uavcan::protocol::enumeration::Begin::Request req; // TODO: Incorrect implementation; the parameter name field should be left empty. // Leaving it as-is to avoid breaking compatibility with non-compliant nodes. @@ -513,6 +512,9 @@ pthread_addr_t UavcanServers::run(pthread_addr_t) call_res = _enumeration_client.call(get_next_active_node_id(1), req); if (call_res < 0) { warnx("UAVCAN ESC enumeration: couldn't send initial Begin request: %d", call_res); + beep(BeepFrequencyError); + } else { + beep(BeepFrequencyGenericIndication); } break; } @@ -596,11 +598,13 @@ void UavcanServers::cb_getset(const uavcan::ServiceCallResult &result) { + const bool this_is_the_last_one = + _esc_enumeration_index >= uavcan::equipment::esc::RawCommand::FieldTypes::cmd::MaxSize - 1 || + _esc_enumeration_index >= _esc_count; + if (!result.isSuccessful()) { warnx("UAVCAN ESC enumeration: save request for node %hhu timed out.", result.getCallID().server_node_id.get()); - beep(100.0F); + beep(BeepFrequencyError); } else if (!result.getResponse().ok) { warnx("UAVCAN ESC enumeration: save request for node %hhu rejected", result.getCallID().server_node_id.get()); - beep(100.0F); + beep(BeepFrequencyError); } else { warnx("UAVCAN ESC enumeration: save request for node %hhu completed OK.", result.getCallID().server_node_id.get()); - beep(2000.0F); + beep(this_is_the_last_one ? BeepFrequencySuccess : BeepFrequencyGenericIndication); } warnx("UAVCAN ESC enumeration: completed %hhu of %hhu", _esc_enumeration_index, _esc_count); - if (_esc_enumeration_index == uavcan::equipment::esc::RawCommand::FieldTypes::cmd::MaxSize - 1 || - _esc_enumeration_index == _esc_count) { + if (this_is_the_last_one) { _esc_enumeration_active = false; // Tell all ESCs to stop enumerating diff --git a/src/modules/uavcan/uavcan_servers.hpp b/src/modules/uavcan/uavcan_servers.hpp index 19df57223f..be3d53ec9e 100644 --- a/src/modules/uavcan/uavcan_servers.hpp +++ b/src/modules/uavcan/uavcan_servers.hpp @@ -79,6 +79,10 @@ class UavcanServers static constexpr unsigned VirtualIfaceBlockAllocationQuota = 80; + static constexpr float BeepFrequencyGenericIndication = 1000.0F; + static constexpr float BeepFrequencySuccess = 2000.0F; + static constexpr float BeepFrequencyError = 100.0F; + public: UavcanServers(uavcan::INode &main_node);