Преглед изворни кода

get sensor history, get run time, chassis identify

zhangbo пре 3 година
родитељ
комит
d9e93c1c99

+ 7 - 3
app/bmc/Api.c

@@ -35,13 +35,13 @@ int PlatformInit(void)
 	GPIO_InitStruct.Pin = GAP_PIN | RACKID1_PIN | RACKID3_PIN | RACKID4_PIN | RACKID5_PIN;
 	stm32_gpio_init(GPIOI, &GPIO_InitStruct);
 
-	//LED灯 D2
-	GPIO_InitStruct.Pin = GPIO1_PIN;
+	//LED灯 
+	GPIO_InitStruct.Pin = IDENTIFY_PIN;
 	GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
 	GPIO_InitStruct.Pull = GPIO_NOPULL;
 	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 	stm32_gpio_write(IDENTIFY_PORT, IDENTIFY_PIN, GPIO_PIN_RESET);
-	stm32_gpio_init(GPIO1_PORT, &GPIO_InitStruct);
+	stm32_gpio_init(IDENTIFY_PORT, &GPIO_InitStruct);
 
 	g_BMCInfo.SelfTestByte 	=	0;
 	g_BMCInfo.SlotID		=	PDK_GetSlotID();
@@ -154,6 +154,7 @@ int PlatformInit(void)
 	g_BMCInfo.CurTimerSecond			=	0;
 	g_BMCInfo.BootValidMinutes			=	0;
 	g_BMCInfo.m_Lan_SetInProgress 		=	0;
+	g_BMCInfo.BootValidMinutesCount		=	0;
 
 	return 0;
 }
@@ -240,6 +241,7 @@ int Init_IPMI_FRU_SDR_SEL(void)
 		g_BMCInfo.IpmiConfig.FanControlInterval		=	FAN_CONTROL_INTERVAL;		
 		g_BMCInfo.IpmiConfig.RearmSetSensorThreshold	=	REARM_SET_SENSOR_THRESHOLD;
 		g_BMCInfo.IpmiConfig.SELTimeUTCOffset		=	8*60;
+		g_BMCInfo.IpmiConfig.totalRunTimeCount		=	0;
 		
 		//IPMB
 		g_BMCInfo.IpmiConfig.PrimaryIPMBSupport		=	PRIMARY_IPMB_SUPPORT;
@@ -346,6 +348,8 @@ int Init_IPMI_FRU_SDR_SEL(void)
 		pSetLanInfo->MACAddr[4]	=	0;
 		pSetLanInfo->MACAddr[5]	=	0;
 
+
+
 		FlushUserInfoTbl();
 		UpdateFlash();
 	}

+ 4 - 2
app/bmc/BmcType.h

@@ -77,6 +77,8 @@ typedef struct
 	//lan configuration
 	LanInfo_T 	LanInfo[1];	//方便扩展多个网卡。
 
+	uint32_t 	totalRunTimeCount;
+
 	
 } IPMIConfig_T;
 
@@ -90,10 +92,10 @@ typedef struct
 	ChannelInfo_T		ChannelTab[15];							//最大支持15个通道。
 
 	//time
-    uint32_t 			CurTimerTick;							//uint: 1ms
+    uint32_t 			CurTimerTick;							//uint: 1ms, 暂时未用
 	uint32_t			CurTimerSecond;
 	uint32_t			BootValidMinutes;						//This work time
-	uint32_t			TotalBootValidMinutes;					//Total work time
+	uint32_t			BootValidMinutesCount;					//Total work time
 //	uint32_t			SELTimeSecond;							//seconds from 1970-1-1 00:00:00, UTC
 	
 	//chassis

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

@@ -64,10 +64,17 @@ void TimerTask( int signo )	//signal handler
 			g_BMCInfo.SenConfig.SysResetTick++;
 		
 		g_BMCInfo.CurTimerSecond++;
+		g_BMCInfo.CurTimerTick++;
 		if(g_BMCInfo.PowerGoodFlag && (g_BMCInfo.CurTimerSecond%60 == 0))	// 1minute
 		{
 			g_BMCInfo.BootValidMinutes++;
-			g_BMCInfo.TotalBootValidMinutes++;
+			g_BMCInfo.BootValidMinutesCount++;
+			if((g_BMCInfo.BootValidMinutesCount%POH_MINS_PER_COUNT) == 0)
+			{
+				g_BMCInfo.BootValidMinutesCount = 0;
+				g_BMCInfo.IpmiConfig.totalRunTimeCount++;
+				FlushIPMIToFlash();
+			}
 		}
 
 		ProcessTimerReq();

