Browse Source

update

master
zhaohe 2 years ago
parent
commit
07b0889ebd
  1. 3
      .gitmodules
  2. 4
      components/cmdscheduler/cmd_scheduler.cpp
  3. 49
      components/eq_20_asb_motor/eq20_servomotor.cpp
  4. 38
      components/eq_20_asb_motor/eq20_servomotor.hpp
  5. 4
      components/eq_20_asb_motor/script_cmder_eq20_servomotor.cpp
  6. 2
      components/hardware/uart/zuart_helper.cpp
  7. 52
      components/mini_servo_motor/mini_servo_motor_ctrl_module.cpp
  8. 2
      components/mini_servo_motor/scirpt_cmder_mini_servo_motor_ctrl_module.cpp
  9. 6
      components/modbus/modbus_block_host.cpp
  10. 4
      components/motor_laser_code_scanner/motor_laser_code_scanne.cpp
  11. 10
      components/pipette_module/pipette_ctrl_module.cpp
  12. 6
      components/sensors/i2ceeprom/m24lr64e_i2c_eeprom.cpp
  13. 12
      components/sensors/smtp2/smtp2.cpp
  14. 2
      components/step_motor_45/script_cmder_step_motor_45.cpp
  15. 20
      components/step_motor_ctrl_module/step_motor_ctrl_module.cpp
  16. 4
      components/step_motor_ctrl_module/step_motor_ctrl_script_cmder_module.cpp
  17. 12
      components/step_motor_ctrl_module/zcan_master_step_motor_ctrl_module.cpp
  18. 16
      components/xy_robot_ctrl_module/xy_robot_ctrl_module.cpp
  19. 4
      components/xy_robot_ctrl_module/xy_robot_script_cmder_module.cpp
  20. 2
      components/zcancmder/zcanreceiver_master.cpp
  21. 2
      components/zprotocols/errorcode
  22. 2
      components/zprotocols/zcancmder
  23. 1
      components/zprotocols/zcancmder_v2

3
.gitmodules

@ -4,3 +4,6 @@
[submodule "components/zprotocols/errorcode"]
path = components/zprotocols/errorcode
url = zwsd@192.168.1.3:zprotocols/errorcode.git
[submodule "components/zprotocols/zcancmder_v2"]
path = components/zprotocols/zcancmder_v2
url = zwsd@192.168.1.3:zprotocols/zcancmder_v2.git

4
components/cmdscheduler/cmd_scheduler.cpp

@ -122,12 +122,12 @@ int32_t CmdScheduler::callcmd(const char* cmd) {
context.argc = argc;
context.argv = argv;
// ZLOGI(TAG, "callcmd:argc %d %d", argc, cmder->second.npara);
if (cmder->second.npara != context.argc - 1) return err::kce_cmd_param_num_error;
if (cmder->second.npara != context.argc - 1) return err::kcmd_param_num_error;
int32_t ret = cmder->second.call_cmd(&context);
return ret;
} else {
return err::kce_cmd_not_found;
return err::kcmd_not_found;
}
}

49
components/eq_20_asb_motor/eq20_servomotor.cpp

@ -9,10 +9,11 @@ using namespace iflytop;
#define TAG "Eq20ServoMotor"
void Eq20ServoMotor::init(ModbusBlockHost *modbusBlockHost, int id) {
void Eq20ServoMotor::init(ModbusBlockHost *modbusBlockHost, int moduleid, int motorid = 1) {
// this->com = com;
m_modbusBlockHost = modbusBlockHost;
m_deviceId = id;
m_deviceId = motorid;
m_moduleId = moduleid;
ZASSERT(m_modbusBlockHost != NULL);
}
@ -214,4 +215,46 @@ int32_t Eq20ServoMotor::_read_reg_bit(uint32_t regadd, int32_t off, int32_t &val
DO_NOLOG(_readreg(regadd, regval));
value = (regval >> off) & 0x01;
return 0;
}
}
/*******************************************************************************
* Motor *
*******************************************************************************/
int32_t Eq20ServoMotor::getid(int32_t *id) {
*id = m_moduleId;
return 0;
}
int32_t Eq20ServoMotor::module_stop() { return stop(); }
int32_t Eq20ServoMotor::module_break() { return stop(); }
int32_t Eq20ServoMotor::module_get_last_exec_status(int32_t *status) {
*status = 0;
return 0;
}
int32_t Eq20ServoMotor::module_get_status(int32_t *status) {}
int32_t Eq20ServoMotor::module_get_error(int32_t *iserror) {
*iserror = 0;
// get_servo_internal_state();
servo_internal_status_t internal_state;
int32_t ecode = get_servo_internal_state(internal_state);
if (ecode != 0) {
return ecode;
}
*status = internal_state.data.sbit.servo_warning | internal_state.data.sbit.servo_warning;
return 0;
return 0;
}
int32_t Eq20ServoMotor::module_clear_error() { return err::koperation_not_support; }
int32_t Eq20ServoMotor::module_set_param(int32_t param_id, int32_t param_value) { return err::koperation_not_support; }
int32_t Eq20ServoMotor::module_get_param(int32_t param_id, int32_t *param_value) { return err::koperation_not_support; }
int32_t Eq20ServoMotor::module_readio(int32_t *io) { return get_io_state(*io); }
int32_t Eq20ServoMotor::module_writeio(int32_t io) { 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_rotate(int32_t direction, int32_t motor_velocity, int32_t acc) { return rotate(direction * motor_velocity, acc); }
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) {}
int32_t Eq20ServoMotor::motor_move_to_with_torque(int32_t pos, int32_t torque) {}

