Browse Source

update

master
zhaohe 2 years ago
parent
commit
ef7a7f2a43
  1. 16
      components/cmdscheduler/cmd_scheduler_v2.cpp
  2. 5
      components/eq_20_asb_motor/eq20_servomotor.cpp
  3. 2
      components/eq_20_asb_motor/eq20_servomotor.hpp
  4. 8
      components/mini_servo_motor/mini_servo_motor_ctrl_module.cpp
  5. 2
      components/mini_servo_motor/mini_servo_motor_ctrl_module.hpp
  6. 2
      components/step_motor_ctrl_module/step_motor_ctrl_module.cpp
  7. 2
      components/step_motor_ctrl_module/step_motor_ctrl_module.hpp
  8. 81
      components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.cpp
  9. 4
      components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.hpp
  10. 2
      components/zprotocols/zcancmder_v2

16
components/cmdscheduler/cmd_scheduler_v2.cpp

@ -78,11 +78,12 @@ void CmdSchedulerV2::schedule() {
for (int i = 0; i < m_rxsize; i++) { for (int i = 0; i < m_rxsize; i++) {
if (rxbuf[i] != '\0') { if (rxbuf[i] != '\0') {
// ZLOGI(TAG, "docmd: %s", &rxbuf[i]); // ZLOGI(TAG, "docmd: %s", &rxbuf[i]);
printf("docmd: %s \n", &rxbuf[i]);
ZLOGI(TAG, "docmd: %s", &rxbuf[i]);
int inext = strlen(&rxbuf[i]) + i; int inext = strlen(&rxbuf[i]) + i;
memset(&ack, 0, sizeof(ack)); memset(&ack, 0, sizeof(ack));
callcmd(&rxbuf[i], &ack); callcmd(&rxbuf[i], &ack);
dumpack(&ack);
i = inext; i = inext;
if (ack.ecode != 0) { if (ack.ecode != 0) {
@ -97,24 +98,25 @@ void CmdSchedulerV2::schedule() {
} }
void CmdSchedulerV2::dumpack(ICmdParserACK* ack) { void CmdSchedulerV2::dumpack(ICmdParserACK* ack) {
if (ack->ecode == 0) { if (ack->ecode == 0) {
printf("\tok -> ");
if (ack->acktype == ack->kAckType_none) { if (ack->acktype == ack->kAckType_none) {
printf("\n");
ZLOGI(TAG, "\tok");
} else if (ack->acktype == ack->kAckType_int32) { } else if (ack->acktype == ack->kAckType_int32) {
ZLOGI(TAG, "\tok-->");
for (int i = 0; i < ack->getAckInt32Num(); i++) { 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) { } else if (ack->acktype == ack->kAckType_buf) {
ZLOGI(TAG, "\tok-->");
for (int i = 0; i < ack->rawlen; i++) { for (int i = 0; i < ack->rawlen; i++) {
printf(" %02x", ack->rawdata[i]); printf(" %02x", ack->rawdata[i]);
} }
printf("\n"); printf("\n");
} else { } else {
printf("\n");
ZLOGI(TAG, "\tok");
} }
} else { } 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);
} }
} }

5
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::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_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_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(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_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); }; int32_t Eq20ServoMotor::motor_move_by_acctime(int32_t distance, int32_t motor_velocity, int32_t acctime) { return move_by(distance, motor_velocity, acctime); };

2
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_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_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(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_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; virtual int32_t motor_move_by_acctime(int32_t distance, int32_t motor_velocity, int32_t acctime) override;

8
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_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_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(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_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; } int32_t MiniRobotCtrlModule::motor_move_by_acctime(int32_t distance, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; }

2
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_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_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(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_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; virtual int32_t motor_move_by_acctime(int32_t distance, int32_t motor_velocity, int32_t acctime) override;

2
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(); }); [this, tox]() { _motor_stop(); });
return 0; 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_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; } int32_t StepMotorCtrlModule::motor_move_by_acctime(int32_t distance, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; }

2
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_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_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(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_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; virtual int32_t motor_move_by_acctime(int32_t distance, int32_t motor_velocity, int32_t acctime) override;

81
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 "micro_computer_module_device_script_cmder_paser.hpp"
#include <stdlib.h> #include <stdlib.h>
#include "sdk/os/zos.hpp" #include "sdk/os/zos.hpp"
@ -7,17 +8,13 @@ using namespace std;
#define TAG "CMD" #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) \ #define DUMP_CONFIG(tag, configid) \
ecode = m_deviceManager->module_get_param(moduleId, configid, &configval); \ ecode = m_deviceManager->module_get_param(moduleId, configid, &configval); \
@ -25,33 +22,39 @@ void MicroComputerModuleDeviceScriptCmderPaser::initialize(ICmdParser* cancmder,
ZLOGI(TAG, "%30s :%d", tag, configval); \ 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); });
} }

4
components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.hpp

@ -9,8 +9,8 @@ class MicroComputerModuleDeviceScriptCmderPaser : public ZModuleDeviceScriptCmde
public: public:
void initialize(ICmdParser* cancmder, ZModuleDeviceManager* deviceManager); void initialize(ICmdParser* cancmder, ZModuleDeviceManager* deviceManager);
void do_dumpconfig(int32_t paramN, const char* paraV[], ICmdParserACK* ack) ;
}; };
} // namespace iflytop } // namespace iflytop

2
components/zprotocols/zcancmder_v2

@ -1 +1 @@
Subproject commit 5fc1f504ef48eccc931c2a80315ef57e462e3c27
Subproject commit 9aa75ad06a2eadd5d6656eba7c45af3d359080f1
Loading…
Cancel
Save