From bb7ade702558582d51ad9ebbf540fb30b9213ff8 Mon Sep 17 00:00:00 2001 From: murmur Date: Tue, 31 Dec 2024 00:21:11 +0800 Subject: [PATCH] update valveCheckBTOResult --- protocol.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/protocol.c b/protocol.c index c8776fa..5ccde65 100644 --- a/protocol.c +++ b/protocol.c @@ -209,7 +209,7 @@ static uint8_t writeCMD(uint8_t *txBuf, uint16_t txLen) { uint8_t ret = readDataFromMotorValve(rxBuf, rxLen, READ_ACK_TIMEOUT); // HAL_UART_Receive(&huart2, rxBuf, rxLen, READ_ACK_TIMEOUT*4); // elog_hexdump("ACK", 16, rxBuf, rxLen); - if(memcmp(rxBuf, txBuf, 2) != 0) {//正常情况下,返回的前2个字节应与发送的相同 + if(ret != HAL_TIMEOUT && ret != HAL_OK) { log_e("READ ACK ERROR:[%s]", ackError[ret]); elog_hexdump("GET DATA", 16, rxBuf, rxLen); systemStatus.rst += 1;//结果计数 @@ -1085,7 +1085,7 @@ static void valveCheckBTOResult(uint8_t index) uint32_t pos = ReadValvePos(index); log_d("valve[%d] bto pos: %d",index,pos); isSuccess = 1; - SetValveFunc(index, RTU_VALVE_CFG_DISABLE); + // SetValveFunc(index, RTU_VALVE_CFG_DISABLE); // if(pos > 200 || pos < (VALVE_PULSE_PER_ROUND-200)) { // // 位置超出范围 // isSuccess = 0; @@ -1181,6 +1181,9 @@ uint8_t ValveRunToAngle(uint8_t index, uint32_t angle) { // 电机以绝对位置,立即更新的方式运行 // (电机是以控制字 6040h(0380h)的 bit4 的上升沿接收新的位置命令, // 所以每次执行完一次运行后需 要把此位清零。) + SetValveFunc(index, RTU_VALVE_CFG_PREPARE); + SetValveFunc(index, RTU_VALVE_CFG_DISABLE); + SetValveFunc(index, RTU_VALVE_CFG_ENABLE); SetValveFunc(index, 0x2F); SetValveFunc(index, 0x3F);