|
|
@ -48,7 +48,7 @@ int32_t A8000ScriptProcesser::sendCanPacket(shared_ptr<ScriptProcesser::Context> |
|
|
|
string cmd = context->cmd; |
|
|
|
vector<string>& cmdandvar = context->cmd_and_var; |
|
|
|
shared_ptr<icps::Packet> rxpacket; |
|
|
|
m_iflytopCanProtocolControler->sendCanPacket(txpacket, rxpacket, 30); |
|
|
|
m_iflytopCanProtocolControler->sendCanPacket(txpacket, rxpacket, 50); |
|
|
|
if (!rxpacket) { |
|
|
|
context->printfInfo = fmt::format("error:overtime"); |
|
|
|
logger->error("sendCanPacket error:overtime"); |
|
|
@ -150,7 +150,6 @@ void A8000ScriptProcesser::step_motor_read_pos(shared_ptr<ScriptProcesser::Conte |
|
|
|
A8000ScriptProcesser::CtrlPointConfig cpcfg = getStepMotorConfig(targetStepMotorId, SAMC_REG_STAT_CURRENT_POS); |
|
|
|
readReg(cpcfg.m_deviceId, cpcfg.m_ctrlPointId, pos, context); |
|
|
|
} |
|
|
|
void A8000ScriptProcesser::step_motor_is_idle(shared_ptr<ScriptProcesser::Context> context, int32_t targetStepMotorId, int32_t& idle) {} |
|
|
|
void A8000ScriptProcesser::step_motor_read_state(shared_ptr<ScriptProcesser::Context> context, int32_t targetStepMotorId, int32_t& state) { |
|
|
|
A8000ScriptProcesser::CtrlPointConfig cpcfg = getStepMotorConfig(targetStepMotorId, SAMC_REG_STAT_STATUS); |
|
|
|
readReg(cpcfg.m_deviceId, cpcfg.m_ctrlPointId, state, context); |
|
|
@ -159,14 +158,19 @@ void A8000ScriptProcesser::step_motor_stop(shared_ptr<ScriptProcesser::Context> |
|
|
|
A8000ScriptProcesser::CtrlPointConfig cpcfg = getStepMotorConfig(targetStepMotorId, SAMC_REG_ACT_STOP); |
|
|
|
writeReg(cpcfg.m_deviceId, cpcfg.m_ctrlPointId, 0, context); |
|
|
|
} |
|
|
|
void A8000ScriptProcesser::step_motor_clear_exception(shared_ptr<ScriptProcesser::Context> context, int32_t targetStepMotorId) { |
|
|
|
A8000ScriptProcesser::CtrlPointConfig cpcfg = getStepMotorConfig(targetStepMotorId, SAMC_REG_ACT_CLEAR_EXCEPTION); |
|
|
|
writeReg(cpcfg.m_deviceId, cpcfg.m_ctrlPointId, 0, context); |
|
|
|
} |
|
|
|
|
|
|
|
void A8000ScriptProcesser::sleep_ms(shared_ptr<ScriptProcesser::Context> context, int32_t ms) { usleep(ms * 1000); } |
|
|
|
void A8000ScriptProcesser::step_motor_wait_for_idle(shared_ptr<ScriptProcesser::Context> context, int32_t targetStepMotorId) { |
|
|
|
int32_t state = 0; |
|
|
|
step_motor_is_idle(context, targetStepMotorId, state); |
|
|
|
step_motor_read_state(context, targetStepMotorId, state); |
|
|
|
// ThisThread thisThread;
|
|
|
|
while (state != 0) { |
|
|
|
usleep(300 * 1000); |
|
|
|
step_motor_is_idle(context, targetStepMotorId, state); |
|
|
|
step_motor_read_state(context, targetStepMotorId, state); |
|
|
|
logger->info("step_motor({}) wait_for_idle:{}", targetStepMotorId, state); |
|
|
|
} |
|
|
|
} |
|
|
@ -281,13 +285,12 @@ void A8000ScriptProcesser::docmd(shared_ptr<ScriptProcesser::Context> context) { |
|
|
|
CHECK_CMD_PARAMETER(1); |
|
|
|
int32_t retval = 0; |
|
|
|
step_motor_read_state(context, context->getvarInt(1), retval); |
|
|
|
} else if (cmd == "step_motor_is_idle") { |
|
|
|
CHECK_CMD_PARAMETER(1); |
|
|
|
int32_t retval = 0; |
|
|
|
step_motor_is_idle(context, context->getvarInt(1), retval); |
|
|
|
} else if (cmd == "step_motor_stop") { |
|
|
|
CHECK_CMD_PARAMETER(1); |
|
|
|
step_motor_stop(context, context->getvarInt(1)); |
|
|
|
} else if (cmd == "step_motor_clear_exception") { |
|
|
|
CHECK_CMD_PARAMETER(1); |
|
|
|
step_motor_clear_exception(context, context->getvarInt(1)); |
|
|
|
} else if (cmd == "step_motor_wait_for_idle") { |
|
|
|
CHECK_CMD_PARAMETER(1); |
|
|
|
step_motor_wait_for_idle(context, context->getvarInt(1)); |
|
|
@ -313,6 +316,9 @@ void A8000ScriptProcesser::docmd(shared_ptr<ScriptProcesser::Context> context) { |
|
|
|
} else if (cmd == "scara_wait_for_idle") { |
|
|
|
CHECK_CMD_PARAMETER(1); |
|
|
|
scara_wait_for_idle(context, context->getvarInt(1)); |
|
|
|
} else if (cmd == "sleep_ms") { |
|
|
|
CHECK_CMD_PARAMETER(1); |
|
|
|
sleep_ms(context, context->getvarInt(1)); |
|
|
|
} |
|
|
|
//
|
|
|
|
//
|
|
|
|