- 打卡等级:以坛为家I
- 打卡总天数:214
- 最近打卡:2026-03-07 06:03:54
高级会员
- 积分
- 867
|
发表于 2026-2-20 21:00:22
|
显示全部楼层
if(Flag_GetData == 1)
{
for(i=0; i<Uart1_Getlen; i++) Uart1_SendChar(Uart1_Get); //收到的数据原样返回
// CRC16_result = MODBUS_CRC16(Uart1_Get, Uart1_Getlen-2);
//// CRC16_result = MODBUS_CRC16(frame, 6);
// CRC16_H = CRC16_result / 256;
// CRC16_L = CRC16_result % 256;
// Uart1_SendChar(CRC16_H);
// Uart1_SendChar(CRC16_L);
if(MODBUS_CRC16(Uart1_Get, Uart1_Getlen) == 0) //首先判断CRC16是否正确, 不正确则忽略, 不处理也不返回信息
{
Uart1_SendChar('A');
}
else
Uart1_SendChar('B');
Flag_GetData = 0;
for(i=0; i<COM_RX1_Length; i++) Uart1_Get = '\0';
}
改成这样数据就错了,为什么呢?
|
|