|
@@ -69,7 +69,7 @@ static uint8_t trans_databuffer[RADAR_MAX_BUFFERSIZE] = {0}; //透
|
|
|
#define WAITTING_TIMEOUT (100) //单位 ms
|
|
|
static uint8_t cmd_radar = RadarCmd_NULL;
|
|
|
uint8_t waiting_time_ladar =0; //等待数据时间, ms
|
|
|
-
|
|
|
+static uint8_t radar_timeout_count = 0; //雷达超时次数
|
|
|
|
|
|
static float airHeight = 0;
|
|
|
static uint8_t _status = 0;
|
|
@@ -108,10 +108,12 @@ static int TransmitData(uint8_t *pdata, uint16_t length);
|
|
|
waiting_time_ladar =0;
|
|
|
|
|
|
if(RadarCmd_AirHeight == cmd_radar){
|
|
|
+ radar_timeout_count = 0;
|
|
|
g_radarRxDataBuff[g_radarRxDataIndex++] = data;
|
|
|
if (g_radarRxDataIndex >= RADAR_RX_BUFF_LENGTH)
|
|
|
{
|
|
|
g_radarRxDataIndex = 0;
|
|
|
+
|
|
|
_crc = crc16(g_radarRxDataBuff, RADAR_RX_BUFF_LENGTH-2);
|
|
|
|
|
|
if( _crc == (((uint16_t)g_radarRxDataBuff[5]<<8) | g_radarRxDataBuff[6])){
|
|
@@ -223,6 +225,7 @@ void Radar_Init(void)
|
|
|
|
|
|
_status = STATUS_NORMAL;
|
|
|
airHeight = 0;
|
|
|
+ radar_timeout_count = 0;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -257,9 +260,16 @@ void Radar_CheckResponse(void)
|
|
|
cmd_radar = RadarCmd_NULL;
|
|
|
|
|
|
if(RadarCmd_AirHeight == cmd_radar){
|
|
|
- _status = STATUS_NoResponse;
|
|
|
- airHeight = 0.0;
|
|
|
+ radar_timeout_count++;
|
|
|
g_radarRxDataIndex = 0;
|
|
|
+
|
|
|
+ if(radar_timeout_count >= 3){
|
|
|
+ radar_timeout_count =3;
|
|
|
+ _status = STATUS_NoResponse;
|
|
|
+ airHeight = 0.0;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
// ladar_printfLen = snprintf((char*)ladar_printfBuff, 64, "Radar_CheckResponse st[%d], airheight: %f m \r\n", _status, airHeight);
|
|
|
// rs485_TransmitData((uint8_t*)ladar_printfBuff, ladar_printfLen);
|
|
@@ -279,6 +289,9 @@ void Radar_SendRequest(void)
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+// ladar_printfLen = snprintf((char*)ladar_printfBuff, 64, "Radar_SendRequest recvbuffer_len[%d] m \r\n", recvbuffer_len);
|
|
|
+// rs485_TransmitData((uint8_t*)ladar_printfBuff, ladar_printfLen);
|
|
|
+
|
|
|
if(recvbuffer_len > 0){
|
|
|
//有透传数据需要发送
|
|
|
cmd_radar = RadarCmd_Trans;
|