fix functions
This commit is contained in:
parent
bea2eea42e
commit
79f802e4b5
28
protocol.c
28
protocol.c
@ -719,14 +719,14 @@ void (*readValve2Reg)(uint8_t index, uint16_t reg) = ReadPump2Reg;
|
||||
/**
|
||||
* 读取阀门1个输入寄存器
|
||||
*
|
||||
* @param index 阀门索引
|
||||
* @param id 阀门id
|
||||
* @param reg 寄存器地址
|
||||
* @return 寄存器值
|
||||
*/
|
||||
uint16_t ReadValve1InputReg(uint8_t index, uint16_t reg)
|
||||
uint16_t ReadValve1InputReg(uint8_t id, uint16_t reg)
|
||||
{
|
||||
uint8_t data[8] = {0};
|
||||
data[0] = index;
|
||||
data[0] = id;
|
||||
data[1] = RTU_FUNC_READ_INPUT_REG;
|
||||
FillBigEndian16(&data[2], reg);
|
||||
FillBigEndian16(&data[4], 1);
|
||||
@ -746,14 +746,14 @@ uint16_t ReadValve1InputReg(uint8_t index, uint16_t reg)
|
||||
/**
|
||||
* 读取阀门2个输入寄存器
|
||||
*
|
||||
* @param index 阀门索引
|
||||
* @param id 阀门id
|
||||
* @param reg 寄存器地址
|
||||
* @return 寄存器值
|
||||
*/
|
||||
uint32_t ReadValve2InputReg(uint8_t index, uint16_t reg)
|
||||
uint32_t ReadValve2InputReg(uint8_t id, uint16_t reg)
|
||||
{
|
||||
uint8_t data[8] = {0};
|
||||
data[0] = index;
|
||||
data[0] = id;
|
||||
data[1] = RTU_FUNC_READ_INPUT_REG;
|
||||
FillBigEndian16(&data[2], reg);
|
||||
FillBigEndian16(&data[4], 2);
|
||||
@ -922,11 +922,12 @@ static uint8_t SetValveHomeTime(uint8_t index, uint16_t time) {
|
||||
* @return 位置值(用户单位)
|
||||
*/
|
||||
static uint32_t ReadValvePos(uint8_t index) {
|
||||
return ReadValve2InputReg(index, RTU_VALVE_CMD_POS);
|
||||
return ReadValve2InputReg(dp.valve[index].id, RTU_VALVE_CMD_POS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查原点回归结果
|
||||
* @param index
|
||||
* @return 0:成功 1:运动中 2:失败
|
||||
*/
|
||||
static uint8_t valveCheckBTOResult(uint8_t index, uint32_t startTime)
|
||||
@ -938,7 +939,7 @@ static uint8_t valveCheckBTOResult(uint8_t index, uint32_t startTime)
|
||||
return 2;
|
||||
}
|
||||
|
||||
uint16_t rst = ReadValve1InputReg(index,RTU_VALVE_CMD_SC);
|
||||
uint16_t rst = ReadValve1InputReg(dp.valve[index].id,RTU_VALVE_CMD_SC);
|
||||
// 如果原点回归完成,状态字第12位会从0变为1,
|
||||
// 如果原点回归失败,状态字第13位会从0变为1。
|
||||
// 此外也可以附加判断电机当前位置是否在0附近的200个脉冲以内。
|
||||
@ -1304,17 +1305,6 @@ static uint8_t HandleSoftStop(uint8_t *rxBuf, uint16_t rxLen) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理电机相关消息
|
||||
*
|
||||
* @param rxBuf 接收到的数据缓冲区
|
||||
* @param rxLen 接收到的数据长度
|
||||
*/
|
||||
void ProcessMotorMsg(uint8_t *rxBuf, uint16_t rxLen) {
|
||||
// 实现电机消息处理逻辑
|
||||
log_d("ProcessMotorMsg");
|
||||
}
|
||||
|
||||
/**
|
||||
* 将消息打包并发送给上位机
|
||||
* 帧格式:帧头+功能码(2Byte)+数据长度(1Byte)+具体数据(NByte)+CRC16校验位+帧尾
|
||||
|
Loading…
Reference in New Issue
Block a user