From 15cf25a9e08d426bdf741ed6a42dcdd53f0560d2 Mon Sep 17 00:00:00 2001 From: yelvlab Date: Tue, 28 Jul 2026 19:46:22 +0800 Subject: [PATCH] =?UTF-8?q?feature(command):=E6=B7=BB=E5=8A=A0M5=E5=81=9C?= =?UTF-8?q?=E6=AD=A2=E5=91=BD=E4=BB=A4=EF=BC=8CM5P0=EF=BC=8CM5P1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/command.c | 16 ++++++++++++++-- Src/main.c | 8 +------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Src/command.c b/Src/command.c index 8ee2752..116ce92 100644 --- a/Src/command.c +++ b/Src/command.c @@ -462,7 +462,7 @@ void handle_command(const uint8_t *frame, uint8_t len) { send_response(RESP_TYPE_PARAM_ERR, s_report_status_err, sizeof(s_report_status_err)); return; } - COMMAND_DEBUG("M3 Command(PUSH): Actuator Channel=%u, Duty Cycle=%u", p_val, s_val); + SEGGER_RTT_printf(0, "[COMMAND] M3 Command(PUSH): Actuator Channel=%u, Duty Cycle=%u \n", p_val, s_val); actuator_output((actuator_channel_t)p_val, (uint16_t)s_val, DIRECTION_PUSH); send_response(RESP_TYPE_OK, s_report_status_ok, sizeof(s_report_status_ok)); } @@ -484,12 +484,24 @@ void handle_command(const uint8_t *frame, uint8_t len) { send_response(RESP_TYPE_PARAM_ERR, s_report_status_err, sizeof(s_report_status_err)); return; } - COMMAND_DEBUG("M4 Command(PULL): Actuator Channel=%u, Duty Cycle=%u", p_val, s_val); + SEGGER_RTT_printf(0, "[COMMAND] M4 Command(PULL): Actuator Channel=%u, Duty Cycle=%u \n", p_val, s_val); actuator_output((actuator_channel_t)p_val, (uint16_t)s_val, DIRECTION_PULL); send_response(RESP_TYPE_OK, s_report_status_ok, sizeof(s_report_status_ok)); } return; + case 5u: // M5 stop actuator output + uint32_t p_val = 0; + bool has_p = find_parameter_value(cmd, cmd_len, 'P', &p_val); + if (!has_p || p_val > (uint32_t)ACTUATOR_CH2) { + send_response(RESP_TYPE_PARAM_ERR, s_report_status_err, sizeof(s_report_status_err)); + return; + } + SEGGER_RTT_printf(0, "[COMMAND] M5 Command(STOP): Actuator Channel=%u \n", p_val); + actuator_stop((actuator_channel_t)p_val); + send_response(RESP_TYPE_OK, s_report_status_ok, sizeof(s_report_status_ok)); + return; + /* ========================================== * M888 软件重启命令 * ========================================== */ diff --git a/Src/main.c b/Src/main.c index cd94610..0f10291 100644 --- a/Src/main.c +++ b/Src/main.c @@ -53,9 +53,6 @@ int main(void) { led_init(); mcu_detect_and_config(); - - // delay_ms(1000); - systick_config(); uart_ring_buffer_init(); @@ -63,10 +60,6 @@ int main(void) actuator_init(); - // actuator_output(ACTUATOR_CH1, 800, DIRECTION_PULL); // Set actuator channel 1 to high, channel 2 to low - - // i2c_config(); - #if DEBUG_MODE == CFG_ENABLE printf("Hello World!\r\n"); #endif @@ -82,6 +75,7 @@ int main(void) #endif /* ========== Command Testing ========== */ + // command_execute("M3P0S999"); /* ========== */