38
components/eq_20_asb_motor/eq20_servomotor.hpp

@ -4,10 +4,12 @@
#include "sdk/os/zos.hpp"
#include "sdk\components\modbus\modbus_block_host.hpp"
#include "sdk\components\zprotocols\zcancmder\api\basic_type.hpp"
#include "sdk\components\zprotocols\zcancmder_v2\api\api.hpp"
namespace iflytop {
using namespace std;
class Eq20ServoMotor {
class Eq20ServoMotor : public ZIModule, public ZIMotor {
public:
typedef struct {
union {
@ -40,7 +42,7 @@ class Eq20ServoMotor {
uint32_t is_reach_target : 1;
uint32_t is_speed_consistent : 1;
uint32_t motor_is_zero_speed : 1;
uint32_t brake_is_on : 1;
uint32_t module_break_is_on : 1;
uint32_t is_pos_close : 1;
uint32_t torque_is_limited : 1;
uint32_t speed_is_limited : 1;
@ -63,13 +65,14 @@ class Eq20ServoMotor {
private:
ModbusBlockHost *m_modbusBlockHost;
int32_t m_deviceId = 0;
int32_t m_moduleId = 0;
int32_t m_auto_resendtimes = 3;
public:
Eq20ServoMotor(/* args */){};
~Eq20ServoMotor(){};
void init(ModbusBlockHost *modbusBlockHost, int id);
void init(ModbusBlockHost *modbusBlockHost, int moduleid, int motorid = 1);
int32_t enable(int32_t enable);
@ -88,6 +91,35 @@ class Eq20ServoMotor {
int32_t get_pos(int32_t &pos);
int32_t get_io_state(int32_t &io_state);
/*******************************************************************************
* OVERRIDE MODULE *
*******************************************************************************/
virtual int32_t getid(int32_t *id) override;
virtual int32_t module_stop() override;
virtual int32_t module_break() override;
virtual int32_t module_get_last_exec_status(int32_t *status) override;
virtual int32_t module_get_status(int32_t *status) override;
virtual int32_t module_get_error(int32_t *iserror) override;
virtual int32_t module_clear_error() override;
virtual int32_t module_set_param(int32_t param_id, int32_t param_value) override;
virtual int32_t module_get_param(int32_t param_id, int32_t *param_value) override;
virtual int32_t module_readio(int32_t *io) override;
virtual int32_t module_writeio(int32_t io) override;
virtual int32_t module_read_adc(int32_t adcindex, int32_t *adc) override;
/*******************************************************************************
* Motor *
*******************************************************************************/
virtual int32_t motor_enable(int32_t enable) 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_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;
public:
int32_t write_reg(uint32_t regadd, int32_t value);
int32_t read_reg(uint32_t regadd, int32_t &value);

4
components/eq_20_asb_motor/script_cmder_eq20_servomotor.cpp

@ -16,7 +16,7 @@ void ScriptCmderEq20Servomotor::initialize(CmdScheduler* cmdScheduler) {
int32_t ScriptCmderEq20Servomotor::findmodule(int id, Eq20ServoMotor** module) {
auto it = moduler.find(id);
if (it == moduler.end()) {
return err::kce_no_such_module;
return err::kmodule_not_found;
}
*module = it->second;
return 0;
@ -32,7 +32,7 @@ static void cmd_dump_ack(Eq20ServoMotor::servo_internal_status_t ack) { //
ZLOGI(TAG, "is_reach_target :%d", ack.data.sbit.is_reach_target);
ZLOGI(TAG, "is_speed_consistent :%d", ack.data.sbit.is_speed_consistent);
ZLOGI(TAG, "motor_is_zero_speed :%d", ack.data.sbit.motor_is_zero_speed);
ZLOGI(TAG, "brake_is_on :%d", ack.data.sbit.brake_is_on);
ZLOGI(TAG, "module_break_is_on :%d", ack.data.sbit.module_break_is_on);
ZLOGI(TAG, "is_pos_close :%d", ack.data.sbit.is_pos_close);
ZLOGI(TAG, "torque_is_limited :%d", ack.data.sbit.torque_is_limited);
ZLOGI(TAG, "speed_is_limited :%d", ack.data.sbit.speed_is_limited);

2
components/hardware/uart/zuart_helper.cpp

@ -58,7 +58,7 @@ int32_t ZUARTHelper::tx_and_rx(uint8_t* tx, uint8_t txdatalen, uint8_t* rx, uint
}
HAL_UART_DMAStop(m_uart);
if (overtime_flag) {
return err::kce_overtime;
return err::kovertime;
}
return 0;
}

52
components/mini_servo_motor/mini_servo_motor_ctrl_module.cpp

@ -19,14 +19,14 @@ void MiniRobotCtrlModule::initialize(FeiTeServoMotor* bus, uint8_t id) {
int32_t MiniRobotCtrlModule::enable(u8 enable) {
bool suc = m_bus->write_u8(m_id, feite::reg_add_e::kRegServoTorqueSwitch, enable);
if (!suc) return err::kce_subdevice_overtime;
if (!suc) return err::ksubdevice_overtime;
return err::ksucc;
}
int32_t MiniRobotCtrlModule::stop(u8 stop_type) {
/**
* @brief
*/
if (!m_bus->ping(m_id)) return err::kce_subdevice_overtime;
if (!m_bus->ping(m_id)) return err::ksubdevice_overtime;
feite::run_mode_e runmode = m_bus->getmode(m_id);
if (runmode == feite::kServoMode) {
m_bus->setmode(m_id, feite::kMotorMode);
@ -38,20 +38,20 @@ int32_t MiniRobotCtrlModule::stop(u8 stop_type) {
return err::ksucc;
}
int32_t MiniRobotCtrlModule::position_calibrate(s32 nowpos) {
if (nowpos < 0 || nowpos > 4095) return err::kce_param_out_of_range;
if (!m_bus->ping(m_id)) return err::kce_subdevice_overtime;
if (!m_bus->reCalibration(m_id, nowpos)) return err::kce_subdevice_overtime;
if (nowpos < 0 || nowpos > 4095) return err::kparam_out_of_range;
if (!m_bus->ping(m_id)) return err::ksubdevice_overtime;
if (!m_bus->reCalibration(m_id, nowpos)) return err::ksubdevice_overtime;
return 0;
}
int32_t MiniRobotCtrlModule::rotate(s32 speed, s32 torque, s32 run_time, action_cb_status_t status_cb) {
ZLOGI(TAG, "rotate speed:%d torque:%d run_time:%d", speed, torque, run_time);
m_thread.stop();
if (!m_bus->ping(m_id)) return err::kce_subdevice_overtime;
if (!m_bus->ping(m_id)) return err::ksubdevice_overtime;
limit_input(torque, 0, 1000);
limit_input(speed, -200000, 200000);
if (!m_bus->rotate(m_id, speed, torque)) return err::kce_subdevice_overtime;
if (!m_bus->rotate(m_id, speed, torque)) return err::ksubdevice_overtime;
m_thread.start([this, speed, torque, run_time, status_cb]() {
int32_t entertime = zos_get_tick();
@ -75,13 +75,13 @@ int32_t MiniRobotCtrlModule::move_to(s32 pos, s32 speed, s32 torque, action_cb_s
ZLOGI(TAG, "move_to pos:%d speed:%d torque:%d", pos, speed, torque);
m_thread.stop();
if (!m_bus->ping(m_id)) return err::kce_subdevice_overtime;
if (!m_bus->ping(m_id)) return err::ksubdevice_overtime;
limit_input(torque, 0, 1000);
limit_input(pos, 0, 4095);
// m_bus->moveTo(m_id, pos, speed, torque);
if (!m_bus->moveTo(m_id, pos, speed, torque)) return err::kce_subdevice_overtime;
if (!m_bus->moveTo(m_id, pos, speed, torque)) return err::ksubdevice_overtime;
m_thread.start([this, pos, speed, torque, status_cb]() {
while (true) {
@ -105,11 +105,11 @@ int32_t MiniRobotCtrlModule::move_to(s32 pos, s32 speed, s32 torque, action_cb_s
int32_t MiniRobotCtrlModule::move_forward(s32 torque) {
ZLOGI(TAG, "move_forward torque:%d", torque);
if (!m_bus->ping(m_id)) return err::kce_subdevice_overtime;
if (!m_bus->ping(m_id)) return err::ksubdevice_overtime;
limit_input(torque, 0, 1000);
m_thread.stop();
if (!m_bus->moveTo(m_id, 4095, 0, torque)) return err::kce_subdevice_overtime;
if (!m_bus->moveTo(m_id, 4095, 0, torque)) return err::ksubdevice_overtime;
m_thread.start([this, torque]() {
while (true) {
if (m_thread.getExitFlag()) break;
@ -124,11 +124,11 @@ int32_t MiniRobotCtrlModule::move_forward(s32 torque) {
int32_t MiniRobotCtrlModule::move_backward(s32 torque) {
ZLOGI(TAG, "move_backward torque:%d", torque);
if (!m_bus->ping(m_id)) return err::kce_subdevice_overtime;
if (!m_bus->ping(m_id)) return err::ksubdevice_overtime;
limit_input(torque, 0, 1000);
m_thread.stop();
if (!m_bus->moveTo(m_id, 0, 0, torque)) return err::kce_subdevice_overtime;
if (!m_bus->moveTo(m_id, 0, 0, torque)) return err::ksubdevice_overtime;
m_thread.start([this, torque]() {
while (true) {
if (m_thread.getExitFlag()) break;
@ -144,7 +144,7 @@ int32_t MiniRobotCtrlModule::move_by(s32 dpos, s32 speed, s32 torque, action_cb_
ZLOGI(TAG, "move_by pos:%d speed:%d torque:%d", dpos, speed, torque);
m_thread.stop();
if (!m_bus->ping(m_id)) return err::kce_subdevice_overtime;
if (!m_bus->ping(m_id)) return err::ksubdevice_overtime;
limit_input(torque, 0, 1000);
limit_input(speed, -200000, 200000);
@ -160,16 +160,16 @@ int32_t MiniRobotCtrlModule::move_by(s32 dpos, s32 speed, s32 torque, action_cb_
return 0;
}
int32_t MiniRobotCtrlModule::run_with_torque(s32 torque, s32 run_time, action_cb_status_t status_cb) {
return err::kce_operation_not_support;
return err::koperation_not_support;
#if 0
ZLOGI(TAG, "run_with_torque torque:%d run_time:%d", torque, run_time);
m_thread.stop();
if (!m_bus->ping(m_id)) return err::kce_subdevice_overtime;
if (!m_bus->ping(m_id)) return err::ksubdevice_overtime;
if (torque > 1000) torque = 1000;
if (torque < 0) torque = 0;
if (!m_bus->moveWithTorque(m_id, torque)) return err::kce_subdevice_overtime;
if (!m_bus->moveWithTorque(m_id, torque)) return err::ksubdevice_overtime;
m_thread.start([this, torque, run_time, status_cb]() {
int32_t entertime = zos_get_tick();
@ -177,7 +177,7 @@ int32_t MiniRobotCtrlModule::run_with_torque(s32 torque, s32 run_time, action_cb
while (true) {
if (m_thread.getExitFlag() && run_time != 0) {
stop(0);
call_status_cb(status_cb, err::kce_break_by_user);
call_status_cb(status_cb, err::kmodule_opeation_break_by_user);
break;
}
if (m_thread.getExitFlag() && run_time == 0) {
@ -199,19 +199,19 @@ int32_t MiniRobotCtrlModule::run_with_torque(s32 torque, s32 run_time, action_cb
return 0;
}
int32_t MiniRobotCtrlModule::move_by_nolimit(s32 pos, s32 speed, s32 torque, action_cb_status_t status_cb) { return err::kce_operation_not_support; }
int32_t MiniRobotCtrlModule::move_by_nolimit(s32 pos, s32 speed, s32 torque, action_cb_status_t status_cb) { return err::koperation_not_support; }
int32_t MiniRobotCtrlModule::read_version(version_t& version) {
uint8_t mainversion, subversion, miniserv_mainversion, miniserv_subversion;
if (!m_bus->readversion(m_id, mainversion, subversion, miniserv_mainversion, miniserv_subversion)) return err::kce_subdevice_overtime;
if (!m_bus->readversion(m_id, mainversion, subversion, miniserv_mainversion, miniserv_subversion)) return err::ksubdevice_overtime;
version.version = mainversion << 24 | subversion << 16 | miniserv_mainversion << 8 | miniserv_subversion;
return 0;
}
int32_t MiniRobotCtrlModule::read_status(status_t& status) {
if (!m_bus->ping(m_id)) return err::kce_subdevice_overtime;
if (!m_bus->ping(m_id)) return err::ksubdevice_overtime;
FeiTeServoMotor::detailed_status_t feitestatus;
if (!m_bus->read_detailed_status(m_id, &feitestatus)) return err::kce_subdevice_overtime;
if (!m_bus->read_detailed_status(m_id, &feitestatus)) return err::ksubdevice_overtime;
status.torque = feitestatus.torque;
status.speed = feitestatus.vel;
status.pos = feitestatus.pos;
@ -224,9 +224,9 @@ int32_t MiniRobotCtrlModule::read_status(status_t& status) {
return 0;
}
int32_t MiniRobotCtrlModule::read_detailed_status(detailed_status_t& debug_info) {
if (!m_bus->ping(m_id)) return err::kce_subdevice_overtime;
if (!m_bus->ping(m_id)) return err::ksubdevice_overtime;
FeiTeServoMotor::detailed_status_t feitestatus;
if (!m_bus->read_detailed_status(m_id, &feitestatus)) return err::kce_subdevice_overtime;
if (!m_bus->read_detailed_status(m_id, &feitestatus)) return err::ksubdevice_overtime;
if (feitestatus.state != 0) {
debug_info.status = 3;
@ -244,10 +244,10 @@ int32_t MiniRobotCtrlModule::read_detailed_status(detailed_status_t& debug_info)
return 0;
}
int32_t MiniRobotCtrlModule::set_basic_param(basic_param_t& param) { return err::kce_operation_not_support; }
int32_t MiniRobotCtrlModule::set_basic_param(basic_param_t& param) { return err::koperation_not_support; }
int32_t MiniRobotCtrlModule::get_basic_param(basic_param_t& param) {
ZLOGI(TAG, "get_basic_param");
if (!m_bus->ping(m_id)) return err::kce_subdevice_overtime;
if (!m_bus->ping(m_id)) return err::ksubdevice_overtime;
m_bus->read_u16(m_id, feite::kRegServoCalibration, param.posCalibrate);
m_bus->read_u16(m_id, feite::kRegServoMinAngle, param.minlimit);
m_bus->read_u16(m_id, feite::kRegServoMaxAngle, param.maxlimit);

2
components/mini_servo_motor/scirpt_cmder_mini_servo_motor_ctrl_module.cpp

@ -43,7 +43,7 @@ void ScirptCmderMiniServoMotorCtrlModule::initialize(CmdScheduler* cmdScheduler)
int32_t ScirptCmderMiniServoMotorCtrlModule::findmodule(int id, I_MiniServoModule** module) {
auto it = moduler.find(id);
if (it == moduler.end()) {
return err::kce_no_such_module;
return err::kmodule_not_found;
}
*module = it->second;
return 0;

6
components/modbus/modbus_block_host.cpp

@ -47,7 +47,7 @@ int32_t ModbusBlockHost::readReg03Muti(uint8_t slaveAddr, uint16_t regAddr, uint
cleanRxBuff();
DO(m_zuartHelper.tx_and_rx(m_txbuff, 6 + 2, m_rxbuff, 5 + regNum * 2, overtimems));
if (!modbus_checkcrc16(m_rxbuff, 7 + regNum * 2)) {
return err::kce_modbusCRC16checkfail;
return err::kcheckcode_is_error;
}
for (int i = 0; i < regNum; i++) {
regVal[i] = m_rxbuff[3 + i * 2] << 8 | m_rxbuff[4 + i * 2];
@ -69,7 +69,7 @@ int32_t ModbusBlockHost::writeReg06(uint8_t slaveAddr, uint16_t regAddr, uint16_
DO(m_zuartHelper.tx_and_rx(m_txbuff, 6 + 2, m_rxbuff, 8, overtimems));
if (!modbus_checkcrc16(m_rxbuff, 8)) {
return err::kce_modbusCRC16checkfail;
return err::kcheckcode_is_error;
}
return 0;
}
@ -94,7 +94,7 @@ int32_t ModbusBlockHost::writeReg10Muti(uint8_t slaveAddr, uint16_t regAddr, uin
DO(m_zuartHelper.tx_and_rx(m_txbuff, 7 + nreg * 2 + 2, m_rxbuff, 8, overtimems));
if (!modbus_checkcrc16(m_rxbuff, 8)) {
return err::kce_modbusCRC16checkfail;
return err::kcheckcode_is_error;
}
return 0;
}

4
components/motor_laser_code_scanner/motor_laser_code_scanne.cpp

@ -76,14 +76,14 @@ int32_t MotorLaserCodeScanner::stop_scan() {
int32_t MotorLaserCodeScanner::get_scan_result(u16 sector_index, u16 sector_size, zcancmder_read_ram_ack_t& ack) {
zlock_guard lock(m_lock);
if (m_thread.isworking()) return err::kce_device_is_busy;
if (m_thread.isworking()) return err::kdevice_is_busy;
uint8_t* src_data = m_scan_result->scan_result + sector_index * sector_size;
int32_t src_data_len = m_scan_result->each_scan_result_len * m_scan_result->scan_reult_nums;
return assign_scan_result(sector_index, sector_size, src_data, src_data_len, ack);
}
int32_t MotorLaserCodeScanner::assign_scan_result(u16 sector_index, u16 sector_size, u8* src_data, s32 src_data_len, zcancmder_read_ram_ack_t& ack) {
if (sector_size > sizeof(ack.packet)) return err::kce_buffer_not_enough;
if (sector_size > sizeof(ack.packet)) return err::kbuffer_not_enough;
uint8_t* copy_s = (uint8_t*)src_data + sector_index * sector_size;
int32_t copy_len = (int32_t)src_data_len - sector_size * sector_index;

10
components/pipette_module/pipette_ctrl_module.cpp

@ -43,7 +43,7 @@ int32_t PipetteModule::stop(u8 stop_type) {
int32_t PipetteModule::zero_pos_calibrate(action_cb_status_t status_cb) {
ZLOGI(TAG, "zero_pos_calibrate");
if (!m_smtp2->isOnline()) return err::kce_device_offline;
if (!m_smtp2->isOnline()) return err::kdevice_offline;
m_thread.stop();
m_thread.start([this, status_cb]() { //
@ -57,7 +57,7 @@ int32_t PipetteModule::zero_pos_calibrate(action_cb_status_t status_cb) {
int32_t PipetteModule::zmotor_reset(action_cb_status_t status_cb) {
ZLOGI(TAG, "reset_device");
if (!m_smtp2->isOnline()) return err::kce_device_offline;
if (!m_smtp2->isOnline()) return err::kdevice_offline;
m_thread.stop();
m_thread.start([this, status_cb]() {
@ -71,7 +71,7 @@ int32_t PipetteModule::zmotor_reset(action_cb_status_t status_cb) {
}
int32_t PipetteModule::pipette_reset(action_cb_status_t status_cb) {
ZLOGI(TAG, "reset_device");
if (!m_smtp2->isOnline()) return err::kce_device_offline;
if (!m_smtp2->isOnline()) return err::kdevice_offline;
m_thread.stop();
m_thread.start([this, status_cb]() {
@ -85,7 +85,7 @@ int32_t PipetteModule::pipette_reset(action_cb_status_t status_cb) {
int32_t PipetteModule::take_tip(s16 vel, s16 height_mm, s16 tip_hight_mm, action_cb_status_t status_cb) {
ZLOGI(TAG, "take_tip");
if (!m_smtp2->isOnline()) return err::kce_device_offline;
if (!m_smtp2->isOnline()) return err::kdevice_offline;
bool hastip = false;
DO2("m_smtp2->read_tip_state(hastip)", m_smtp2->read_tip_state(hastip));
@ -123,7 +123,7 @@ int32_t PipetteModule::take_tip(s16 vel, s16 height_mm, s16 tip_hight_mm, action
int32_t PipetteModule::remove_tip(s16 vel, s16 height_mm, action_cb_status_t status_cb) {
ZLOGI(TAG, "rmove_tip ");
if (!m_smtp2->isOnline()) return err::kce_device_offline;
if (!m_smtp2->isOnline()) return err::kdevice_offline;
m_thread.stop();
m_thread.start([this, vel, height_mm, status_cb]() {

6
components/sensors/i2ceeprom/m24lr64e_i2c_eeprom.cpp

@ -52,10 +52,10 @@ int32_t M24LR64E_I2CEEPROM::stop_monitor_status() {
};
int32_t M24LR64E_I2CEEPROM::read(u16 sector_index, u16 sector_size, zcancmder_read_ram_ack_t& ack) {
zlock_guard guard(m_mutex);
if (sector_size > sizeof(ack.packet)) return err::kce_buffer_not_enough;
if (sector_size > sizeof(ack.packet)) return err::kbuffer_not_enough;
uint16_t add = sector_index * sector_size;
if (add >= MAX_SIZE) return err::kce_param_out_of_range;
if (add >= MAX_SIZE) return err::kparam_out_of_range;
if (add + sector_size > MAX_SIZE) {
ack.len = MAX_SIZE - add;
@ -67,7 +67,7 @@ int32_t M24LR64E_I2CEEPROM::read(u16 sector_index, u16 sector_size, zcancmder_re
HAL_StatusTypeDef status = HAL_I2C_Mem_Read(m_i2c_handle, READ_ADD, add, I2C_MEMADD_SIZE_8BIT, ack.packet, ack.len, 30);
if (status != HAL_OK) {
printf("M24LR64E_I2CEEPROM::read error: %d\n", status);
return err::kce_device_offline;
return err::kdevice_offline;
}
return 0;
};

12
components/sensors/smtp2/smtp2.cpp

@ -255,15 +255,15 @@ int32_t SMTP2::getState() {
int ret = getState(isbusy, error);
if (ret == 0) {
if (isbusy) {
return err::kce_device_is_busy;
return err::kdevice_is_busy;
}
return error;
}
return err::kce_device_is_offline;
return err::kdevice_is_offline;
}
bool SMTP2::isOnline() {
if (getState() != err::kce_device_is_offline) {
if (getState() != err::kdevice_is_offline) {
return true;
}
return false;
@ -275,7 +275,7 @@ bool SMTP2::isOnline() {
iflytop::err::error_t SMTP2::read_ack_error_code(char* rxbuf, size_t rxlen) {
if (rxlen < 3) {
return err::kce_device_is_offline;
return err::kdevice_is_offline;
}
uint8_t errorcode = (uint8_t)rxbuf[2];
if (errorcode > '`') {
@ -409,7 +409,7 @@ int32_t SMTP2::doaction_block(function<int32_t()> action) {
// µÈ´ýÒÆÒºÇ¹¸´Î»Íê³É
while (true) {
int32_t state = getState();
if (state != err::kce_device_is_busy) {
if (state != err::kdevice_is_busy) {
if (state == 0) {
stop();
return 0;
@ -420,7 +420,7 @@ int32_t SMTP2::doaction_block(function<int32_t()> action) {
}
if (thisThread.getExitFlag()) {
stop();
return err::kce_break_by_user;
return err::kmodule_opeation_break_by_user;
}
thisThread.sleep(1000);
}

2
components/step_motor_45/script_cmder_step_motor_45.cpp

@ -16,7 +16,7 @@ void ScriptCmderStepMotor45::initialize(CmdScheduler* cmdScheduler) {
int32_t ScriptCmderStepMotor45::findmodule(int id, StepMotor45** module) {
auto it = moduler.find(id);
if (it == moduler.end()) {
return err::kce_no_such_module;
return err::kmodule_not_found;
}
*module = it->second;
return 0;

20
components/step_motor_ctrl_module/step_motor_ctrl_module.cpp

@ -48,14 +48,14 @@ bool StepMotorCtrlModule::isbusy() { return m_thread.isworking(); }
int32_t StepMotorCtrlModule::move_to_logic_point(int32_t logic_point_num, action_cb_status_t status_cb) {
ZLOGI(TAG, "move_to_logic_point %d", logic_point_num);
if (logic_point_num >= ZARRAY_SIZE(m_flash_config.logic_point)) {
return err::kce_param_out_of_range;
return err::kparam_out_of_range;
}
logic_point_t logic_point = m_flash_config.logic_point[logic_point_num];
return move_to(logic_point.x, logic_point.velocity, status_cb);
}
int32_t StepMotorCtrlModule::set_logic_point(int logic_point_num, int32_t x, int32_t vel, s32 acc, s32 dec) {
ZLOGI(TAG, "set_logic_point %d %d %d %d %d", logic_point_num, x, vel, acc, dec);
if (logic_point_num >= ZARRAY_SIZE(m_flash_config.logic_point)) return err::kce_param_out_of_range;
if (logic_point_num >= ZARRAY_SIZE(m_flash_config.logic_point)) return err::kparam_out_of_range;
if (logic_point_num < 0) logic_point_num = 0;
// memset(&m_flash_config, 0, sizeof(m_flash_config));
m_flash_config.logic_point[logic_point_num].x = x;
@ -66,7 +66,7 @@ int32_t StepMotorCtrlModule::set_logic_point(int logic_point_num, int32_t x, int
}
int32_t StepMotorCtrlModule::get_logic_point(int logic_point_num, logic_point_t& logic_point) {
if (logic_point_num >= ZARRAY_SIZE(m_flash_config.logic_point)) {
return err::kce_param_out_of_range;
return err::kparam_out_of_range;
}
logic_point = m_flash_config.logic_point[logic_point_num];
return 0;
@ -242,7 +242,7 @@ int32_t StepMotorCtrlModule::rotate(int32_t speed, int32_t lastforms, action_cb_
if (lastforms < 0) {
ZLOGW(TAG, "lastforms:%d < 0", lastforms);
return err::kce_param_out_of_range;
return err::kparam_out_of_range;
}
if (m_param.maxspeed != 0 && abs(speed) > m_param.maxspeed) {
@ -400,7 +400,7 @@ int32_t StepMotorCtrlModule::exec_move_to_zero_task() {
if (!xreach_zero) {
// 触发异常回调
ZLOGE(TAG, "x reach zero failed");
return err::kce_not_found_x_zero_point;
return err::kxymotor_not_found_x_zero_point;
}
}
}
@ -427,11 +427,11 @@ int32_t StepMotorCtrlModule::exec_move_to_zero_task() {
if (m_thread.getExitFlag()) {
ZLOGI(TAG, "break move to zero thread exit");
return err::kce_break_by_user;
return err::kmodule_opeation_break_by_user;
}
if (m_Xgpio->getState()) {
ZLOGE(TAG, "leave away zero failed");
return err::kce_x_leave_away_zero_point_fail;
return err::kxymotor_x_find_zero_edge_fail;
}
}
@ -460,13 +460,13 @@ int32_t StepMotorCtrlModule::exec_move_to_zero_task() {
// if (m_thread.getExitFlag()) {
// ZLOGI(TAG, "break move to zero thread exit");
// return err::kce_break_by_user;
// return err::kmodule_opeation_break_by_user;
// }
// if (!xreach_zero) {
// // 触发异常回调
// ZLOGE(TAG, "x reach zero failed");
// return err::kce_not_found_x_zero_point;
// return err::kxymotor_not_found_x_zero_point;
// }
// }
@ -563,7 +563,7 @@ int32_t StepMotorCtrlModule::do_motor_action_block_2(function<int32_t()> action,
if (isbusy()) {
stop(0);
return err::kce_break_by_user;
return err::kmodule_opeation_break_by_user;
}
return get_last_exec_status();

4
components/step_motor_ctrl_module/step_motor_ctrl_script_cmder_module.cpp

@ -34,7 +34,7 @@ void StepMotorCtrlScriptCmderModule::initialize(CmdScheduler* cmdScheduler) {
int32_t StepMotorCtrlScriptCmderModule::findmodule(int id, I_StepMotorCtrlModule** module) {
auto it = moduler.find(id);
if (it == moduler.end()) {
return err::kce_no_such_module;
return err::kmodule_not_found;
}
*module = it->second;
@ -265,7 +265,7 @@ void StepMotorCtrlScriptCmderModule::regcmd() { //
param.look_zero_edge_dec = value;
} else {
ZLOGE(TAG, "invalid param name:%s", paramName);
return (int32_t)err::kce_param_out_of_range;
return (int32_t)err::kparam_out_of_range;
}
DO_CMD(module->set_base_param(param));
return (int32_t)0;

12
components/step_motor_ctrl_module/zcan_master_step_motor_ctrl_module.cpp

@ -136,22 +136,22 @@ class StepMotorCtrlModule : public I_StepMotorCtrlModule {
}
virtual int32_t move_to_block(int32_t tox, int overtime) { //
return err::kce_overtime;
return err::kovertime;
}
virtual int32_t move_by_block(int32_t dx, int overtime) { //
return err::kce_overtime;
return err::kovertime;
}
virtual int32_t move_to_block(int32_t tox, int32_t velocity, int overtime) { //
return err::kce_overtime;
return err::kovertime;
}
virtual int32_t move_by_block(int32_t dx, int32_t velocity, int overtime) { //
return err::kce_overtime;
return err::kovertime;
}
virtual int32_t move_to_zero_block(int overtime) { //
return err::kce_overtime;
return err::kovertime;
}
virtual int32_t move_to_zero_with_calibrate_block(int32_t x, int overtime) { //
return err::kce_overtime;
return err::kovertime;
}
};

16
components/xy_robot_ctrl_module/xy_robot_ctrl_module.cpp

@ -381,12 +381,12 @@ int32_t XYRobotCtrlModule::exec_move_to_zero_task() {
if (m_thread.getExitFlag()) {
ZLOGI(TAG, "break move to zero thread exit");
return err::kce_break_by_user;
return err::kmodule_opeation_break_by_user;
}
if (!xreach_zero) {
ZLOGE(TAG, "find zero point fail");
return err::kce_x_leave_away_zero_point_fail;
return err::kxymotor_x_find_zero_edge_fail;
}
}
@ -404,12 +404,12 @@ int32_t XYRobotCtrlModule::exec_move_to_zero_task() {
if (m_thread.getExitFlag()) {
ZLOGI(TAG, "break move to zero thread exit");
return err::kce_break_by_user;
return err::kmodule_opeation_break_by_user;
}
if (!xleave_zero) {
ZLOGI(TAG, "leave away zero failed");
return err::kce_x_leave_away_zero_point_fail;
return err::kxymotor_x_find_zero_edge_fail;
}
}
@ -431,11 +431,11 @@ int32_t XYRobotCtrlModule::exec_move_to_zero_task() {
}
if (m_thread.getExitFlag()) {
ZLOGI(TAG, "break move to zero thread exit");
return err::kce_break_by_user;
return err::kmodule_opeation_break_by_user;
}
if (!yreach_zero) {
ZLOGE(TAG, "find zero point fail");
return err::kce_y_leave_away_zero_point_fail;
return err::kxymotor_y_find_zero_edge_fail;
}
}
@ -452,11 +452,11 @@ int32_t XYRobotCtrlModule::exec_move_to_zero_task() {
}
if (m_thread.getExitFlag()) {
ZLOGI(TAG, "break move to zero thread exit");
return err::kce_break_by_user;
return err::kmodule_opeation_break_by_user;
}
if (!yleave_zero) {
ZLOGI(TAG, "leave away zero failed");
return err::kce_y_leave_away_zero_point_fail;
return err::kxymotor_y_find_zero_edge_fail;
}
}

4
components/xy_robot_ctrl_module/xy_robot_script_cmder_module.cpp

@ -14,7 +14,7 @@ void XYRobotScriptCmderModule::initialize(CmdScheduler* cmdScheduler) {
int32_t XYRobotScriptCmderModule::findmodule(int id, I_XYRobotCtrlModule** module) {
auto it = moduler.find(id);
if (it == moduler.end()) {
return err::kce_no_such_module;
return err::kmodule_not_found;
}
*module = it->second;
return 0;
@ -152,7 +152,7 @@ void XYRobotScriptCmderModule::regcmd() { //
status.look_zero_edge_dec = paramVal;
} else {
ZLOGE(TAG, "invalid param name:%s", paramName);
return (int32_t)err::kce_param_out_of_range;
return (int32_t)err::kparam_out_of_range;
}
DO_CMD(module->set_base_param(status));

2
components/zcancmder/zcanreceiver_master.cpp

@ -183,7 +183,7 @@ int32_t ZCanCommnaderMaster::sendPacketBlock(uint8_t *pa
if (zos_haspassedms(enterticket) > (uint32_t)overtime_ms) {
ZLOGE(TAG, "sendPacketBlock timeout");
unregListener(cmdheader->packetindex);
return err::kce_overtime;
return err::kovertime;
}
osDelay(1);
}

2
components/zprotocols/errorcode

@ -1 +1 @@
Subproject commit a3197d626bc551983a5598d3c3a35e8e4de63e35
Subproject commit deb433723f081f4fd21a3a8278aa4cbdcc13d2d0

2
components/zprotocols/zcancmder

@ -1 +1 @@
Subproject commit 5c9d5ade69831f8d65d7ed30e49987706100bbfa
Subproject commit b059fefa2e01273ba78029ec64e4f2b715d69197

1
components/zprotocols/zcancmder_v2

@ -0,0 +1 @@
Subproject commit d3302705937d2bd91698417244897d2780292b9c
Loading…
Cancel
Save