+ 5 - 7
app/bmc/msghndlr/Chassis/ChassisDevice.c

@@ -295,8 +295,6 @@ GetChassisIdentify ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
 {
      ChassisIdentifyReq_T*    pChassisIdentifyReq =
         ( ChassisIdentifyReq_T*) pReq;
-     ChassisIdentifyRes_T*    pChassisIdentifyRes =
-        ( ChassisIdentifyRes_T*) pRes;
 
     if (ReqLen <= sizeof(ChassisIdentifyReq_T)) 
     {
@@ -316,7 +314,7 @@ GetChassisIdentify ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
             /* Check for the reserved bytes should b zero */
             if  ( 0 !=  (pChassisIdentifyReq->ForceIdentify & RESERVED_BITS_GETCHASSISIDENTIFY ) )
             {
-                pChassisIdentifyRes->CompletionCode = CC_INV_DATA_FIELD;
+                pRes[0] = CC_INV_DATA_FIELD;
                 return sizeof(uint8_t);	
             }
 
@@ -332,14 +330,14 @@ GetChassisIdentify ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
         }
         g_BMCInfo.ChassisIdentify = TRUE;
 
-        pChassisIdentifyRes->CompletionCode = CC_NORMAL;
+        pRes[0] = CC_NORMAL;
     }    	
     else 
     {
-        pChassisIdentifyRes->CompletionCode = CC_REQ_INV_LEN;
+        pRes[0] = CC_REQ_INV_LEN;
     }
     
-    return sizeof(ChassisIdentifyRes_T);
+    return 1;
 }
 
 
@@ -460,7 +458,7 @@ GetPOHCounter ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
 
     pGetPOHCounterRes->CompletionCode    = CC_NORMAL;
     pGetPOHCounterRes->MinutesPerCount   = POH_MINS_PER_COUNT;
-    pGetPOHCounterRes->POHCounterReading = (g_BMCInfo.BootValidMinutes/60);
+    pGetPOHCounterRes->POHCounterReading = g_BMCInfo.IpmiConfig.totalRunTimeCount;
    
     return sizeof(GetPOHCounterRes_T);
 }

+ 1 - 1
app/bmc/msghndlr/Chassis/ChassisDevice.h

@@ -34,7 +34,7 @@
 
 #define  CHASSIS_PARAMETER_VERSION                 0x01
 
