From 3e4d2f9020cbd79e821ab1b9965e6b4517c0f7c9 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Sun, 28 Apr 2024 18:58:52 +0800 Subject: [PATCH] update --- README.md | 2 ++ iflytop_canbus_protocol | 2 +- usrc/protocol_impl/protocol_impl_service.cpp | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 73a28b8..cb025b5 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,6 @@ ``` + V2: + 完成需求 ``` \ No newline at end of file diff --git a/iflytop_canbus_protocol b/iflytop_canbus_protocol index 0d30ade..147a3d0 160000 --- a/iflytop_canbus_protocol +++ b/iflytop_canbus_protocol @@ -1 +1 @@ -Subproject commit 0d30adef26695d979d4f62a051d896aab1354734 +Subproject commit 147a3d04808e51599910a6e47f082ae91a8bc8f0 diff --git a/usrc/protocol_impl/protocol_impl_service.cpp b/usrc/protocol_impl/protocol_impl_service.cpp index f804d58..ed07797 100644 --- a/usrc/protocol_impl/protocol_impl_service.cpp +++ b/usrc/protocol_impl/protocol_impl_service.cpp @@ -235,6 +235,24 @@ static void pump_func_impl(uint8_t from, uint8_t to, uint8_t* rawpacket, size_t int32_t regval = Hardware::ins().motor(subindex)->readInt(regadd); zcanbus_send_ack(packet, (uint8_t*)®val, sizeof(regval)); } + + // ping + else if (packet->function_id == kcmd_pump_get_subic_reg) { + CHECK_PARAM_LEN(paramNum, 1); + + int32_t subindex = GET_PARAM(packet->params, 0); + + if (subindex >= Hardware::ins().motorNum()) { + zcanbus_send_errorack(packet, kerr_invalid_param); + return; + } + + if (!Hardware::ins().motor(subindex)->ping()) { + zcanbus_send_errorack(packet, kerr_motor_subdevice_offline); + return; + } + zcanbus_send_ack(packet, NULL, 0); + } } static void others_func_impl(uint8_t from, uint8_t to, uint8_t* rawpacket, size_t len) {