diff --git a/components/cmdscheduler/cmd_scheduler_v2.cpp b/components/cmdscheduler/cmd_scheduler_v2.cpp index 0da0aa8..36d79fb 100644 --- a/components/cmdscheduler/cmd_scheduler_v2.cpp +++ b/components/cmdscheduler/cmd_scheduler_v2.cpp @@ -78,11 +78,12 @@ void CmdSchedulerV2::schedule() { for (int i = 0; i < m_rxsize; i++) { if (rxbuf[i] != '\0') { // ZLOGI(TAG, "docmd: %s", &rxbuf[i]); - printf("docmd: %s \n", &rxbuf[i]); + ZLOGI(TAG, "docmd: %s", &rxbuf[i]); int inext = strlen(&rxbuf[i]) + i; memset(&ack, 0, sizeof(ack)); callcmd(&rxbuf[i], &ack); + dumpack(&ack); i = inext; if (ack.ecode != 0) { @@ -97,24 +98,25 @@ void CmdSchedulerV2::schedule() { } void CmdSchedulerV2::dumpack(ICmdParserACK* ack) { if (ack->ecode == 0) { - printf("\tok -> "); if (ack->acktype == ack->kAckType_none) { - printf("\n"); + ZLOGI(TAG, "\tok"); } else if (ack->acktype == ack->kAckType_int32) { + ZLOGI(TAG, "\tok-->"); for (int i = 0; i < ack->getAckInt32Num(); i++) { - printf(" %d", (int)ack->getAckInt32Val(i)); + // printf(" %d", (int)ack->getAckInt32Val(i)); + ZLOGI(TAG, "\t\t%d", (int)ack->getAckInt32Val(i)); } - printf("\n"); } else if (ack->acktype == ack->kAckType_buf) { + ZLOGI(TAG, "\tok-->"); for (int i = 0; i < ack->rawlen; i++) { printf(" %02x", ack->rawdata[i]); } printf("\n"); } else { - printf("\n"); + ZLOGI(TAG, "\tok"); } } else { - printf("\tfailed:%s(%d)\n", err::error2str(ack->ecode),(int) ack->ecode); + ZLOGI(TAG, "\tfailed:%s(%d)", err::error2str(ack->ecode), (int)ack->ecode); } } diff --git a/components/eq_20_asb_motor/eq20_servomotor.cpp b/components/eq_20_asb_motor/eq20_servomotor.cpp index b25556d..f2e8c15 100644 --- a/components/eq_20_asb_motor/eq20_servomotor.cpp +++ b/components/eq_20_asb_motor/eq20_servomotor.cpp @@ -263,12 +263,13 @@ int32_t Eq20ServoMotor::module_writeio(int32_t io) { return err::koperation_not_ int32_t Eq20ServoMotor::module_read_adc(int32_t adcindex, int32_t *adc) { return err::koperation_not_support; } -int32_t Eq20ServoMotor::motor_enable(int32_t varenable) { return enable(varenable); } +int32_t Eq20ServoMotor::motor_enable(int32_t varenable) { + return enable(varenable); } int32_t Eq20ServoMotor::motor_rotate(int32_t direction, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; } int32_t Eq20ServoMotor::motor_move_by(int32_t distance, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; } int32_t Eq20ServoMotor::motor_move_to(int32_t position, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; } -int32_t Eq20ServoMotor::motor_move_to_with_torque(int32_t pos, int32_t torque) { return err::koperation_not_support; } +int32_t Eq20ServoMotor::motor_move_to_with_torque(int32_t direction, int32_t torque) { return err::koperation_not_support; } int32_t Eq20ServoMotor::motor_rotate_acctime(int32_t direction, int32_t motor_velocity, int32_t acctime) { return rotate(direction * motor_velocity, acctime); }; int32_t Eq20ServoMotor::motor_move_by_acctime(int32_t distance, int32_t motor_velocity, int32_t acctime) { return move_by(distance, motor_velocity, acctime); }; diff --git a/components/eq_20_asb_motor/eq20_servomotor.hpp b/components/eq_20_asb_motor/eq20_servomotor.hpp index a7df57b..cf78fac 100644 --- a/components/eq_20_asb_motor/eq20_servomotor.hpp +++ b/components/eq_20_asb_motor/eq20_servomotor.hpp @@ -118,7 +118,7 @@ class Eq20ServoMotor : public ZIModule, public ZIMotor { virtual int32_t motor_rotate(int32_t direction, int32_t motor_velocity, int32_t acc) override; virtual int32_t motor_move_by(int32_t distance, int32_t motor_velocity, int32_t acc) override; virtual int32_t motor_move_to(int32_t position, int32_t motor_velocity, int32_t acc) override; - virtual int32_t motor_move_to_with_torque(int32_t pos, int32_t torque) override; + virtual int32_t motor_move_to_with_torque(int32_t direction, int32_t torque) override; virtual int32_t motor_rotate_acctime(int32_t direction, int32_t motor_velocity, int32_t acctime) override; virtual int32_t motor_move_by_acctime(int32_t distance, int32_t motor_velocity, int32_t acctime) override; diff --git a/components/mini_servo_motor/mini_servo_motor_ctrl_module.cpp b/components/mini_servo_motor/mini_servo_motor_ctrl_module.cpp index 2f653d5..fcf5aea 100644 --- a/components/mini_servo_motor/mini_servo_motor_ctrl_module.cpp +++ b/components/mini_servo_motor/mini_servo_motor_ctrl_module.cpp @@ -313,7 +313,13 @@ int32_t MiniRobotCtrlModule::motor_enable(int32_t varenable) { return enable(var int32_t MiniRobotCtrlModule::motor_rotate(int32_t direction, int32_t motor_velocity, int32_t acc) { return rotate(direction, motor_velocity, acc, nullptr); } int32_t MiniRobotCtrlModule::motor_move_by(int32_t distance, int32_t motor_velocity, int32_t acc) { return move_by(distance, motor_velocity, acc, nullptr); } int32_t MiniRobotCtrlModule::motor_move_to(int32_t position, int32_t motor_velocity, int32_t acc) { return move_to(position, motor_velocity, acc, nullptr); } -int32_t MiniRobotCtrlModule::motor_move_to_with_torque(int32_t pos, int32_t torque) { return move_to(pos, 0, torque, nullptr); } +int32_t MiniRobotCtrlModule::motor_move_to_with_torque(int32_t direction, int32_t torque) { + if (direction >= 0) { + return move_forward(torque); + } else { + return move_backward(torque); + } +} int32_t MiniRobotCtrlModule::motor_rotate_acctime(int32_t direction, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; } int32_t MiniRobotCtrlModule::motor_move_by_acctime(int32_t distance, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; } diff --git a/components/mini_servo_motor/mini_servo_motor_ctrl_module.hpp b/components/mini_servo_motor/mini_servo_motor_ctrl_module.hpp index e50c096..74cf44a 100644 --- a/components/mini_servo_motor/mini_servo_motor_ctrl_module.hpp +++ b/components/mini_servo_motor/mini_servo_motor_ctrl_module.hpp @@ -67,7 +67,7 @@ class MiniRobotCtrlModule : public I_MiniServoModule, public ZIModule, public ZI virtual int32_t motor_rotate(int32_t direction, int32_t motor_velocity, int32_t acc) override; virtual int32_t motor_move_by(int32_t distance, int32_t motor_velocity, int32_t acc) override; virtual int32_t motor_move_to(int32_t position, int32_t motor_velocity, int32_t acc) override; - virtual int32_t motor_move_to_with_torque(int32_t pos, int32_t torque) override; + virtual int32_t motor_move_to_with_torque(int32_t direction, int32_t torque) override; virtual int32_t motor_rotate_acctime(int32_t direction, int32_t motor_velocity, int32_t acctime) override; virtual int32_t motor_move_by_acctime(int32_t distance, int32_t motor_velocity, int32_t acctime) override; diff --git a/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp b/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp index 164b953..08457f1 100644 --- a/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp +++ b/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp @@ -763,7 +763,7 @@ int32_t StepMotorCtrlModule::motor_move_to(int32_t tox, int32_t motor_velocity, [this, tox]() { _motor_stop(); }); return 0; } -int32_t StepMotorCtrlModule::motor_move_to_with_torque(int32_t pos, int32_t torque) { return err::koperation_not_support; } +int32_t StepMotorCtrlModule::motor_move_to_with_torque(int32_t direction, int32_t torque) { return err::koperation_not_support; } int32_t StepMotorCtrlModule::motor_rotate_acctime(int32_t direction, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; } int32_t StepMotorCtrlModule::motor_move_by_acctime(int32_t distance, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; } diff --git a/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp b/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp index fc802d8..b5bc3e1 100644 --- a/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp +++ b/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp @@ -130,7 +130,7 @@ class StepMotorCtrlModule : public I_StepMotorCtrlModule, public ZIModule, publi virtual int32_t motor_rotate(int32_t direction, int32_t motor_velocity, int32_t acc) override; virtual int32_t motor_move_by(int32_t distance, int32_t motor_velocity, int32_t acc) override; virtual int32_t motor_move_to(int32_t position, int32_t motor_velocity, int32_t acc) override; - virtual int32_t motor_move_to_with_torque(int32_t pos, int32_t torque) override; + virtual int32_t motor_move_to_with_torque(int32_t direction, int32_t torque) override; virtual int32_t motor_rotate_acctime(int32_t direction, int32_t motor_velocity, int32_t acctime) override; virtual int32_t motor_move_by_acctime(int32_t distance, int32_t motor_velocity, int32_t acctime) override; diff --git a/components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.cpp b/components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.cpp index 581f7a5..3f50b7e 100644 --- a/components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.cpp +++ b/components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.cpp @@ -1,4 +1,5 @@ #include "micro_computer_module_device_script_cmder_paser.hpp" + #include #include "sdk/os/zos.hpp" @@ -7,17 +8,13 @@ using namespace std; #define TAG "CMD" -void MicroComputerModuleDeviceScriptCmderPaser::initialize(ICmdParser* cancmder, ZModuleDeviceManager* deviceManager) { - ZModuleDeviceScriptCmderPaser::initialize(cancmder, deviceManager); - m_cmdParser = cancmder; - m_deviceManager = deviceManager; - - cancmder->regCMD("dumpconfig", "dumpconfig (mid)", 1, [this](int32_t paramN, const char* paraV[], ICmdParserACK* ack) { // - ack->ecode = 0; +void MicroComputerModuleDeviceScriptCmderPaser::do_dumpconfig(int32_t paramN, const char* paraV[], ICmdParserACK* ack) { + // + ack->ecode = 0; - uint16_t moduleId = atoi(paraV[0]); - int32_t configval = 0; - int32_t ecode = 0; + uint16_t moduleId = atoi(paraV[0]); + int32_t configval = 0; + int32_t ecode = 0; #define DUMP_CONFIG(tag, configid) \ ecode = m_deviceManager->module_get_param(moduleId, configid, &configval); \ @@ -25,33 +22,39 @@ void MicroComputerModuleDeviceScriptCmderPaser::initialize(ICmdParser* cancmder, ZLOGI(TAG, "%30s :%d", tag, configval); \ } - DUMP_CONFIG("motor_x_shift", kcfg_motor_x_shift); - DUMP_CONFIG("motor_y_shift", kcfg_motor_y_shift); - DUMP_CONFIG("motor_z_shift", kcfg_motor_z_shift); - DUMP_CONFIG("motor_x_shaft", kcfg_motor_x_shaft); - DUMP_CONFIG("motor_y_shaft", kcfg_motor_y_shaft); - DUMP_CONFIG("motor_z_shaft", kcfg_motor_z_shaft); - DUMP_CONFIG("motor_x_one_circle_pulse", kcfg_motor_x_one_circle_pulse); - DUMP_CONFIG("motor_y_one_circle_pulse", kcfg_motor_y_one_circle_pulse); - DUMP_CONFIG("motor_z_one_circle_pulse", kcfg_motor_z_one_circle_pulse); - DUMP_CONFIG("motor_default_velocity", kcfg_motor_default_velocity); - DUMP_CONFIG("motor_default_acc", kcfg_motor_default_acc); - DUMP_CONFIG("motor_default_dec", kcfg_motor_default_dec); - DUMP_CONFIG("motor_default_break_dec", kcfg_motor_default_break_dec); - DUMP_CONFIG("motor_run_to_zero_max_x_d", kcfg_motor_run_to_zero_max_x_d); - DUMP_CONFIG("motor_run_to_zero_max_y_d", kcfg_motor_run_to_zero_max_y_d); - DUMP_CONFIG("motor_run_to_zero_max_z_d", kcfg_motor_run_to_zero_max_z_d); - DUMP_CONFIG("motor_look_zero_edge_max_x_d", kcfg_motor_look_zero_edge_max_x_d); - DUMP_CONFIG("motor_look_zero_edge_max_y_d", kcfg_motor_look_zero_edge_max_y_d); - DUMP_CONFIG("motor_look_zero_edge_max_z_d", kcfg_motor_look_zero_edge_max_z_d); - DUMP_CONFIG("motor_run_to_zero_speed", kcfg_motor_run_to_zero_speed); - DUMP_CONFIG("motor_run_to_zero_dec", kcfg_motor_run_to_zero_dec); - DUMP_CONFIG("motor_look_zero_edge_speed", kcfg_motor_look_zero_edge_speed); - DUMP_CONFIG("motor_look_zero_edge_dec", kcfg_motor_look_zero_edge_dec); - DUMP_CONFIG("cfg_stepmotor_ihold", k_cfg_stepmotor_ihold); - DUMP_CONFIG("cfg_stepmotor_irun", k_cfg_stepmotor_irun); - DUMP_CONFIG("cfg_stepmotor_iholddelay", k_cfg_stepmotor_iholddelay); - DUMP_CONFIG("cfg_xyrobot_robot_type", k_cfg_xyrobot_robot_type); - - }); + DUMP_CONFIG("motor_x_shift", kcfg_motor_x_shift); + DUMP_CONFIG("motor_y_shift", kcfg_motor_y_shift); + DUMP_CONFIG("motor_z_shift", kcfg_motor_z_shift); + DUMP_CONFIG("motor_x_shaft", kcfg_motor_x_shaft); + DUMP_CONFIG("motor_y_shaft", kcfg_motor_y_shaft); + DUMP_CONFIG("motor_z_shaft", kcfg_motor_z_shaft); + DUMP_CONFIG("motor_x_one_circle_pulse", kcfg_motor_x_one_circle_pulse); + DUMP_CONFIG("motor_y_one_circle_pulse", kcfg_motor_y_one_circle_pulse); + DUMP_CONFIG("motor_z_one_circle_pulse", kcfg_motor_z_one_circle_pulse); + DUMP_CONFIG("motor_default_velocity", kcfg_motor_default_velocity); + DUMP_CONFIG("motor_default_acc", kcfg_motor_default_acc); + DUMP_CONFIG("motor_default_dec", kcfg_motor_default_dec); + DUMP_CONFIG("motor_default_break_dec", kcfg_motor_default_break_dec); + DUMP_CONFIG("motor_run_to_zero_max_x_d", kcfg_motor_run_to_zero_max_x_d); + DUMP_CONFIG("motor_run_to_zero_max_y_d", kcfg_motor_run_to_zero_max_y_d); + DUMP_CONFIG("motor_run_to_zero_max_z_d", kcfg_motor_run_to_zero_max_z_d); + DUMP_CONFIG("motor_look_zero_edge_max_x_d", kcfg_motor_look_zero_edge_max_x_d); + DUMP_CONFIG("motor_look_zero_edge_max_y_d", kcfg_motor_look_zero_edge_max_y_d); + DUMP_CONFIG("motor_look_zero_edge_max_z_d", kcfg_motor_look_zero_edge_max_z_d); + DUMP_CONFIG("motor_run_to_zero_speed", kcfg_motor_run_to_zero_speed); + DUMP_CONFIG("motor_run_to_zero_dec", kcfg_motor_run_to_zero_dec); + DUMP_CONFIG("motor_look_zero_edge_speed", kcfg_motor_look_zero_edge_speed); + DUMP_CONFIG("motor_look_zero_edge_dec", kcfg_motor_look_zero_edge_dec); + DUMP_CONFIG("cfg_stepmotor_ihold", k_cfg_stepmotor_ihold); + DUMP_CONFIG("cfg_stepmotor_irun", k_cfg_stepmotor_irun); + DUMP_CONFIG("cfg_stepmotor_iholddelay", k_cfg_stepmotor_iholddelay); + DUMP_CONFIG("cfg_xyrobot_robot_type", k_cfg_xyrobot_robot_type); +} + +void MicroComputerModuleDeviceScriptCmderPaser::initialize(ICmdParser* cancmder, ZModuleDeviceManager* deviceManager) { + ZModuleDeviceScriptCmderPaser::initialize(cancmder, deviceManager); + m_cmdParser = cancmder; + m_deviceManager = deviceManager; + + cancmder->regCMD("dumpconfig", "dumpconfig (mid)", 1, [this](int32_t paramN, const char* paraV[], ICmdParserACK* ack) { do_dumpconfig(paramN, paraV, ack); }); } diff --git a/components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.hpp b/components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.hpp index 8750f65..0217897 100644 --- a/components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.hpp +++ b/components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.hpp @@ -9,8 +9,8 @@ class MicroComputerModuleDeviceScriptCmderPaser : public ZModuleDeviceScriptCmde public: void initialize(ICmdParser* cancmder, ZModuleDeviceManager* deviceManager); + + void do_dumpconfig(int32_t paramN, const char* paraV[], ICmdParserACK* ack) ; }; } // namespace iflytop - - diff --git a/components/zprotocols/zcancmder_v2 b/components/zprotocols/zcancmder_v2 index 5fc1f50..9aa75ad 160000 --- a/components/zprotocols/zcancmder_v2 +++ b/components/zprotocols/zcancmder_v2 @@ -1 +1 @@ -Subproject commit 5fc1f504ef48eccc931c2a80315ef57e462e3c27 +Subproject commit 9aa75ad06a2eadd5d6656eba7c45af3d359080f1