-#define  POH_MINS_PER_COUNT                        60
+
 
 /******************************************************************************
 *

+ 1 - 0
app/bmc/msghndlr/PDKCmds.c

@@ -346,6 +346,7 @@ const CmdHndlrMap_T g_Storlead_CmdHndlr [] =
     { CMD_SET_LAN_INFO,      PRIV_USER,      Storlead_SetLanInfo,         0xff,  0xAAAA  ,0xFFFF},
     { CMD_GET_BLADE_INFO,      PRIV_USER,      Storlead_GetBladeInfo,         0xff,  0xAAAA  ,0xFFFF},
     { CMD_GET_SENSOR_NAME,      PRIV_USER,      Storlead_GetSensorName,         0xff,  0xAAAA  ,0xFFFF},
+    { CMD_GET_CURRUNTIME,      PRIV_USER,      Storlead_GetCurRunTime,         0xff,  0xAAAA  ,0xFFFF},    
      { 0x00,                     0x00,           0x00,                 0x00, 0x0000  ,  0x0000},
 };
 

+ 10 - 0
app/bmc/msghndlr/Storlead/Storlead.c

@@ -617,4 +617,14 @@ int Storlead_GetSensorName(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
     }
 
     return MAX_ID_STR_LEN+1;
+}
+
+int Storlead_GetCurRunTime(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
+{
+    pRes[0] = CC_NORMAL;
+    pRes[1] = g_BMCInfo.BootValidMinutes&0xff;        //LSB
+    pRes[2] = (g_BMCInfo.BootValidMinutes>>8)&0xff;
+    pRes[3] = (g_BMCInfo.BootValidMinutes>>16)&0xff;
+    pRes[4] = (g_BMCInfo.BootValidMinutes>>24)&0xff;
+    return 5;
 }

+ 1 - 0
app/bmc/msghndlr/Storlead/Storlead.h

@@ -15,3 +15,4 @@ int Storlead_GetLanInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
 int Storlead_SetLanInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
 int Storlead_GetBladeInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
 int Storlead_GetSensorName(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
+int Storlead_GetCurRunTime(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);

+ 1 - 0
app/bmc/msghndlr/cmdselect.c

@@ -810,6 +810,7 @@ const NetFnCmds_T g_Storlead [] =
 	{ CMD_SET_LAN_INFO          ,ENABLED},	
 	{ CMD_GET_BLADE_INFO          ,ENABLED},	
 	{ CMD_GET_SENSOR_NAME          ,ENABLED},	
+	{ CMD_GET_CURRUNTIME          ,ENABLED},	
 	{0,				0		},
 };
 

+ 2 - 1
app/common_include/com_BMCCfg.h

@@ -5,6 +5,7 @@
 #define 	MAX_FAN_NUMS 	10		//该系统最多支持10个风扇
 #define 	BLADE_NUMBERS	10
 #define SENSOR_NUMBERS				(15)
+#define  POH_MINS_PER_COUNT                        60
 //r1.4 	网页初步成型,ASSERT NULL的错误解掉了,清除了日志。
 #define FW_VERSION_MAJOR			(1)
 #define FW_VERSION_MINOR			(4)
@@ -14,7 +15,7 @@ extern uint8_t ChassisSecondaryIPMBAddr[BLADE_NUMBERS];
 
 //模块识别相关配置
 #define DEFAULT_IDENTIFY_TIMEOUT 	(15)	//15s
-#define IDENTIFY_PORT				GPIOC
+#define IDENTIFY_PORT				GPIOD
 #define IDENTIFY_PIN				GPIO_PIN_12
 /*
 0x00 0000 ~ 0x7F FFFF 	7MB		BMC Firmware

+ 0 - 7
app/common_include/com_IPMI_ChassisDevice.h

@@ -120,13 +120,6 @@ typedef struct
 
 }   ChassisIdentifyReq_T;
 
-/* ChassisIdentifyRes_T */
-typedef struct
-{
-    uint8_t   CompletionCode;
-    
-}   ChassisIdentifyRes_T;
-
 /* SetChassisCapabilitiesReq_T */
 typedef struct
 {

+ 1 - 0
app/common_include/com_IPMI_Storlead.h

@@ -13,6 +13,7 @@
 #define CMD_SET_LAN_INFO		0xD
 #define CMD_GET_BLADE_INFO		0xE
 #define CMD_GET_SENSOR_NAME		0xF
+#define CMD_GET_CURRUNTIME		0x10
 
 
 #endif /* __COM_IPMI_STORLEAD_H__ */

+ 10 - 0
app/goahead-3.6.5/src/libipmi/inc/libipmi_ChassisDevice.h

@@ -85,6 +85,16 @@ typedef enum tag_FORCE_CHASSIS_ID
 uint16_t	LIBIPMI_HL_GetSystemBootOptions_BootFlags( IPMI20_UDS_SESSION_T *pUDSSession, BootFlags_T* pBootFlags,int timeout);
 uint16_t	LIBIPMI_HL_SetSystemBootOptions_BootFlags( IPMI20_UDS_SESSION_T *pUDSSession, BootFlags_T* pBootFlags,int timeout);
 
+
+uint16_t	IPMI_GetPOH( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t *min_per_cnt, uint32_t *counts,int timeout);
+uint16_t	IPMC_GetPOH( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint8_t *min_per_cnt, uint32_t *counts,int timeout);
+uint16_t IPMICMD_ChassisIdentify(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IdentifyInterval, uint8_t ForceIdentify, int timeout);
+uint16_t	IPMC_ChassisIdentify(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint8_t IdentifyInterval, uint8_t ForceIdentify, int timeout);
+
+
+
+
+
 #pragma pack()
 
 #ifdef  __cplusplus

+ 2 - 0
app/goahead-3.6.5/src/libipmi/inc/libipmi_storlead_OEM.h

@@ -117,5 +117,7 @@ int IPMI_GetSensorName(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t sensor_number,
 int IPMC_GetSensorName(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint8_t sensor_number, uint8_t *sensor_name, int timeout);
 int IPMI_GetSensorHistory(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t sensor_number, uint8_t *history_buf, int timeout);
 int IPMC_GetSensorHistory(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint8_t sensor_number, uint16_t offset, uint16_t length, uint8_t *history_buf, int timeout);
+uint16_t	IPMI_GetCurRunTime( IPMI20_UDS_SESSION_T *pUDSSession, uint32_t *minutes,int timeout);
+uint16_t	IPMC_GetCurRunTime( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint32_t *minutes,int timeout);
 #endif /* __LIBIPMI_STORLEAD_OEM_H__ */
 

+ 114 - 44
app/goahead-3.6.5/src/libipmi/src/libipmi_Chassis.c

@@ -170,21 +170,62 @@ uint16_t IPMICMD_SetSystemBootOptions(IPMI20_UDS_SESSION_T *pUDSSession, SetBoot
 
 
 
-uint16_t IPMICMD_ChassisIdentify(IPMI20_UDS_SESSION_T *pUDSSession,int timeout,ChassisIdentifyReq_T* ChassisIdReq)
+uint16_t IPMICMD_ChassisIdentify(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IdentifyInterval, uint8_t ForceIdentify, int timeout)
 {
-	 uint32_t		dwResLen;
-    	 uint16_t		wRet;
-	 ChassisIdentifyRes_T ChassisIdRes = {0};
-	 
-	 dwResLen = sizeof (ChassisIdentifyRes_T);
-	 
-	 wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+	uint32_t		dwResLen;
+   	uint16_t		wRet;
+	uint8_t 		Res[10];
+	uint8_t			Req[10];
+
+	Req[0] = IdentifyInterval;
+	Req[1] = ForceIdentify;
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
 					    NETFNLUN_IPMI_CHASSIS, CMD_CHASSIS_IDENTIFY,
-					    (uint8_t *)ChassisIdReq,sizeof(ChassisIdentifyReq_T),
-					    (uint8_t*)&ChassisIdRes, &dwResLen,
+					    Req,2,
+					    Res, &dwResLen,
 					    timeout);
+
+	if((wRet != 0) || (Res[0] != 0))
+	{
+		printf("ChassisIdentify failed! ccode = %d\n", Res[0]);
+		return -1;
+	}
 					    
-	return wRet;
+	return 0;
+}
+
+uint16_t	IPMC_ChassisIdentify(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint8_t IdentifyInterval, uint8_t ForceIdentify, int timeout)
+{
+
+	uint16_t 	wRet = 0;
+	uint8_t 	Req[10] = {0};
+	uint8_t		Res[10];
+	uint32_t	dwResLen;
+	
+	//get title
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_CHASSIS;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_CHASSIS_IDENTIFY;	
+	Req[7] = IdentifyInterval;
+	Req[8] = ForceIdentify;
+	Req[9] = 0x100 - (Req[4] + Req[5] + Req[6] + Req[7] + Req[8])&0xff;
+
+	//dwResLen = sizeof(GetDevIDRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 
+											DEFAULT_NET_FN_LUN, CMD_SEND_MSG,
+											Req, 10,
+											Res, &dwResLen,
+											timeout);
+    if((wRet != 0) || (Res[6] != 0))
+	{
+		printf("---> IPMC_ChassisIdentify failed! ccode = %d\n", Res[6]);
+		return -1;
+	}
+	return 0;
 }
 
 
@@ -296,39 +337,6 @@ uint16_t	IPMC_GetChassisStatus( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbA
     return 0;
 }
 
-//will turn chassis identify on or off
-//BlinkTime - Set to TURN_OFF for turning off indefinitely
-//	      Set to Interval in secs for chassis identify to be on for that much time.
-// 	      for indefinite interval set ForceOn to 1.
-// ForceOn - overrides BlinkTime settings if set to 1.Set to 0 if controlling by interval
-uint16_t LIBIPMI_HL_ChassisIdentify(IPMI20_UDS_SESSION_T *pUDSSession, int timeout,uint8_t BlinkTimeSecs,FORCE_CHASSIS_ID ForceOn)
-{
-	uint16_t wRet;
-	
-	ChassisIdentifyReq_T ChassisIdReq = {0};
-	
-	//set interval to blinktimesecs. If caller set it to 0 so be it.
-	//The caller should always give a time to this function . He can Use SPEC_DEFAULT to get default timeout behavior.
-	ChassisIdReq.IdentifyInterval = BlinkTimeSecs;
-	ChassisIdReq.ForceIdentify = ForceOn;
-	
-	printf("id interval and  force in libipmi are %d %d \n",ChassisIdReq.IdentifyInterval,ChassisIdReq.ForceIdentify);
-	
-	wRet = IPMICMD_ChassisIdentify(pUDSSession,timeout,&ChassisIdReq);
-	
-	if(wRet == LIBIPMI_E_SUCCESS)
-	{
-		printf("Chassis identify command success\n");
-	}
-	else
-	{	
-		printf("Chassis Identify failed for the following params : %d %d",BlinkTimeSecs,ForceOn);
-	}
-	
-	return wRet;
-}
-
-
 uint16_t	LIBIPMI_HL_GetSystemBootOptions_BootFlags( IPMI20_UDS_SESSION_T *pUDSSession, BootFlags_T* pBootFlags,int timeout)
 {
 	uint16_t wRet;
@@ -399,3 +407,65 @@ uint16_t	LIBIPMI_HL_SetSystemBootOptions_BootFlags( IPMI20_UDS_SESSION_T *pUDSSe
 
 	return 0;
 }
+
+uint16_t	IPMI_GetPOH( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t *min_per_cnt, uint32_t *counts,int timeout)
+{
+    uint32_t		dwResLen;
+    uint16_t		wRet;
+    uint8_t 		Res[10];
+
+
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+					    NETFNLUN_IPMI_CHASSIS, CMD_GET_POH_COUNTER,
+					    NULL, 0 ,
+					    Res, &dwResLen,
+					    timeout);
+    if((wRet != 0) || (Res[0] != 0))
+    {
+    	printf("IPMI_GetPOH failed! ccode = %d\n", Res[0]);
+    	*min_per_cnt = 0;
+    	*counts = 0;
+    	return -1;
+    }
+
+    *min_per_cnt = Res[1];
+    *counts = (Res[5]<<24) | (Res[4]<<16) | (Res[3]<<8) | Res[2];
+    return 0;
+}
+
+uint16_t	IPMC_GetPOH( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint8_t *min_per_cnt, uint32_t *counts,int timeout)
+{
+
+	uint16_t 	wRet = 0;
+	uint8_t 	Req[10] = {0};
+	uint8_t		Res[50];
+	uint32_t	dwResLen;
+	
+
+	//get title
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_CHASSIS;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_GET_POH_COUNTER;	
+	Req[7] = 0x100 - (Req[4] + Req[5] + Req[6])&0xff;
+
+	//dwResLen = sizeof(GetDevIDRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 
+											DEFAULT_NET_FN_LUN, CMD_SEND_MSG,
+											Req, 8,
+											Res, &dwResLen,
+											timeout);
+    if((wRet != 0) || (Res[6] != 0))
+	{
+		printf("---> IPMC_GetPOH failed! ccode = %d\n", Res[6]);
+		return -1;
+	}
+    *min_per_cnt = Res[7];
+    *counts = (Res[11]<<24) | (Res[10]<<16) | (Res[9]<<8) | Res[8];
+        
+    return 0;
+}
+

