Parcourir la source

keep sensor history

zhangbo il y a 3 ans
Parent
commit
d4327e5793

+ 1 - 0
app/bmc/SysTimer/TimerTask.c

@@ -76,6 +76,7 @@ void TimerTask( int signo )	//signal handler
 				FlushIPMIToFlash();
 			}
 		}
+		//printf("CurTimerSecond %d\n", g_BMCInfo.CurTimerSecond);
 
 		ProcessTimerReq();
 		break;

+ 5 - 10
app/bmc/main.c

@@ -105,11 +105,11 @@ void main(void)
 // 	}
 
 	//检查软件授权
-	// if(CheckLicense() != 0)
-	// {
-	// 	system("killall -9 damon.sh");
-	// 	exit(0);
-	// }
+	if(CheckLicense() != 0)
+	{
+		system("killall -9 damon.sh");
+		exit(0);
+	}
 
 	PlatformInit();
 	Init_IPMI_FRU_SDR_SEL();
@@ -160,11 +160,6 @@ void main(void)
 	}
 
 	/* Create TimerTask */
-	// gThreadIndex = 0;
-	// if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,TimerTask,NULL))
- //    {
- //        printf("%s: Create TimerTask thread failed!\n", __FUNCTION__);
- //    }
 	signal(SIGALRM, TimerTask);
 
     struct itimerval new_value;

+ 31 - 20
app/bmc/msghndlr/SensorEvent/SensorDevice/SensorMonitor.c

@@ -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;
-				}
-			}
-		}		
+
 	}
 
 

+ 2 - 2
app/bmc/msghndlr/Storlead/Storlead.c

@@ -240,7 +240,7 @@ int  Storlead_GetSensorInfo(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
         if(pSensor.SDRRec->Type  == FULL_SDR_REC)       /*Full SDR*/
         {
             FullSDR = (FullSensorRec_T *)pSDRRec;
-            pGetSensorInfoRes->SensorInfo.OwnerID = FullSDR->OwnerID;
+            pGetSensorInfoRes->SensorInfo.OwnerID = g_BMCInfo.PrimaryIPMBAddr;//FullSDR->OwnerID;
             pGetSensorInfoRes->SensorInfo.OwnerLUN= FullSDR->OwnerLUN;
             pGetSensorInfoRes->SensorInfo.MaxReading = FullSDR->MaxReading;
             pGetSensorInfoRes->SensorInfo.MinReading = FullSDR->MinReading;
@@ -251,7 +251,7 @@ int  Storlead_GetSensorInfo(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
         else if(pSensor.SDRRec->Type == COMPACT_SDR_REC)   /*Compact SDR*/
         {
             CompSDR = (CompactSensorRec_T *)pSDRRec;
-            pGetSensorInfoRes->SensorInfo.OwnerID = CompSDR->OwnerID;
+            pGetSensorInfoRes->SensorInfo.OwnerID = g_BMCInfo.PrimaryIPMBAddr; //CompSDR->OwnerID;
             pGetSensorInfoRes->SensorInfo.OwnerLUN= CompSDR->OwnerLUN;
             pGetSensorInfoRes->SensorInfo.MaxReading = 0;
             pGetSensorInfoRes->SensorInfo.MinReading = 0;

+ 2 - 1
app/goahead-3.6.5/src/web_interface/src/fru.c

@@ -286,7 +286,8 @@ void getFruBoardInfo(Webs *wp)
 	pTmpStr++;
 	_boardCustomField = walloc(strLen+1);
 	memset(_boardCustomField, 0, strLen+1);
-	strncpy(_boardCustomField, pTmpStr, strLen);
+	//strncpy(_boardCustomField, pTmpStr, strLen);
+	strcpy(_boardCustomField, "hello dengjiu");
 
 	//Date
 	tval = ((board_data.MfgDateTime[2] << 16) + (board_data.MfgDateTime[1] << 8) + (board_data.MfgDateTime[0]));