generated from hulk/gd32e23x_template_cmake_vscode
add(cmd):构建推杆的命令M3推出,M4拉回
This commit is contained in:
@@ -445,6 +445,51 @@ void handle_command(const uint8_t *frame, uint8_t len) {
|
||||
send_response(RESP_TYPE_OK, s_report_status_ok, sizeof(s_report_status_ok));
|
||||
return;
|
||||
|
||||
case 3u: // M3 p_val: Actuator Channel. s_val: Actuator Duty Cycle
|
||||
{
|
||||
uint32_t p_val = 0;
|
||||
uint32_t s_val = 0;
|
||||
|
||||
bool has_p = find_parameter_value(cmd, cmd_len, 'P', &p_val);
|
||||
bool has_s = find_parameter_value(cmd, cmd_len, 'S', &s_val);
|
||||
|
||||
if (!(has_p && has_s)) {
|
||||
send_response(RESP_TYPE_PARAM_ERR, s_report_status_err, sizeof(s_report_status_err));
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_val > (uint32_t)ACTUATOR_CH2 || s_val > 999u) {
|
||||
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);
|
||||
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));
|
||||
}
|
||||
return;
|
||||
case 4u: // M4 p_val: Actuator Channel. s_val: Actuator Duty Cycle
|
||||
{
|
||||
uint32_t p_val = 0;
|
||||
uint32_t s_val = 0;
|
||||
|
||||
bool has_p = find_parameter_value(cmd, cmd_len, 'P', &p_val);
|
||||
bool has_s = find_parameter_value(cmd, cmd_len, 'S', &s_val);
|
||||
|
||||
if (!(has_p && has_s)) {
|
||||
send_response(RESP_TYPE_PARAM_ERR, s_report_status_err, sizeof(s_report_status_err));
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_val > (uint32_t)ACTUATOR_CH2 || s_val > 999u) {
|
||||
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);
|
||||
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;
|
||||
|
||||
/* ==========================================
|
||||
* M888 软件重启命令
|
||||
* ========================================== */
|
||||
|
||||
Reference in New Issue
Block a user