+ 57 - 0
app/goahead-3.6.5/src/libipmi/src/libipmi_storlead_OEM.c

@@ -559,3 +559,60 @@ int IPMC_GetSensorHistory(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, u
 
     return 0;
 }
+
+uint16_t	IPMI_GetCurRunTime( IPMI20_UDS_SESSION_T *pUDSSession, uint32_t *minutes,int timeout)
+{
+    uint32_t		dwResLen;
+    uint16_t		wRet;
+    uint8_t 		Res[10];
+
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+					    NETFNLUN_IPMI_STORLEAD, CMD_GET_CURRUNTIME,
+					    NULL, 0 ,
+					    Res, &dwResLen,
+					    timeout);
+    if((wRet != 0) || (Res[0] != 0))
+    {
+    	printf("IPMI_GetCurRunTime failed! ccode = %d\n", Res[0]);
+    	*minutes = 0;
+    	return -1;
+    }
+    *minutes = (Res[4]<<24) | (Res[3]<<16) | (Res[2]<<8) | Res[1];
+    return 0;
+}
+
+uint16_t	IPMC_GetCurRunTime( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint32_t *minutes,int timeout)
+{
+
+	uint16_t 	wRet = 0;
+	uint8_t 	Req[10] = {0};
+	uint8_t		Res[50];
+	uint32_t	dwResLen;
+	
+
+	//get title
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_STORLEAD;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_GET_CURRUNTIME;	
+	Req[7] = 0x100 - (Req[4] + Req[5] + Req[6])&0xff;
+
+	//dwResLen = sizeof(GetDevIDRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 
+											DEFAULT_NET_FN_LUN, CMD_SEND_MSG,
+											Req, 8,
+											Res, &dwResLen,
+											timeout);
+    if((wRet != 0) || (Res[6] != 0))
+	{
+		printf("---> IPMC_GetCurRunTime failed! ccode = %d\n", Res[6]);
+		*minutes = 0;
+		return -1;
+	}
+    *minutes = (Res[10]<<24) | (Res[9]<<16) | (Res[8]<<8) | Res[7];
+        
+    return 0;
+}

