فهرست منبع

New sensor history

zhangbo 5 سال پیش
والد
کامیت
c9d53a9cbf

+ 19 - 0
app/bmc/Api.c

@@ -541,4 +541,23 @@ int UpdateUserInfoTble(void)
 {
 //	sf_read(5, USERTBL_FLASH_ADDR, (uint8_t*)g_BMCInfo.UserInfoTbl, sizeof(UserInfo_T)*MAX_USER_NUM);
 	return 0;
+}
+
+int getSensorHistory(uint8_t sensorNum, uint8_t *phistoryBuf)
+{
+	int i =0;
+	for(i=0;i<SENSOR_NUMBERS;i++)
+	{
+		if(gSensorHistoryInfo[i].SensorNum == sensorNum)
+		{
+			memcpy(phistoryBuf, gSensorHistoryInfo[i].History, HISTORY_DATA_SIZE);
+			return 0;
+		}
+	}
+	
+	if(i >= SENSOR_NUMBERS)
+	{
+		printf("---> can't find sensorNum!\n");
+		return -1;
+	}
 }

BIN
app/bmc/bmc_app


+ 1 - 0
app/bmc/main.c

@@ -37,6 +37,7 @@
 BMCInfo_t 	g_BMCInfo;
 pthread_t 	gThreadIDs[256];
 uint8_t		gThreadIndex = 0;
+SensorHistoryInfo_T 	gSensorHistoryInfo[SENSOR_NUMBERS];
 
 //void *test_thread(void *var);
 //uint8_t test_flag = 0;

+ 2 - 0
app/bmc/main.h

@@ -12,6 +12,7 @@
 #include "BmcType.h"
 #include "com_IPMI_SDRRecord.h"
 
+
 #include "Session.h"
 #include "sensor_tbl.h"
 #include "MsgHndlr.h"
@@ -103,5 +104,6 @@ extern KCSBridgeResInfo_T       m_KCSBridgeResInfo;
 extern TimerTaskTbl_T    		m_TimerTaskTbl [20];
 
 extern BMCInfo_t 	g_BMCInfo;
+extern SensorHistoryInfo_T 	gSensorHistoryInfo[SENSOR_NUMBERS];
 
 #endif /* __MAIN_H__ */

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

@@ -341,6 +341,7 @@ const CmdHndlrMap_T g_Storlead_CmdHndlr [] =
     { CMD_GET_SENSOR_INFO,      PRIV_USER,      Storlead_GetSensorInfo,     0xff,  0xAAAA  ,0xFFFF},
     { CMD_GET_SEL_ENTIRES,      PRIV_USER,      Storlead_GetSELEntires,     0xff,  0xAAAA  ,0xFFFF},
     { CMD_AUTHOR_VERIFY,        PRIV_USER,      Storlead_AuthorVerify,     0xff,  0xAAAA  ,0xFFFF},
+    { CMD_GET_SENSOR_HISTORY,   PRIV_USER,      Storlead_GetSensorHistory,     0xff,  0xAAAA  ,0xFFFF},
     { 0x00,                     0x00,           0x00,                 0x00, 0x0000  ,  0x0000},
 };
 

+ 1 - 0
app/bmc/msghndlr/SensorEvent/SensorDevice/Sensor.c

@@ -174,6 +174,7 @@ InitSensorInfo ()
 		pSensorInfo = (SensorInfo_T*)&pSMSharedMem->SensorInfo [i];
 		
 		g_BMCInfo.SenConfig.ValidSensorList[i]	=	sensor_tbl[i].sensor_number;
+        gSensorHistoryInfo[i].SensorNum = sensor_tbl[i].sensor_number;
 		
 		pSensorInfo->SensorNumber	= 	sensor_tbl[i].sensor_number;
 		pSensorInfo->SensorReading	=	0;

+ 17 - 11
app/bmc/msghndlr/SensorEvent/SensorDevice/SensorMonitor.c

@@ -227,7 +227,7 @@ MonitorTSensors ( SensorInfo_T*     pSensorInfo)
 //	uint8_t 				ReadFlags = 0;
 //	FullSensorRec_T*      	sfs=NULL;
 //	CompactSensorRec_T*   	scs=NULL;
-//	int				index,j;
+	int				index,j;
 	
 	PSGood = g_BMCInfo.PowerGoodFlag;
  
