|
@@ -30,7 +30,6 @@
|
|
|
#include "main.h"
|
|
|
#include "Api.h"
|
|
|
|
|
|
-//#if SENSOR_DEVICE == 1
|
|
|
|
|
|
/*** Local Definitions ***/
|
|
|
#define FULL_SDR_REC 0x01
|
|
@@ -58,6 +57,7 @@
|
|
|
static void MonitorTSensors ( SensorInfo_T* pSensorInfo);
|
|
|
static void MonitorNonTSensors ( SensorInfo_T* pSensorInfo);
|
|
|
|
|
|
+
|
|
|
/*-------------------------------------------
|
|
|
* SensorMonitorTask
|
|
|
*---------------------- --------------------*/
|
|
@@ -66,6 +66,7 @@ void *SensorMonitorTask (void *pArg)
|
|
|
int i;
|
|
|
SensorInfo_T* pSensorInfo;
|
|
|
SensorSharedMem_T* pSMSharedMem;
|
|
|
+ uint32_t preSecond = 0;
|
|
|
|
|
|
printf("SensorMonitorTask start...\r\n");
|
|
|
|
|
@@ -84,6 +85,15 @@ void *SensorMonitorTask (void *pArg)
|
|
|
pSMSharedMem->SensorTick = 0;
|
|
|
while (1)
|
|
|
{
|
|
|
+ //只有到达整秒才可以向下执行,且没秒只执行一次。误差10ms。
|
|
|
+ if(preSecond == g_BMCInfo.CurTimerSecond)
|
|
|
+ {
|
|
|
+ usleep(10000); //10ms
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ preSecond = g_BMCInfo.CurTimerSecond;
|
|
|
+
|
|
|
g_BMCInfo.SenConfig.InitAgentRearm = FALSE;
|
|
|
|
|
|
/* Monitor all sensors */
|
|
@@ -123,10 +133,26 @@ void *SensorMonitorTask (void *pArg)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //保存传感器历史记录
|
|
|
+ int index,j;
|
|
|
+ if(g_BMCInfo.CurTimerSecond%18 == 0) //3 minutes
|
|
|
+ {
|
|
|
+ //printf("sensor %d history\n", pSensorInfo->SensorNumber);
|
|
|
+ for(index=0; index<SENSOR_NUMBERS;index++)
|
|
|
+ {
|
|
|
+ if(pSensorInfo->SensorNumber == gSensorHistoryInfo[index].SensorNum)
|
|
|
+ {
|
|
|
+ for(j=1;j<HISTORY_DATA_SIZE;j++)
|
|
|
+ {
|
|
|
+ gSensorHistoryInfo[index].History[j-1] = gSensorHistoryInfo[index].History[j];
|
|
|
+ }
|
|
|
+ gSensorHistoryInfo[index].History[HISTORY_DATA_SIZE-1] = pSensorInfo->SensorReading;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
g_BMCInfo.SenConfig.MonitorBusy = 0;
|
|
|
-
|
|
|
- sleep(1);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -219,7 +245,7 @@ MonitorTSensors ( SensorInfo_T* pSensorInfo)
|
|
|
int16_t SensorMax = 255;
|
|
|
int16_t SensorMin = 0;
|
|
|
int16_t DeassertThreshold;
|
|
|
- int index,j;
|
|
|
+
|
|
|
|
|
|
PSGood = g_BMCInfo.PowerGoodFlag;
|
|
|
|
|
@@ -237,22 +263,7 @@ MonitorTSensors ( SensorInfo_T* pSensorInfo)
|
|
|
{
|
|
|
pSensorInfo->Err = get_sensor_reading(pSensorInfo->SensorNumber, &SensorReading);
|
|
|
pSensorInfo->SensorReading = SensorReading;
|
|
|
-
|
|
|
- //keep sensor history
|
|
|
- if((g_BMCInfo.CurTimerSecond%180 == 0)) //3 minutes
|
|
|
- {
|
|
|
- for(index=0; index<SENSOR_NUMBERS;index++)
|
|
|
- {
|
|
|
- if(pSensorInfo->SensorNumber == gSensorHistoryInfo[index].SensorNum)
|
|
|
- {
|
|
|
- for(j=1;j<HISTORY_DATA_SIZE;j++)
|
|
|
- {
|
|
|
- gSensorHistoryInfo[index].History[j-1] = gSensorHistoryInfo[index].History[j];
|
|
|
- }
|
|
|
- gSensorHistoryInfo[index].History[HISTORY_DATA_SIZE-1] = pSensorInfo->SensorReading;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|