+ 118 - 7
app/goahead-3.6.5/src/web_interface/src/config.c

@@ -329,15 +329,69 @@ void web_GetRunTime(Webs *wp){
     uint16_t    wRet = LIBIPMI_E_SUCCESS;
     IPMI20_UDS_SESSION_T    UDSSession;
     uint8_t target_addr;
-    uint32_t    TotalRunTime = 1000;    //模块总运行时间,单位: 分钟
-    uint32_t    CurRunTime = 50;        //模块本次运行时间,单位: 分钟
+    uint8_t min_per_cnt = 0;
+    uint32_t counts = 0;
+    uint32_t totalhours = 0;
+    uint32_t hours = 0, days = 0, minutes = 0;
+    uint32_t totalsMinutes = 0;
+    char    totalRunTimeStr[50]={0};
+    char    curRunTimeStr[50] = {0};
+
+    LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
+
+    //获取总运行时间
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+        wRet = IPMI_GetPOH( &UDSSession, &min_per_cnt, &counts,DEFAULT_TIMEOUT);
+        if(wRet != 0)
+        {
+            websError(wp, 404, "web_GetRunTime failed!");
+        }        
+    }
+    else
+    {
+        wRet = IPMC_GetPOH( &UDSSession, target_addr, &min_per_cnt, &counts, DEFAULT_TIMEOUT);
+        if(wRet != 0)
+        {
+            websError(wp, 404, "web_GetRunTime failed!");
+        }
+    }
+    totalhours = counts*min_per_cnt/60;  //hours
+    days = totalhours/24;
+    hours = totalhours%24;
+    sprintf(totalRunTimeStr, "%d days, %d hours", days, hours);
+
+    //获取当前运行时间
+    if(target_addr == 0x20)
+    {
+        wRet = IPMI_GetCurRunTime( &UDSSession, &totalsMinutes, DEFAULT_TIMEOUT);
+        if(wRet != 0)
+        {
+            websError(wp, 404, "web_GetRunTime failed!");
+        }        
+    }
+    else
+    {
+        wRet = IPMC_GetCurRunTime( &UDSSession, target_addr, &totalsMinutes, DEFAULT_TIMEOUT);
+        if(wRet != 0)
+        {
+            websError(wp, 404, "web_GetRunTime failed!");
+        }
+    }
+    days = totalsMinutes/(24*60);
+    hours = (totalsMinutes%(24*60))/(60);
+    minutes = totalsMinutes%60;
+    sprintf(curRunTimeStr, "%d days, %d hours, %d minutes", days, hours, minutes);
+
+    LIBIPMI_CloseSession(&UDSSession );
    
     
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON_AddItemToObject(root, "data", data);//根节点下添加
-    cJSON_AddStringToObject(data, "TotalRunTime", "129 hour 40 min");
-    cJSON_AddStringToObject(data, "CurRunTime", "1 hour 3 min");
+    cJSON_AddStringToObject(data, "TotalRunTime", totalRunTimeStr);
+    cJSON_AddStringToObject(data, "CurRunTime", curRunTimeStr);
     cJSON_AddStringToObject(root, "msg", "");
     cJSON_AddNumberToObject(root, "code", 200);
 