@@ -255,16 +255,22 @@ MonitorTSensors ( SensorInfo_T*     pSensorInfo)
 //		}
 		pSensorInfo->SensorReading = SensorReading;
 		
-//		//keep sensor history
-//		index = getSensorIndex(pSensorInfo->SensorNumber);
-//		if((index >= 0) && (g_BMCInfo.CurTimerSecond%180 == 0) && (g_sensorList[index].supportHistory == 1))	//3 minutes
-//		{
-//			for(j=1;j<HISTORY_DATA_SIZE;j++)
-//			{
-//				g_sensorHistory[index][j-1] =  g_sensorHistory[index][j];
-//			}
-//			g_sensorHistory[index][HISTORY_DATA_SIZE-1] = pSensorInfo->SensorReading;
-//		}
+		//keep sensor history
+		if((g_BMCInfo.CurTimerSecond%2/*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;
+				}
+			}
+		}
+		
 	}
 
 

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

@@ -352,4 +352,36 @@ int Storlead_AuthorVerify(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
     printf("Invalid username!\n");
     *pRes = CC_PASSWORD_TEST_FAILED;
     return 1;
+}
+
+int Storlead_GetSensorHistory(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
+{
+    uint8_t *pSensorHistory = pRes+3;
+    uint8_t  sensorNum = pReq[0];
+    uint16_t offset = (pReq[1]<<8) | pReq[2];
+    uint16_t len = (pReq[3]<<8) | pReq[4];
+    uint16_t total_len = 480;
+    *pRes= CC_NORMAL;
+    
+    if(offset >= total_len)
+    {
+        *pRes = CC_PARAM_OUT_OF_RANGE;
+        return 1;
+    }
+    
+    if(getSensorHistory(sensorNum, pSensorHistory) != 0)
+    {
+        *pRes = CC_PARAM_OUT_OF_RANGE;
+        return 1;
+    };
+    
+    
+    if(len > (total_len - offset))
+        len = total_len - offset;
+    printf("len = %d, offset = %d, total_len = %d\n", len, offset, total_len);
+    
+    *(pRes+1) = (len>>8)&0xff;
+    *(pRes+2) = len&0xff;
+    
+    return len+3;   
 }

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

@@ -6,4 +6,5 @@
 int  Storlead_GetSysInfo(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
 int  Storlead_GetSensorInfo(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
 int  Storlead_GetSELEntires(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
-int Storlead_AuthorVerify(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
+int Storlead_AuthorVerify(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
+int Storlead_GetSensorHistory(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);

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

@@ -801,6 +801,7 @@ const NetFnCmds_T g_Storlead [] =
 	{ CMD_GET_SENSOR_INFO          ,ENABLED},
 	{ CMD_GET_SEL_ENTIRES          ,ENABLED},
 	{ CMD_AUTHOR_VERIFY          ,ENABLED},
+	{ CMD_GET_SENSOR_HISTORY          ,ENABLED},		
 	{0,				0		},
 };
 

+ 23 - 22
app/bmc/sensor_driver.c

@@ -10,6 +10,7 @@
 #include "hal_interface_api.h"
 #include "linux/fcntl.h"
 
+static uint8_t i = 0;
 /* 
  * sensor number: 1
  * sensor name: +12V
@@ -27,14 +28,14 @@ int sensor_1_write(void)
 
 int sensor_1_read(uint8_t *reading)
 {
-	uint8_t buf = 5;
+	//uint8_t buf = 5;
 //	int fd = open("/dev/i2c3", O_RDWR);
 //	stm32_i2c_master_write(fd, 0xAA, &buf, 1);
 //	stm32_i2c_master_read(fd, 0xAA, &buf, 1);
 //	close(fd);
 	//printf("read sensor 1: %#x!\n", buf);
 	//*reading = buf;
-	*reading = 0xff;
+	*reading = i++;
 	return 0;
 }
 
@@ -57,13 +58,13 @@ int sensor_2_write(void)
 
 int sensor_2_read(uint8_t *reading)
 {
-	uint8_t buf = 4;
+//	uint8_t buf = 4;
 //	int fd = open("/dev/i2c3", O_RDWR);
 //	stm32_i2c_master_write(fd, 0xAA, &buf, 1);
 //	stm32_i2c_master_read(fd, 0xAA, &buf, 1);
 //	close(fd);
 	//*reading = buf;
-	*reading = 0xe0;
+	*reading = i;
 	return 0;
 }
 
@@ -86,13 +87,13 @@ int sensor_3_write(void)
 
 int sensor_3_read(uint8_t *reading)
 {
-	uint8_t buf = 0;
+//	uint8_t buf = 0;
 //	int fd = open("/dev/i2c3", O_RDWR);
 //	stm32_i2c_master_write(fd, 0x98, &buf, 1);
 //	stm32_i2c_master_read(fd, 0x98, &buf, 1);
 //	close(fd);
 	//*reading = buf;
-	*reading = 0x80;
+	*reading = i;
 	return 0;
 }
 
@@ -116,13 +117,13 @@ int sensor_4_write(void)
 
 int sensor_4_read(uint8_t *reading)
 {
-	uint8_t buf = 1;
+//	uint8_t buf = 1;
 //	int fd = open("/dev/i2c3", O_RDWR);
 //	stm32_i2c_master_write(fd, 0x98, &buf, 1);
 //	stm32_i2c_master_read(fd, 0x98, &buf, 1);
 //	close(fd);
 	//*reading = buf;
-	*reading = 0x8a;
+	*reading = i;
 	return 0;
 }
 
@@ -143,10 +144,10 @@ int sensor_5_write(void)
 
 int sensor_5_read(uint8_t *reading)
 {
-	uint16_t buf;
+//	uint16_t buf;
 //	stm32_adc_get_value(1, &buf);
 	//*reading = buf>>4;
-	*reading = 0x50;
+	*reading = i;
 	return 0;
 }
 
@@ -167,10 +168,10 @@ int sensor_6_write(void)
 
 int sensor_6_read(uint8_t *reading)
 {
-	uint16_t buf;
+//	uint16_t buf;
 //	stm32_adc_get_value(2, &buf);
 	//*reading = buf>>4;
-	*reading = 0x60;
+	*reading = i;
 	return 0;
 }
 
@@ -191,10 +192,10 @@ int sensor_7_write(void)
 
 int sensor_7_read(uint8_t *reading)
 {
-	uint16_t buf;
+//	uint16_t buf;
 //	stm32_adc_get_value(3, &buf);
 	//*reading = buf>>4;
-	*reading = 0x70;
+	*reading = i;
 	return 0;
 }
 
@@ -215,10 +216,10 @@ int sensor_8_write(void)
 
 int sensor_8_read(uint8_t *reading)
 {
-	uint16_t buf;
+//	uint16_t buf;
 //	stm32_adc_get_value(4, &buf);
 	//*reading = buf>>4;
-	*reading = 0x80;
+	*reading = i;
 	return 0;
 }
 
@@ -239,10 +240,10 @@ int sensor_9_write(void)
 
 int sensor_9_read(uint8_t *reading)
 {
-	uint16_t buf;
+//	uint16_t buf;
 //	stm32_adc_get_value(5, &buf);
 	//*reading = buf>>4;
-	*reading = 0x90;
+	*reading = i;
 	return 0;
 }
 
@@ -263,10 +264,10 @@ int sensor_10_write(void)
 
 int sensor_10_read(uint8_t *reading)
 {
-	uint16_t buf;
+//	uint16_t buf;
 //	stm32_adc_get_value(6, &buf);
 	//*reading = buf>>4;
-	*reading = 0xA0;
+	*reading = i;
 	return 0;
 }
 
@@ -287,10 +288,10 @@ int sensor_11_write(void)
 
 int sensor_11_read(uint8_t *reading)
 {
-	uint16_t buf;
+//	uint16_t buf;
 //	stm32_adc_get_value(7, &buf);
 	//*reading = buf>>4;
-	*reading = 0xB0;
+	*reading = i;
 	return 0;
 }
 

+ 6 - 0
app/common_include/com_BmcType.h

@@ -308,5 +308,11 @@ typedef struct
     char password[MAX_PASSWORD_LEN];
 } AuthorVerify_T;
 
+typedef struct 
+{
+    uint8_t SensorNum;
+    uint8_t History[HISTORY_DATA_SIZE];
+} SensorHistoryInfo_T;
+
 #pragma pack()
 #endif /* __BMC_TYPE_H__ */

+ 1 - 0
app/common_include/com_IPMIDefs.h

@@ -66,6 +66,7 @@
 #define MAX_PASSWORD_LEN        (20+1)
 #define SDR_ALLOC_UNIT_SIZE                 0x40
 #define SDR_MAX_RECORD_SIZE                 0x1 	//Maximum record size in allocation units
+#define HISTORY_DATA_SIZE 		480
 
 #define AUTH_FILE_PATH		"/etc/goahead/auth.txt"
 

+ 1 - 0
app/common_include/com_IPMI_Storlead.h

@@ -5,5 +5,6 @@
 #define CMD_GET_SENSOR_INFO   	0x1
 #define CMD_GET_SEL_ENTIRES		0x2
 #define CMD_AUTHOR_VERIFY 		0x3
+#define CMD_GET_SENSOR_HISTORY  0x4
 
 #endif /* __COM_IPMI_STORLEAD_H__ */

+ 2 - 0
app/goahead-3.6.5/src/goahead.c

@@ -212,6 +212,8 @@ websDefineAction("resetBmc", resetBmc);
 
 //server_health
 websDefineAction("setThreshold", setThreshold);
+websDefineAction("web_getSensorHistory", web_getSensorHistory);
+
 
 
 /**************** user code after goahead end************************/

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

@@ -108,7 +108,7 @@ extern OemWebFlags_T g_OemWebFlags;
 //uint16_t LIBIPMI_HL_FanCtrol( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t fanIndex, uint8_t fanMode, uint8_t fanLevel, int timeout);
 //int LIBIPMI_HL_GetFanStatus( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t fanIndex, OemFanStatus_T *pFanStatus, int timeout);
 uint16_t LIBIPMI_HL_GetSysInfo( IPMI20_UDS_SESSION_T *pUDSSession, SysInfo_T *pSysInfo, int timeout);
-//uint16_t LIBIPMI_HL_GetSensorHistory( IPMI20_UDS_SESSION_T *pUDSSession, sensor_history_st *pSensorHistory_st, int card_index, int sensor_number, int IPMB_ADDR);
+uint16_t LIBIPMI_HL_GetSensorHistory( IPMI20_UDS_SESSION_T *pUDSSession, sensor_history_st *pSensorHistory_st, int card_index, int sensor_number, int IPMB_ADDR);
 //uint16_t LIBIPMI_HL_GetAllCards(IPMI20_UDS_SESSION_T *pUDSSession, CardStatus_T*	pResBladeSts, int timeout);
 //int	 LIBIPMI_HL_GetChassisInfo(IPMI20_UDS_SESSION_T *pUDSSession, OemChassisInfo_T* pBladeInfo, int timeout);
 //int 	 LIBIPMI_HL_GetBladeStatus(IPMI20_UDS_SESSION_T *pUDSSession, OemBladeStatus_T* pBladeStatus, int timeout);

+ 90 - 84
app/goahead-3.6.5/src/libipmi/src/libipmi_storlead_OEM.c

@@ -318,94 +318,100 @@ uint16_t LIBIPMI_HL_GetSysInfo( IPMI20_UDS_SESSION_T *pUDSSession, SysInfo_T *pS
 
 
 
-// uint16_t
-// LIBIPMI_HL_GetSensorHistory( IPMI20_UDS_SESSION_T *pUDSSession, sensor_history_st *pSensorHistory_st, int card_index, int sensor_number, int IPMB_ADDR)
-// {
-// 	printf(">come in history\n");
-// 	int i = 0;
-// 	uint8_t	 	RawHistory[MAX_HISTORY_LEN];
-// 	uint16_t    wRet;
-// 	uint32_t    dwResLen;
-// 	uint32_t	sdr_buff_size = 100;
-// 	uint8_t 	Req[5];
-// 	uint8_t 	Res[MAX_HISTORY_LEN+3];	
-// 	int timeout = 3;
-// 	FullSensorRec_T sdr_buffer;
-// 	uint16_t 	offset = 0;
-// 	uint16_t	reqLen = 0, resLen = 0;
-// 	//get factors
-// 	LIBIPMI_HL_GetSpecificSDR( pUDSSession, (uint8_t*)&sdr_buffer, &sdr_buff_size, sensor_number, timeout );	
-	
-// 	//get history
-// 	// if( pUDSSession->byMediumType == IPMB_MEDIUM )
-// 	// {
-// 	// 	reqLen = 22;	//32 bytes - ipmb message header - response header - checksum2
-// 	// 	do{
-// 	// 		Req[0] = sensor_number;
-// 	// 		Req[1] = (offset>>8)&0xff;
-// 	// 		Req[2] = offset&0xff;
-// 	// 		Req[3] = (reqLen>>8)&0xff;
-// 	// 		Req[4] = reqLen&0xff;
-// 	// 		wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,   0x2e<<2, 0x89,
-// 	// 												(uint8_t*)Req, 5,
-// 	// 												(uint8_t *)Res, &dwResLen,
-// 	// 												timeout);
-// 	// 		if(wRet != 0)
-// 	// 		{
-// 	// 			return -1;
-// 	// 		}
-// 	// 		resLen = (Res[1]<<8) | Res[2];
-// 	// 		if(resLen > MAX_HISTORY_LEN)
-// 	// 		{
-// 	// 			printf("---> response length error: resLen = %#x\n", resLen);
-// 	// 			return -1;
-// 	// 		}
-// 	// 		memcpy(&RawHistory[offset],&Res[3],resLen);
-// 	// 		offset += resLen;
-// 	// 		if(offset >= MAX_HISTORY_LEN)	//get all history datas
-// 	// 		{
-// 	// 			reqLen = 0;
-// 	// 			break;
-// 	// 		}
-// 	// 		reqLen = ((MAX_HISTORY_LEN-offset)>22) ? 22 : (MAX_HISTORY_LEN-offset);		
-// 	// 	}while(reqLen);		
-// 	// }
-// 	// else
-// 	{
-// 		Req[0] = sensor_number;
-// 		Req[1] = 0;
-// 		Req[2] = 0;
-// 		Req[3] = (MAX_HISTORY_LEN>>8)&0xff;
-// 		Req[4] = MAX_HISTORY_LEN & 0xff;
-// 		wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,   0x2e<<2, 0x89,
-// 														(uint8_t*)Req, 5,
-// 														(uint8_t *)Res, &dwResLen,
-// 														timeout);
-// 		if(wRet != 0)
-// 		{
-// 			return -1;
-// 		}
+uint16_t
+LIBIPMI_HL_GetSensorHistory( IPMI20_UDS_SESSION_T *pUDSSession, sensor_history_st *pSensorHistory_st, int card_index, int sensor_number, int IPMB_ADDR)
+{
+	printf("---> come in history\n");
+	int i = 0;
+	//uint8_t	 	RawHistory[MAX_HISTORY_LEN];
+	uint16_t    wRet;
+	uint32_t    dwResLen;
+	uint32_t	sdr_buff_size = 255;
+	uint8_t 	Req[5];
+	uint8_t 	*Res = (uint8_t*)walloc(MAX_HISTORY_LEN+3);
+	int timeout = 3;
+	FullSensorRec_T sdr_buffer;
+	uint16_t 	offset = 0;
+	uint16_t	reqLen = 0, resLen = 0;
+	float 		tmpValue;
+	//get factors
+	LIBIPMI_HL_GetSpecificSDR( pUDSSession, (uint8_t*)&sdr_buffer, &sdr_buff_size, sensor_number, timeout );	
+	
+	//get history
+	// if( pUDSSession->byMediumType == IPMB_MEDIUM )
+	// {
+	// 	reqLen = 22;	//32 bytes - ipmb message header - response header - checksum2
+	// 	do{
+	// 		Req[0] = sensor_number;
+	// 		Req[1] = (offset>>8)&0xff;
+	// 		Req[2] = offset&0xff;
+	// 		Req[3] = (reqLen>>8)&0xff;
+	// 		Req[4] = reqLen&0xff;
+	// 		wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,   0x2e<<2, 0x89,
+	// 												(uint8_t*)Req, 5,
+	// 												(uint8_t *)Res, &dwResLen,
+	// 												timeout);
+	// 		if(wRet != 0)
+	// 		{
+	// 			return -1;
+	// 		}
+	// 		resLen = (Res[1]<<8) | Res[2];
+	// 		if(resLen > MAX_HISTORY_LEN)
+	// 		{
+	// 			printf("---> response length error: resLen = %#x\n", resLen);
+	// 			return -1;
+	// 		}
+	// 		memcpy(&RawHistory[offset],&Res[3],resLen);
+	// 		offset += resLen;
+	// 		if(offset >= MAX_HISTORY_LEN)	//get all history datas
+	// 		{
+	// 			reqLen = 0;
+	// 			break;
+	// 		}
+	// 		reqLen = ((MAX_HISTORY_LEN-offset)>22) ? 22 : (MAX_HISTORY_LEN-offset);		
+	// 	}while(reqLen);		
+	// }
+	// else
+	{
+		Req[0] = sensor_number;
+		Req[1] = 0;
+		Req[2] = 0;
+		Req[3] = (MAX_HISTORY_LEN>>8)&0xff;
+		Req[4] = MAX_HISTORY_LEN & 0xff;
+		wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,   
+									NETFNLUN_IPMI_STORLEAD, CMD_GET_SENSOR_HISTORY,
+									(uint8_t*)Req, 5,
+									(uint8_t *)Res, &dwResLen,
+									timeout);
+		if(wRet != 0)
+		{
+			return -1;
+		}
 		
-// 		resLen = (Res[1]<<8) | Res[2];
-// 		if(resLen > MAX_HISTORY_LEN)
-// 		{
-// 			printf("---> response length error: resLen = %#x\n", resLen);
-// 			return -1;
-// 		}
-// 		memcpy(RawHistory,&Res[3],resLen);
-// 	}
+		resLen = (Res[1]<<8) | Res[2];
+		if(resLen > MAX_HISTORY_LEN)
+		{
+			printf("---> response length error: resLen = %#x\n", resLen);
+			return -1;
+		}
+		//memcpy(RawHistory,&Res[3],resLen);
+	}
 	
-// 	for(i=0;i < 480; i++)
-// 	{
-// 		ipmi_convert_reading( (uint8_t*)&sdr_buffer, RawHistory[i], (float*)&pSensorHistory_st->sensor_history[i] );
-// 	}
+	for(i=0;i < 480; i++)
+	{
+		ipmi_convert_reading( (uint8_t*)&sdr_buffer, Res[3+i], &tmpValue );
+		pSensorHistory_st->sensor_history[i] = tmpValue;
+		//printf("raw: %#x, float: %f\n", Res[3+i], tmpValue);
+	}
 	
-// 	memset(pSensorHistory_st->sensor_name, 0,sizeof(pSensorHistory_st->sensor_name));
-// 	memcpy(pSensorHistory_st->sensor_name, sdr_buffer.IDStr, sdr_buffer.IDStrTypeLen&0x3f);
-// 	pSensorHistory_st->sensor_num = sensor_number;
+	memset(pSensorHistory_st->sensor_name, 0,sizeof(pSensorHistory_st->sensor_name));
+	memcpy(pSensorHistory_st->sensor_name, sdr_buffer.IDStr, sdr_buffer.IDStrTypeLen&0x3f);
+	pSensorHistory_st->sensor_num = sensor_number;
 
-// 	return 0;
-// }
+	wfree(Res);
+
+	return 0;
+}
 
 
 // uint16_t	LIBIPMI_HL_GetAllCards(IPMI20_UDS_SESSION_T *pUDSSession,

+ 9 - 9
app/goahead-3.6.5/src/libipmi/src/sensor_helpers.c

@@ -348,9 +348,9 @@ int ipmi_convert_reading( uint8_t *sdr_buffer, uint8_t raw_reading, float *conve
     switch( record->Units1 >> 6 )
     {
         case SDR_READING_UNSIGNED:
-            printf( "Sensor reading number format is unsigned\n" );
-            printf( "Sensor min: %d\n", sensor_min );
-            printf( "Sensor max: %d\n", sensor_max );
+            // printf( "Sensor reading number format is unsigned\n" );
+            // printf( "Sensor min: %d\n", sensor_min );
+            // printf( "Sensor max: %d\n", sensor_max );
             break;
 
         case SDR_READING_1SCOMP:
@@ -364,9 +364,9 @@ int ipmi_convert_reading( uint8_t *sdr_buffer, uint8_t raw_reading, float *conve
             if( sensor_max & (uint8_t)0x80 )
                 sensor_max = -( ~sensor_max & 0xff );
 
-            printf( "Sensor reading number format is 1's complement: %d\n", raw_number );
-            printf( "Sensor min: %d\n", sensor_min );
-            printf( "Sensor max: %d\n", sensor_max );
+            // printf( "Sensor reading number format is 1's complement: %d\n", raw_number );
+            // printf( "Sensor min: %d\n", sensor_min );
+            // printf( "Sensor max: %d\n", sensor_max );
             break;
 
         case SDR_READING_2SCOMP:
@@ -380,9 +380,9 @@ int ipmi_convert_reading( uint8_t *sdr_buffer, uint8_t raw_reading, float *conve
             if( sensor_max & (uint8_t)0x80 )
                 sensor_max = -( ( ~sensor_max & 0xff ) + 1 );
 
-            printf( "Sensor reading number format is 2's complement: %d\n", raw_number );
-            printf( "Sensor min: %d\n", sensor_min );
-            printf( "Sensor max: %d\n", sensor_max );
+            // printf( "Sensor reading number format is 2's complement: %d\n", raw_number );
+            // printf( "Sensor min: %d\n", sensor_min );
+            // printf( "Sensor max: %d\n", sensor_max );
             break;
 
         case SDR_READING_NONANALOG:

+ 1 - 0
app/goahead-3.6.5/src/web_interface/inc/server_health.h

@@ -3,5 +3,6 @@
 
 #include "goahead.h"
 void setThreshold(Webs *wp);
+void web_getSensorHistory(Webs *wp);
 
 #endif /* __SERVER_HEALTH_H__ */

+ 92 - 0
app/goahead-3.6.5/src/web_interface/src/server_health.c

@@ -121,3 +121,95 @@ void setThreshold(Webs *wp){
 
 }
 
+void web_getSensorHistory(Webs *wp)
+{
+    IPMI20_UDS_SESSION_T    UDSSession;
+    int i = 0,j=0;
+    int wRet = 0;
+    sensor_history_st *pSensorHistory = (sensor_history_st *)walloc(sizeof(sensor_history_st));
+    char tmpBuf[10];
+    char * const historyBuf = walloc(5000);
+    char *strBuf = historyBuf;
+    uint8_t CARDE_INDEX = 0;
+    uint8_t IPMB_ADDR = 0;
+
+
+    char *strSensorNumber = websGetVar(wp, "SensorNumber", NULL);
+    int   SensorNumber = atoi(strSensorNumber);
+    
+    //Create session
+    LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
+
+    wRet = LIBIPMI_HL_GetSensorHistory(&UDSSession, pSensorHistory, CARDE_INDEX, SensorNumber, IPMB_ADDR);
+    
+    if(wRet != 0){
+        printf("---> LIBIPMI_HL_GetSensorHistory error, return %#x\n", wRet);
+         websError(wp, 404, "Get Sensor History error!");
+        return ;
+    }
+
+    //Close session
+    LIBIPMI_CloseSession(&UDSSession );
+    
+    for(i=0;i<HISTORY_DATA_SIZE;i++)
+    {
+        sprintf(tmpBuf, "%0.3f", pSensorHistory->sensor_history[i]);
+        j = 0;
+        while(tmpBuf[j] != '\0')
+        {
+            j++;
+            if(j>=10)
+                break;
+        }
+        tmpBuf[j] = ',';    //replace '\0' by ','
+        j++;        //point to next empty
+        sprintf(strBuf, "%s", tmpBuf);
+        strBuf += j;
+    }
+    strBuf--;
+    *strBuf = '\0';
+
+    printf("---> strBuf: %s\n", strBuf);
+
+    char *pStr;
+    cJSON * root =  cJSON_CreateObject();
+
+    cJSON_AddNumberToObject(root, "SensorNum", pSensorHistory->sensor_num);
+    cJSON_AddStringToObject(root, "SensorName", pSensorHistory->sensor_name);
+    cJSON_AddStringToObject(root, "history", historyBuf);
+    
+   
+    pStr = cJSON_PrintUnformatted(root);
+
+    printf("---> cJSON Str:\n%s\n", pStr);
+    websSetStatus(wp, 200);
+    websWriteHeaders(wp, -1, 0);
+    websWriteEndHeaders(wp); 
+    websWrite(wp, pStr);
+    websFlush(wp, 0);
+    websDone(wp);
+
+    if(pStr)
+        wfree(pStr);
+    if(root)
+        cJSON_Delete(root);
+
+
+    if(historyBuf)
+        wfree(historyBuf);
+    if(pSensorHistory)
+        wfree(pSensorHistory);
+
+
+}
+
+
+
+
+
+
+
+
+
+
+