@@ -346,7 +400,7 @@ void web_GetRunTime(Webs *wp){
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp); 
-    websWrite(wp,"%s", pStr);
+    websWrite(wp, pStr);
     websFlush(wp, 0);
     websDone(wp);
     //printf("cJSON:%s\n", pStr);
@@ -364,30 +418,63 @@ void web_SetModIdentifyOn(Webs *wp){
     char *strTime = websGetVar(wp, "timeSelect", NULL);    //
     int timeSelect = atoi(strTime);
     uint8_t identifySec = 0;
+    uint8_t ForceIdentify = 0;
 
     switch(timeSelect)
     {
         case 0: //15s
             identifySec = 15;
+            ForceIdentify = 0;
             break;
         case 1: //30s
             identifySec = 30;
+            ForceIdentify = 0;
             break;
         case 2: //60s
             identifySec = 60;
+            ForceIdentify = 0;
             break;
         case 3: //120s
             identifySec = 120;
+            ForceIdentify = 0;
             break;
         case 4: //forever
             identifySec = 0xff;
+            ForceIdentify = 1;
             break;
         default:
             identifySec = 15;
+            ForceIdentify = 0;
             break;
     }
 
     printf("---> identify on Sec = %d\n", identifySec);
+
+    
+    
+    //Create session
+    LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
+
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+        wRet = IPMICMD_ChassisIdentify(&UDSSession, identifySec, ForceIdentify, DEFAULT_TIMEOUT);
+        if(wRet != 0)
+        {
+            printf("chassis identify failed! interval %d, force %d!\n", identifySec, ForceIdentify);
+        }
+    }
+    else
+    {
+        wRet = IPMC_ChassisIdentify(&UDSSession, target_addr, identifySec, ForceIdentify, DEFAULT_TIMEOUT);
+        if(wRet != 0)
+        {
+            printf("chassis identify failed! interval %d, force %d!\n", identifySec, ForceIdentify);
+        }
+    }
+
+    LIBIPMI_CloseSession(&UDSSession );
+    
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON_AddItemToObject(root, "data", data);//根节点下添加
@@ -399,7 +486,7 @@ void web_SetModIdentifyOn(Webs *wp){
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp); 
-    websWrite(wp,"%s", pStr);
+    websWrite(wp, pStr);
     websFlush(wp, 0);
     websDone(wp);
     //printf("cJSON:%s\n", pStr);
@@ -415,9 +502,33 @@ void web_SetModIdentifyOff(Webs *wp){
     IPMI20_UDS_SESSION_T    UDSSession;
     uint8_t target_addr;
     uint8_t identifySec = 0;
+    uint8_t ForceIdentify = 0;
 
 
     printf("---> identify off Sec = %d\n", identifySec);
+    //Create session
+    LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
+
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+        wRet = IPMICMD_ChassisIdentify(&UDSSession, identifySec, ForceIdentify, DEFAULT_TIMEOUT);
+        if(wRet != 0)
+        {
+            printf("chassis identify failed! interval %d, force %d!\n", identifySec, ForceIdentify);
+        }
+    }
+    else
+    {
+        wRet = IPMC_ChassisIdentify(&UDSSession, target_addr, identifySec, ForceIdentify, DEFAULT_TIMEOUT);
+        if(wRet != 0)
+        {
+            printf("chassis identify failed! interval %d, force %d!\n", identifySec, ForceIdentify);
+        }
+    }
+
+    LIBIPMI_CloseSession(&UDSSession );
+
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON_AddItemToObject(root, "data", data);//根节点下添加
@@ -429,7 +540,7 @@ void web_SetModIdentifyOff(Webs *wp){
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp); 
-    websWrite(wp,"%s", pStr);
+    websWrite(wp, pStr);
     websFlush(wp, 0);
     websDone(wp);
     //printf("cJSON:%s\n", pStr);