Quellcode durchsuchen

server_health web ok

zhangbo vor 3 Jahren
Ursprung
Commit
d592d676b5

+ 1 - 1
app/bmc/Api.c

@@ -797,7 +797,7 @@ int API_BridgeInternal(MsgPkt_T* pReqPkt, MsgPkt_T* pResPkt, uint8_t DestAddr, i
 			m_PendingBridgedResTbl[PBTbl][SeqNum].ChannelNum = pReqPkt->Channel; 
 			m_PendingBridgedResTbl[PBTbl][SeqNum].OriginSrc  = ORIGIN_INT_REQ;
 			g_BMCInfo.SendMsgSeqNum = SeqNum;
-			printf("g_BMCInfo.SendMsgSeqNum %d\n", g_BMCInfo.SendMsgSeqNum);
+//			printf("g_BMCInfo.SendMsgSeqNum %d\n", g_BMCInfo.SendMsgSeqNum);
 
 			/* Format Sequence Number */
 			pReqMsgHdr->RqSeqLUN = ((g_BMCInfo.SendMsgSeqNum) << 2) & 0xFC;

+ 15 - 4
app/bmc/msghndlr/Storlead/Storlead.c

@@ -354,12 +354,23 @@ int Storlead_AuthorVerify(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
     return 1;
 }
 
+/*
+    Req[0]: sensor number
+    Req[1]: offset_lsb
+    Req[2]: offset_msb
+    Req[3]: readlen_lsb
+    Req[4]: readlen_msb
+    -----------------------
+    Res[0]: ccode
+    Res[1]: return len lsb
+    Res[2]: return len msb
+*/
 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 offset = (pReq[2]<<8) | pReq[1];
+    uint16_t len = (pReq[4]<<8) | pReq[3];
     uint16_t total_len = 480;
     *pRes= CC_NORMAL;
     
@@ -380,8 +391,8 @@ int Storlead_GetSensorHistory(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
         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;
+    *(pRes+1) = len&0xff;
+    *(pRes+2) = (len>>8)&0xff;
     
     return len+3;   
 }

+ 6 - 0
app/goahead-3.6.5/src/libipmi/inc/libipmi_sdr.h

@@ -147,6 +147,12 @@ uint16_t Storlead_GetCompleteSDR( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t Ipm
 										int SensorNumber,
 										int timeout );
 
+  uint16_t IPMC_GetSpecificSDR( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+                                                uint8_t *sdr_buffer, 
+                                                uint32_t* sdr_buff_size,
+                                                int SensorNumber,
+                                                int timeout );
+
 
 #ifdef  __cplusplus
 }

+ 3 - 0
app/goahead-3.6.5/src/libipmi/inc/libipmi_sensor.h

@@ -57,6 +57,9 @@ extern "C" {
                                                SetSensorThresholdReq_T *pReqSetSensorThreshold,
                                                SetSensorThresholdRes_T *pResSetSensorThreshold,
                                                int timeout);
+uint16_t  IPMC_SetSensorThreshold( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+                    SetSensorThresholdReq_T *pReqSetSensorThreshold,
+                    int timeout);
 
 /* 35.9 Get Sensor Thresholds Command */
   uint16_t IPMICMD_GetSensorThreshold( IPMI20_UDS_SESSION_T *pUDSSession,

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

@@ -92,7 +92,6 @@ typedef struct{
 
 #pragma pack()
 
-extern OemWebFlags_T g_OemWebFlags;
 extern uint8_t gIPMBAddr[BLADE_NUMBERS];
 extern uint8_t gChassisManageEn;
 //uint16_t LIBIPMI_HL_GetIPMCSensorInfo(IPMI20_UDS_SESSION_T *pUDSSession, SenInfo_T *pSensorInfo,uint32_t *nNumSensor,int timeout);
@@ -116,5 +115,7 @@ uint16_t IPMC_restoreFactorySettings(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t
 int LIBIPMI_IPMC_GetDeviceID(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, GetDevIDRes_T *DevIDRes, int timeout);
 int IPMI_GetSensorName(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t sensor_number, uint8_t *sensor_name, int timeout);
 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);
 #endif /* __LIBIPMI_STORLEAD_OEM_H__ */
 

+ 20 - 20
app/goahead-3.6.5/src/libipmi/src/libipmi_StorDevice.c

@@ -60,7 +60,7 @@ uint16_t IPMICMD_GetSELAllocationInfo(IPMI20_UDS_SESSION_T *pUDSSession,
 
 	dwResLen = sizeof(SELAllocInfo_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NETFNLUN_IPMI_APP, CMD_GET_SEL_ALLOCATION_INFO,
+						NETFNLUN_IPMI_STORAGE, CMD_GET_SEL_ALLOCATION_INFO,
 						(uint8_t*)DummyReqData, 0,
 						(uint8_t *)pResGetSELAllocInfo, &dwResLen,
 						timeout);
@@ -77,7 +77,7 @@ uint16_t IPMICMD_ReserveSEL(IPMI20_UDS_SESSION_T *pUDSSession,
 
 	memset(pReserveSelRes, 0, sizeof(ReserveSELRes_T));
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NETFNLUN_IPMI_APP, CMD_RESERVE_SEL,
+						NETFNLUN_IPMI_STORAGE, CMD_RESERVE_SEL,
 						NULL, 0,
 						(uint8_t *)pReserveSelRes, &dwResLen,
 						timeout);
@@ -108,7 +108,7 @@ uint16_t IPMC_ReserveSEL(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
 
 	Req[0] = 0x40;	//Track | channel 0
 	Req[1] = IpmbAddr;
-	Req[2] = NETFNLUN_IPMI_APP;
+	Req[2] = NETFNLUN_IPMI_STORAGE;
 	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
 	Req[4] = 0x20;
 	Req[5] = 0x10;
@@ -147,7 +147,7 @@ uint16_t IPMICMD_GetSELEntry(IPMI20_UDS_SESSION_T *pUDSSession,
 	uint16_t wRet = 0;
 
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NETFNLUN_IPMI_APP, CMD_GET_SEL_ENTRY,
+						NETFNLUN_IPMI_STORAGE, CMD_GET_SEL_ENTRY,
 						(uint8_t*)pGetSELReqData, sizeof(GetSELReq_T),
 						(uint8_t *)pGetSELResData, &ResDataLen,
 						timeout);
@@ -244,7 +244,7 @@ uint16_t IPMICMD_AddSELEntry(IPMI20_UDS_SESSION_T *pUDSSession,
 
 	dwResLen = sizeof(AddSELRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NETFNLUN_IPMI_APP, CMD_ADD_SEL_ENTRY,
+						NETFNLUN_IPMI_STORAGE, CMD_ADD_SEL_ENTRY,
 						(uint8_t*)pSELReqData, sizeof(SELEventRecord_T),
 						(uint8_t *)pSELResData, &dwResLen,
 						timeout);
@@ -269,7 +269,7 @@ uint16_t IPMICMD_DeleteSELEntry(IPMI20_UDS_SESSION_T *pUDSSession,
 	//first do a SEL reservation
 	dwResLen = sizeof(ReserveSELRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NETFNLUN_IPMI_APP, CMD_RESERVE_SEL,
+						NETFNLUN_IPMI_STORAGE, CMD_RESERVE_SEL,
 						NULL, 0,
 						(uint8_t *)&ReserveSelRes, &dwResLen,
 						timeout);
@@ -293,7 +293,7 @@ uint16_t IPMICMD_DeleteSELEntry(IPMI20_UDS_SESSION_T *pUDSSession,
 	DeleteSELReqData.RecID = RecordID;
 
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NETFNLUN_IPMI_APP, CMD_DELETE_SEL_ENTRY,
+						NETFNLUN_IPMI_STORAGE, CMD_DELETE_SEL_ENTRY,
 						(uint8_t*)&DeleteSELReqData, sizeof(DeleteSELReqData),
 						(uint8_t *)&DeleteSELResData, &dwResLen,
 						timeout);
@@ -314,7 +314,7 @@ uint16_t IPMICMD_ClearSEL(IPMI20_UDS_SESSION_T *pUDSSession,
 	//first do a SEL reservation
  	dwResLen = sizeof(ReserveSELRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NETFNLUN_IPMI_APP, CMD_RESERVE_SEL,
+						NETFNLUN_IPMI_STORAGE, CMD_RESERVE_SEL,
 						(uint8_t*)DummyReqData, 0,
 						(uint8_t *)&ReserveSelRes, &dwResLen,
 						timeout);
@@ -343,7 +343,7 @@ uint16_t IPMICMD_ClearSEL(IPMI20_UDS_SESSION_T *pUDSSession,
 
 	dwResLen = sizeof(ClearSELRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NETFNLUN_IPMI_APP, CMD_CLEAR_SEL,
+						NETFNLUN_IPMI_STORAGE, CMD_CLEAR_SEL,
 						(uint8_t*)&ClearSelReq, sizeof(ClearSELReq_T),
 						(uint8_t *)&ClearSelRes, &dwResLen,
 						timeout);
@@ -977,7 +977,7 @@ uint16_t IPMICMD_GetFRUInventoryAreaInfo(IPMI20_UDS_SESSION_T *pUDSSession,
 
 	dwResLen = sizeof(FRUInventoryAreaInfoRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NETFNLUN_IPMI_APP, CMD_FRU_INVENTORY_AREA_INFO,
+						NETFNLUN_IPMI_STORAGE, CMD_FRU_INVENTORY_AREA_INFO,
 						(uint8_t *)pReqFRUInventoryAreaInfo, sizeof(FRUInventoryAreaInfoReq_T),
 						(uint8_t *)pResFRUInventoryAreaInfo, &dwResLen,
 						timeout);
@@ -997,7 +997,7 @@ uint16_t IPMICMD_ReadFRUData(IPMI20_UDS_SESSION_T *pUDSSession,
 
 	dwResLen = sizeof(FRUReadRes_T) + (pFRUReadReqData->CountToRead);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NETFNLUN_IPMI_APP, CMD_READ_FRU_DATA,
+						NETFNLUN_IPMI_STORAGE, CMD_READ_FRU_DATA,
 						(uint8_t *)pFRUReadReqData, sizeof(FRUReadReq_T),
 						(uint8_t *)pFRUReadResData, &dwResLen,
 						timeout);
@@ -1015,7 +1015,7 @@ uint16_t IPMICMD_WriteFRUData(IPMI20_UDS_SESSION_T *pUDSSession,
 
 	dwResLen = sizeof(FRUWriteRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NETFNLUN_IPMI_APP, CMD_WRITE_FRU_DATA,
+						NETFNLUN_IPMI_STORAGE, CMD_WRITE_FRU_DATA,
 						(uint8_t *)pFRUWriteReqData, ReqDataLen,
 						(uint8_t *)pFRUWriteResData, &dwResLen,
 						timeout);
@@ -1155,7 +1155,7 @@ uint8_t IPMICMD_GetSELTime(IPMI20_UDS_SESSION_T *pUDSSession,
 
 	dwResLen = sizeof(GetSELTimeRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NETFNLUN_IPMI_APP, CMD_GET_SEL_TIME,
+						NETFNLUN_IPMI_STORAGE, CMD_GET_SEL_TIME,
 						(uint8_t*)DummyReqData, 0,
 						(uint8_t *)pGetSELTimeRes, &dwResLen,
 						timeout);
@@ -1176,7 +1176,7 @@ uint8_t IPMC_GetSELTime(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
 
 	Req[0] = 0x40;	//Track | channel 0
 	Req[1] = IpmbAddr;
-	Req[2] = NETFNLUN_IPMI_APP;
+	Req[2] = NETFNLUN_IPMI_STORAGE;
 	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
 	Req[4] = 0x20;
 	Req[5] = 0x10;
@@ -1208,7 +1208,7 @@ uint8_t IPMICMD_SetSELTime(IPMI20_UDS_SESSION_T *pUDSSession,
 
 	dwResLen = sizeof(uint8_t);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NETFNLUN_IPMI_APP, CMD_SET_SEL_TIME,
+						NETFNLUN_IPMI_STORAGE, CMD_SET_SEL_TIME,
 						(uint8_t *)pSetSELTimeReq, sizeof(SetSELTimeReq_T),
 						(uint8_t *)DummyResData, &dwResLen,
 						timeout);
@@ -1229,7 +1229,7 @@ uint8_t IPMC_SetSELTime(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
 
 	Req[0] = 0x40;	//Track | channel 0
 	Req[1] = IpmbAddr;
-	Req[2] = NETFNLUN_IPMI_APP;
+	Req[2] = NETFNLUN_IPMI_STORAGE;
 	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
 	Req[4] = 0x20;
 	Req[5] = 0x10;
@@ -1261,7 +1261,7 @@ uint8_t IPMICMD_GetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession,
 
 	dwResLen = sizeof(GetSELTimeUTCOffsetRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NETFNLUN_IPMI_APP, CMD_GET_SEL_TIME_UTC_OFFSET,
+						NETFNLUN_IPMI_STORAGE, CMD_GET_SEL_TIME_UTC_OFFSET,
 						(uint8_t*)DummyReqData, 0,
 						(uint8_t *)pGetSELTimeUTCOffsetRes, &dwResLen,
 						timeout);
@@ -1282,7 +1282,7 @@ uint8_t IPMC_GetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t Ipmb
 
 	Req[0] = 0x40;	//Track | channel 0
 	Req[1] = IpmbAddr;
-	Req[2] = NETFNLUN_IPMI_APP;
+	Req[2] = NETFNLUN_IPMI_STORAGE;
 	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
 	Req[4] = 0x20;
 	Req[5] = 0x10;
@@ -1314,7 +1314,7 @@ uint8_t IPMICMD_SetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession,
 
 	dwResLen = sizeof(SetSELTimeUTCOffsetRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NETFNLUN_IPMI_APP, CMD_SET_SEL_TIME_UTC_OFFSET,
+						NETFNLUN_IPMI_STORAGE, CMD_SET_SEL_TIME_UTC_OFFSET,
 						(uint8_t *)pSetSELTimeUTCOffsetReq, sizeof(SetSELTimeUTCOffsetReq_T),
 						(uint8_t *)&pSetSELTimeUTCOffsetRes, &dwResLen,
 						timeout);
@@ -1335,7 +1335,7 @@ uint8_t IPMC_SetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t Ipmb
 
 	Req[0] = 0x40;	//Track | channel 0
 	Req[1] = IpmbAddr;
-	Req[2] = NETFNLUN_IPMI_APP;
+	Req[2] = NETFNLUN_IPMI_STORAGE;
 	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
 	Req[4] = 0x20;
 	Req[5] = 0x10;

+ 82 - 5
app/goahead-3.6.5/src/libipmi/src/libipmi_sdr.c

@@ -672,7 +672,7 @@ uint16_t IPMC_GetSDR( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
     FullSensorRec_T *sdr_record = (FullSensorRec_T*) &data_buffer[sizeof(GetSDRRes_T)];
     GetSDRReq_T ReqGetSDR;
     GetSDRRes_T *pResGetSDR = (GetSDRRes_T *) &data_buffer[0];
-    uint32_t      dwRetLen = 255;   //sizeof(data_buffer);
+    uint32_t      dwRetLen;   //sizeof(data_buffer);
     int wRet = 0;
     
     wRet = IPMICMD_ReserveSDRRepository(pUDSSession, &ResReserveSDRRepository, timeout);
@@ -685,8 +685,6 @@ uint16_t IPMC_GetSDR( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
         ReqGetSDR.Offset = 0;
         ReqGetSDR.Size = 0xff;
         wRet = IPMICMD_GetSDR(pUDSSession, &ReqGetSDR, pResGetSDR, &dwRetLen, timeout);
-        //TODO: IPMICMD_GetSDR replaced by LIBIPMI_HL_GetSDR, by jimbo
-        //wRet = LIBIPMI_HL_GetSDR(pUDSSession, ReqGetSDR.ReservationID, ReqGetSDR.RecID, pResGetSDR, &dwRetLen, timeout );
         if (wRet != LIBIPMI_E_SUCCESS)
         {
             printf("Get SDR error!\n");
@@ -700,8 +698,7 @@ uint16_t IPMC_GetSDR( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
         }
     }
     
-    dwRetLen -= sizeof(GetSDRRes_T);
-    *sdr_buff_size = *sdr_buff_size >= dwRetLen ? dwRetLen : *sdr_buff_size;
+    *sdr_buff_size =  sizeof(FullSensorRec_T);
     memcpy(sdr_buffer, sdr_record, *sdr_buff_size);
 
     //printf("sdr_buff_size: %d\n", *sdr_buff_size);
@@ -710,3 +707,83 @@ uint16_t IPMC_GetSDR( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
     return wRet;
 }
 
+uint16_t IPMC_GetSpecificSDR( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+                                                uint8_t *sdr_buffer, 
+                                                uint32_t* sdr_buff_size,
+                                                int SensorNumber,
+                                                int timeout )
+{
+    FullSensorRec_T *sdr_record = NULL;
+    uint16_t    wRet = 0;
+    uint8_t     Req[50] = {0};
+    uint8_t     Res[100];
+    uint16_t    strLen, remainLen;
+    uint32_t    dwResLen;
+    uint16_t    ReserveID = 0;
+    uint16_t    NextRecID = 0;
+    
+
+    //Reserve SDR
+    Req[0] = 0x40;  //Track | channel 0
+    Req[1] = IpmbAddr;
+    Req[2] = NETFNLUN_IPMI_STORAGE;
+    Req[3] = 0x100 - (Req[1] + Req[2])&0xff;    //checksum1
+    Req[4] = 0x20;
+    Req[5] = 0x10;
+    Req[6] = CMD_RESERVE_SDR_REPOSITORY;  
+    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("Reserve SDR failed\n");
+        ReserveID = 0;
+    }
+
+
+    NextRecID = 0;
+    while (1)
+    {
+        Req[0] = 0x40;  //Track | channel 0
+        Req[1] = IpmbAddr;
+        Req[2] = NETFNLUN_IPMI_STORAGE;
+        Req[3] = 0x100 - (Req[1] + Req[2])&0xff;    //checksum1
+        Req[4] = 0x20;
+        Req[5] = 0x10;
+        Req[6] = CMD_GET_SDR;  
+        Req[7] = ReserveID&0xff;
+        Req[8] = (ReserveID>>8)&0xff;
+        Req[9] = NextRecID&0xff;
+        Req[10] = (NextRecID>>8)&0xff;
+        Req[11] = 0;                     //offset
+        Req[12] = 0xff;                 //size
+        Req[13] = 0x100 - (Req[4]+Req[5]+Req[6]+Req[7]+Req[8]+Req[9]+Req[10]+Req[11]+Req[12])&0xff;
+
+        wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 
+                                                DEFAULT_NET_FN_LUN, CMD_SEND_MSG,
+                                                Req, 14,
+                                                Res, &dwResLen,
+                                                timeout);
+        if ((wRet != LIBIPMI_E_SUCCESS) || (Res[6] != 0))
+        {
+            printf("Get SDR error!\n");
+            break;
+        }
+
+        NextRecID = (Res[8]<<8) | Res[7];
+        sdr_record = (FullSensorRec_T*)&Res[9];
+        if (sdr_record->SensorNum == SensorNumber)
+        {
+            break;  // found
+        }
+    }
+    
+    *sdr_buff_size = sizeof(FullSensorRec_T);
+    memcpy(sdr_buffer, sdr_record, *sdr_buff_size);
+    return 0;
+}

+ 47 - 0
app/goahead-3.6.5/src/libipmi/src/libipmi_sensor.c

@@ -178,6 +178,53 @@ uint16_t	IPMICMD_GetSDRInfo( IPMI20_UDS_SESSION_T *pUDSSession,
 	return wRet;
 }
 
+uint16_t	IPMC_SetSensorThreshold( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+										SetSensorThresholdReq_T *pReqSetSensorThreshold,
+										int timeout)
+{
+	uint16_t    wRet = 0;
+    uint8_t     Req[50] = {0};
+    uint8_t     Res[50];
+    uint16_t    strLen, remainLen;
+    uint32_t    dwResLen;
+    uint16_t    ReserveID = 0;
+    uint16_t    NextRecID = 0;
+    
+
+    //Reserve SDR
+    Req[0] = 0x40;  //Track | channel 0
+    Req[1] = IpmbAddr;
+    Req[2] = NETFNLUN_IPMI_SENSOR;
+    Req[3] = 0x100 - (Req[1] + Req[2])&0xff;    //checksum1
+    Req[4] = 0x20;
+    Req[5] = 0x10;
+    Req[6] = CMD_SET_SENSOR_THRESHOLDS;  
+    Req[7] = pReqSetSensorThreshold->SensorNum;
+    Req[8] = pReqSetSensorThreshold->SetFlags;
+    Req[9] = pReqSetSensorThreshold->LowerNonCritical;
+    Req[10] = pReqSetSensorThreshold->LowerCritical;
+    Req[11] = pReqSetSensorThreshold->LowerNonRecoverable;
+    Req[12] = pReqSetSensorThreshold->UpperNonCritical;
+    Req[13] = pReqSetSensorThreshold->UpperCritical;
+    Req[14] = pReqSetSensorThreshold->UpperNonRecoverable;
+    Req[15] = 0x100 - (Req[4]+Req[5]+Req[6]+Req[7]+Req[8]+Req[9]+Req[10]+Req[11]+Req[12]+Req[13]+Req[14])&0xff;
+
+    //dwResLen = sizeof(GetDevIDRes_T);
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 
+                                            DEFAULT_NET_FN_LUN, CMD_SEND_MSG,
+                                            Req, 16,
+                                            Res, &dwResLen,
+                                            timeout);
+    if((wRet != 0) || (Res[6] != 0))
+    {
+    	printf("IPMC_SetSensorThreshold failed\n");
+    	return wRet;
+    }
+
+	return 0;
+}
+
+
 /* 35.9 Get Sensor Thresholds Command */
   uint16_t	IPMICMD_GetSensorThreshold( IPMI20_UDS_SESSION_T *pUDSSession,
 										GetSensorThresholdReq_T *pReqGetSensorThreshold,

+ 61 - 295
app/goahead-3.6.5/src/libipmi/src/libipmi_storlead_OEM.c

@@ -23,204 +23,6 @@
 #include "com_IPMI_App.h"
 
 
-OemWebFlags_T g_OemWebFlags;
-uint8_t ChassisPrimaryIPMBAddr[BLADE_NUMBERS] = {0X82, 0x84, 0x86, 0x88, 0x8A, 0x8C, 0x8E, 0x90, 0x92, 0x94};
-uint8_t ChassisSecondaryIPMBAddr[BLADE_NUMBERS] = {0X82, 0x84, 0x86, 0x88, 0x8A, 0x8C, 0x8E, 0x90, 0x92, 0x94};
-/*
-*@fn IPMICMD_AMIGetSensorInfo
-*@brief
-*@param pUDSSession - IPMI Session Handle
-*@param pAMIGetSensorInfoReq - Pointer to the request of AMI Get SensorInfo command
-*@param pAMIGetSensorInfoRes - Pointer to the response of AMI Get SensorInfo command
-*@param timeout - Timeout Value
-**/
-// uint16_t IPMICMD_GetIPMCSensorInfo(IPMI20_UDS_SESSION_T *pUDSSession, AMIGetSensorInfoRes_T *pGetIPMCSensorInfoRes,int timeout)
-// {
-//  	uint16_t wRet = 0;
-	
-// 	uint16_t reservation_id;
-// 	uint16_t record_id = 0;
-// 	uint32_t dwRecordLen;
-// 	SenInfo_T SensorInfo;
-	
-// 	uint8_t SDRData[100] = {0};
-// 	uint8_t NextRecIDLS = 0;
-// 	uint8_t NextRecIDMS = 0;
-// 	uint8_t cnt = 0;
-// 	uint8_t timeoutTick = 0;
-// 	wRet = IPMICMD_ReserveSDRRepository(pUDSSession, (ReserveSDRRepositoryRes_T*)SDRData, timeout);
-// 	if(wRet != 0)
-// 	{
-// 		printf("Error Reserve SDR Repository\n");
-// 		return wRet;
-// 	}
-	
-// 	reservation_id = SDRData[2]<<8 | SDRData[1];
-	
-// 	do
-// 	{
-// 		//Get SDR
-// 		if(0 != LIBIPMI_HL_GetSDR(pUDSSession, reservation_id, record_id, (GetSDRRes_T*)SDRData, &dwRecordLen, timeout ))
-// 		{
-// 			printf("---> Get SDR error! record_id = %#x\n", record_id);
-// 			return -1;
-// 		}
-			
-// 		NextRecIDLS = SDRData[1];
-// 		NextRecIDMS = SDRData[2];
-// 		memcpy(&SensorInfo.hdr, &SDRData[3],5/*Sizeof(SDRRecHdr_T)*/);
-// 		if(SensorInfo.hdr.Type == 0x01)	//full sensor sdr
-// 		{	
-// 			SensorInfo.Accuracy_MSB_Exp = SDRData[3+29-1];
-// 			//SensorInfo.AssertionEventByte1 = SDRData[3+15-1];
-// 			//SensorInfo.AssertionEventByte2 = SDRData[3+16-1];
-// 			SensorInfo.B_LSB	= SDRData[3+27-1];
-// 			SensorInfo.B_MSB_Accuracy	=	SDRData[3+28-1];
-// 			SensorInfo.DeassertionEventByte1	=	SDRData[3+17-1];
-// 			SensorInfo.DeassertionEventByte2	=	SDRData[3+18-1];
-// 			SensorInfo.EventTypeCode	=	SDRData[3+14-1];
-// 			SensorInfo.Linearization	=	SDRData[3+24-1];
-// 			SensorInfo.LowerCritical	=	SDRData[3+41-1];
-// 			SensorInfo.LowerNonCritical	=	SDRData[3+42-1];
-// 			SensorInfo.LowerNonRecoverable	=	SDRData[3+40-1];
-// 			SensorInfo.M_LSB	=	SDRData[3+25-1];
-// 			SensorInfo.M_MSB_Tolerance	=	SDRData[3+26-1];
-// 			SensorInfo.MaxReading	=	SDRData[3+35-1];
-// 			SensorInfo.MinReading	=	SDRData[3+36-1];
-// 			SensorInfo.OwnerID	=	SDRData[3+6-1];
-// 			SensorInfo.OwnerLUN	=	SDRData[3+7-1];
-// 			SensorInfo.RExp_BExp	=	SDRData[3+30-1];			
-// 			SensorInfo.SensorNumber	=	SDRData[3+8-1];
-// 			SensorInfo.SensorTypeCode		=	SDRData[3+13-1];
-// 			SensorInfo.Settable_Readable_ThreshMask	=	SDRData[3+20-1]<<8 | SDRData[3+19-1];
-// 			SensorInfo.Units1	=	SDRData[3+21-1];
-// 			SensorInfo.Units2	=	SDRData[3+22-1];
-// 			SensorInfo.Units3	=	SDRData[3+23-1];
-// 			SensorInfo.UpperCritical	=	SDRData[3+38-1];
-// 			SensorInfo.UpperNonCritical	=	SDRData[3+39-1];
-// 			SensorInfo.UpperNonRecoverable = SDRData[3+37-1];
-			
-// 			memset(SensorInfo.SensorName, 0, 16);
-// 			memcpy(SensorInfo.SensorName, &SDRData[3+49-1], SDRData[3+48-1]&0x3f);
-			
-// 			//get sensor reading
-// 			if(0 != IPMICMD_GetSensorReading(pUDSSession, (GetSensorReadingReq_T *)&SensorInfo.SensorNumber, 
-// 				(GetSensorReadingRes_T *)SDRData, timeout))
-// 			{
-// 				printf("---> Get sensorReading error! sensorNum = %#x\n", SensorInfo.SensorNumber);
-// 				return -1;
-// 			}
-// 			SensorInfo.SensorReading = SDRData[1];
-// 			SensorInfo.OptionalStatus	=	SDRData[4];
-// 			SensorInfo.Flags	=	SDRData[2];
-			
-// 			SensorInfo.ComparisonStatus = SDRData[3];
-// 			if(SensorInfo.EventTypeCode == 0x01)	//threshold
-// 			{
-// 				//TODO: jimbo
-// 				SensorInfo.AssertionEventByte1 = 0x0;
-// 				SensorInfo.AssertionEventByte2 = 0x0;
-// 				if((SensorInfo.Units1 & 0xc0) == 0x00)	//unsigned
-// 				{
-// 					if((uint8_t)SensorInfo.SensorReading > (uint8_t)SensorInfo.UpperCritical)
-// 						SensorInfo.AssertionEventByte2 |= 0x02;
-// 					if((uint8_t)SensorInfo.SensorReading > (uint8_t)SensorInfo.UpperNonCritical)
-// 						SensorInfo.AssertionEventByte1 |= 0x80;
-// 					if((uint8_t)SensorInfo.SensorReading > (uint8_t)SensorInfo.UpperNonRecoverable)
-// 						SensorInfo.AssertionEventByte2 |= 0x08;
-// 					if((uint8_t)SensorInfo.SensorReading < (uint8_t)SensorInfo.LowerCritical)
-// 						SensorInfo.AssertionEventByte1 |= 0x04;
-// 					if((uint8_t)SensorInfo.SensorReading < (uint8_t)SensorInfo.LowerNonCritical)
-// 						SensorInfo.AssertionEventByte1 |= 0x01;
-// 					if((uint8_t)SensorInfo.SensorReading < (uint8_t)SensorInfo.LowerNonRecoverable)
-// 						SensorInfo.AssertionEventByte1 |= 0x10;					
-// 				}
-// 				else if((SensorInfo.Units1 & 0xc0) == 0x80)	//2's complement
-// 				{
-// 					if((char)SensorInfo.SensorReading > (char)SensorInfo.UpperCritical)
-// 						SensorInfo.AssertionEventByte2 |= 0x02;
-// 					if((char)SensorInfo.SensorReading > (char)SensorInfo.UpperNonCritical)
-// 						SensorInfo.AssertionEventByte1 |= 0x80;
-// 					if((char)SensorInfo.SensorReading > (char)SensorInfo.UpperNonRecoverable)
-// 						SensorInfo.AssertionEventByte2 |= 0x08;
-// 					if((char)SensorInfo.SensorReading < (char)SensorInfo.LowerCritical)
-// 						SensorInfo.AssertionEventByte1 |= 0x04;
-// 					if((char)SensorInfo.SensorReading < (char)SensorInfo.LowerNonCritical)
-// 						SensorInfo.AssertionEventByte1 |= 0x01;
-// 					if((char)SensorInfo.SensorReading < (char)SensorInfo.LowerNonRecoverable)
-// 						SensorInfo.AssertionEventByte1 |= 0x10;
-// 				}
-				
-// 			}
-			
-			
-// 			memcpy(((uint8_t*)pGetIPMCSensorInfoRes)+3+sizeof(SenInfo_T)*cnt, &SensorInfo, sizeof(SenInfo_T));
-// 			cnt++;
-			
-// //			printf("cnt: %d, sensorNum: %#x, sensorReading: %#x, OptionStatus = %#x, ComparisonStatus = %#x\n", 
-// //					cnt, SensorInfo.SensorNumber, SensorInfo.SensorReading, SensorInfo.OptionalStatus, SensorInfo.ComparisonStatus);
-// 		}
-		
-		
-// 		record_id = NextRecIDMS<<8 | NextRecIDLS;
-// 		timeoutTick++;
-// 		if(timeoutTick > 64)	
-// 		{
-// 			wRet = -1;
-// 			break;
-// 		}
-// 	}while(record_id != 0xffff);	  
-	
-// 	if(wRet == 0)
-// 		pGetIPMCSensorInfoRes->CompletionCode = 0;
-// 	else
-// 		pGetIPMCSensorInfoRes->CompletionCode = 255;
-	
-// 	pGetIPMCSensorInfoRes->Noofentries = cnt;
-	
-// //	printf("return pGetIPMCSensorInfoRes: ");
-// //	for(i=0;i<3+sizeof(SenInfo_T)*cnt;i++)
-// //		printf("%#2x ",((uint8_t*)pGetIPMCSensorInfoRes)[i]);
-// //	printf("\n");
-	
-// 	return (wRet);
-// }
-
-
-// uint16_t LIBIPMI_HL_GetIPMCSensorInfo(IPMI20_UDS_SESSION_T *pUDSSession,SenInfo_T *pSensorInfo,uint32_t *nNumSensor,int timeout)
-// {
-// 	uint16_t wRet = 0;
-// 	AMIGetSensorInfoRes_T *pGetIPMCSensorInfoRes;
-// 	uint8_t *SensorEntries;
-// 	int i;
-	
-// 	SensorEntries = (uint8_t *)malloc(MAX_SENSOR_INFO_SIZE);
-// 	if(SensorEntries == NULL)
-// 	{
-// 		printf("Memory allocation error in LIBIPMI_HL_AMIGetSELEntires \n");
-// 		wRet = 0xFF;
-// 		return wRet;
-// 	}
-	
-// 	memset(SensorEntries,0,MAX_SENSOR_INFO_SIZE);
-// 	pGetIPMCSensorInfoRes = (AMIGetSensorInfoRes_T *)SensorEntries;
-// 	wRet = IPMICMD_GetIPMCSensorInfo(pUDSSession,(AMIGetSensorInfoRes_T *)SensorEntries,timeout);
-// 	if(wRet == LIBIPMI_E_SUCCESS)
-// 	{
-// 		*nNumSensor = pGetIPMCSensorInfoRes->Noofentries;
-// 		for(i = 0; i < pGetIPMCSensorInfoRes->Noofentries; i++)
-// 		{
-// 			memcpy((uint8_t *)&pSensorInfo[i],&SensorEntries[sizeof(AMIGetSensorInfoRes_T) + (i * sizeof(SenInfo_T))],sizeof(SenInfo_T) );
-// 		}
-// 	}
-// 	else
-// 	{
-// 		printf("error getting sensor info %d\n",wRet);
-// 	}
-// 	free(SensorEntries);
-// 	return (wRet);
-// }
-
 uint16_t LIBIPMI_HL_SetFanInfo( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t fanIndex, uint8_t fanMode, uint8_t fanLevel, int timeout)
 {
 	uint16_t wRet = 0;
@@ -397,102 +199,6 @@ uint16_t IPMC_GetSysInfo( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, S
 	return 0;
 }
 
-
-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);
-	}
-	
-	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;
-
-	wfree(Res);
-
-	return 0;
-}
-
 // /************************************************* new add **********************************************************************/
 int LIBIPMI_HL_GetChassisInfo(IPMI20_UDS_SESSION_T *pUDSSession, OemChassisInfo_T* pChassisInfo, int timeout)
 {
@@ -1024,4 +730,64 @@ int IPMC_GetSensorName(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint
 
 	memcpy(sensor_name, &Res[7], MAX_ID_STR_LEN);
 	return 0;
-}
+}
+
+int IPMI_GetSensorHistory(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t sensor_number, uint8_t *history_buf, int timeout)
+{
+	uint8_t 	Req[10] = {0};
+	uint32_t	dwResLen;
+	uint16_t 	wRet;
+	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 *)history_buf, &dwResLen,
+                                timeout);
+    if((wRet != 0) || (history_buf[0] != 0))
+    {
+        printf("IPMI_GetSensorHistory error!\n");
+        return -1;
+    }
+
+    return 0;
+}
+
+/*
+	本地模块可以一次性全部获取,但是从模块的IPMB总线最大也就只能传输256个字节,所以要分开获取。
+*/
+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)
+{
+	uint8_t 	Req[20] = {0};
+	uint32_t	dwResLen;
+	uint16_t 	wRet;
+    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_SENSOR_HISTORY;  
+    Req[7] = sensor_number;
+    Req[8] = offset&0xff; //offset lsb
+    Req[9] = (offset>>8)&0xff; //offset msb
+    Req[10] = length&0xff;      //readlen lsb
+    Req[11] = (length>>8)&0xff;    //readlen msb
+    Req[12] = 0x100 - (Req[4]+Req[5]+Req[6]+Req[7]+Req[8]+Req[9]+Req[10]+Req[11])&0xff;
+
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 
+                                            DEFAULT_NET_FN_LUN, CMD_SEND_MSG,
+                                            Req, 13,
+                                            history_buf, &dwResLen,
+                                            timeout);
+    if((wRet != 0) || (history_buf[6] != 0))
+    {
+        printf("IPMC_GetSensorHistory error!\n");
+        return wRet;
+    }
+
+    return 0;
+}

+ 7 - 0
app/goahead-3.6.5/src/web_interface/src/dashboard.c

@@ -493,6 +493,13 @@ void getAllBladeInfo(Webs *wp){
         cJSON_AddNumberToObject(pJsonsub, "power", pBladeStatus[i].pwrStatus); 
         cJSON_AddStringToObject(pJsonsub, "name", pBladeStatus[i].bladeName); 
         cJSON_AddNumberToObject(pJsonsub, "isChMC", pBladeStatus[i].isChMC); 
+
+        //将主模块的IPMB地址改成0x20
+        if(pBladeStatus[i].isChMC)
+        {
+            gIPMBAddr[i] = 0x20;
+            printf("Modify %d blade ipmb address to 0x20\n", i);
+        }
     }
   
     pStr = cJSON_PrintUnformatted(root);

+ 110 - 32
app/goahead-3.6.5/src/web_interface/src/server_health.c

@@ -31,6 +31,7 @@ void setThreshold(Webs *wp){
     float LC = atof(strLC);
     float LNR = atof(strLNR);
     int   SensorNumber = atoi(strSensorNumber);
+    uint8_t target_addr;
 
     printf(" %s, %s %s %s, %s %s %s = %d, %f %f %f %f %f %f \n", strSensorNumber, strUNC, strUC, strUNR, strLNC, strLC, 
     	strLNR,  SensorNumber, UNC, UC, UNR, LNC, LC, LNR );
@@ -63,7 +64,15 @@ void setThreshold(Webs *wp){
     //Create session
     LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
 
-    wRet = LIBIPMI_HL_GetSpecificSDR(&UDSSession, data_buffer, &data_buff_size, SensorNumber, DEFAULT_TIMEOUT);
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    { 
+        wRet = LIBIPMI_HL_GetSpecificSDR(&UDSSession, data_buffer, &data_buff_size, SensorNumber, DEFAULT_TIMEOUT);
+    }
+    else
+    {
+        wRet = IPMC_GetSpecificSDR(&UDSSession, target_addr, data_buffer, &data_buff_size, SensorNumber, DEFAULT_TIMEOUT);   
+    }
     
     pReqSetSensorThreshold->SensorNum = SensorNumber;
     
@@ -81,29 +90,34 @@ void setThreshold(Webs *wp){
     // 	pReqSetSensorThreshold->UpperNonCritical, pReqSetSensorThreshold->UpperCritical, 
     // 	pReqSetSensorThreshold->UpperNonRecoverable, pReqSetSensorThreshold->LowerNonCritical, 
     // 	pReqSetSensorThreshold->LowerCritical, pReqSetSensorThreshold->LowerNonRecoverable);
-
-    wRet = IPMICMD_SetSensorThreshold( &UDSSession, pReqSetSensorThreshold, pResSetSensorThreshold, DEFAULT_TIMEOUT);
+    if(target_addr == 0x20)
+    {
+        wRet = IPMICMD_SetSensorThreshold( &UDSSession, pReqSetSensorThreshold, pResSetSensorThreshold, DEFAULT_TIMEOUT);
+    }
+    else
+    {
+        wRet = IPMC_SetSensorThreshold( &UDSSession, target_addr, pReqSetSensorThreshold, DEFAULT_TIMEOUT);   
+    }
 
     //Close session
     LIBIPMI_CloseSession(&UDSSession );
 
-	char *pStr;
+	
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON_AddItemToObject(root, "data", data);//根节点下添加
     cJSON_AddStringToObject(root, "msg", "");
     cJSON_AddNumberToObject(root, "code", 200);
     
-   
+    char *pStr;
     pStr = cJSON_PrintUnformatted(root);
-
-//    printf("---> cJSON Str:\n%s\n", pStr);
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp); 
     websWrite(wp,"%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
+    printf("---> cJSON Str:\n%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
@@ -124,15 +138,18 @@ void setThreshold(Webs *wp){
 void webGetSensorHistory(Webs *wp)
 {
     IPMI20_UDS_SESSION_T    UDSSession;
-    int i = 0,j=0;
-    int wRet = 0;
+    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        tmpBuf[10];
+    char        *historyBuf = walloc(5000);
+    uint8_t     target_addr;
+    FullSensorRec_T *sdr_record = (FullSensorRec_T*) walloc(100);
+    uint32_t     sdr_buff_size = 0;
+    float       tmpValue;
+    uint8_t     Req[20];
+    uint8_t     Res[256];
+    uint32_t    dwResLen;
 
     char *strSensorNumber = websGetVar(wp, "SensorNumber", NULL);
     int   SensorNumber = atoi(strSensorNumber);
@@ -140,20 +157,89 @@ void webGetSensorHistory(Webs *wp)
     //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 ;
+    //wp->index = 1;
+    target_addr = gIPMBAddr[wp->index];
+    //get factors
+    if(target_addr == 0x20)
+    { 
+        wRet = LIBIPMI_HL_GetSpecificSDR( &UDSSession, (uint8_t*)sdr_record, &sdr_buff_size, SensorNumber, DEFAULT_TIMEOUT );
+    }
+    else
+    {
+        wRet = IPMC_GetSpecificSDR(&UDSSession, target_addr, (uint8_t*)sdr_record, &sdr_buff_size, SensorNumber, DEFAULT_TIMEOUT);   
     }
 
+    if(wRet != 0)
+    {
+        websError(wp, 404, "GetSpecificSDR error!");
+        wfree(pSensorHistory);
+        wfree(historyBuf);
+        wfree(sdr_record);
+        return;
+    }
+
+    pSensorHistory->sensor_num = SensorNumber;
+    strcpy(pSensorHistory->sensor_name, sdr_record->IDStr);
+    printf("sensor_num: %d, sensor_name: %s\n", pSensorHistory->sensor_num, pSensorHistory->sensor_name);
+        
+    if(target_addr == 0x20)
+    {
+        wRet = IPMI_GetSensorHistory(&UDSSession, SensorNumber, (uint8_t*)historyBuf, DEFAULT_TIMEOUT);
+        if(wRet != 0)
+        {
+            websError(wp, 404, "IPMI_GetSensorHistory error!");
+            wfree(pSensorHistory);
+            wfree(historyBuf);
+            wfree(sdr_record);
+            return;
+        }
+        for(i=0;i<MAX_HISTORY_LEN;i++)
+        {
+            ipmi_convert_reading( (uint8_t*)sdr_record, (uint8_t)historyBuf[3+i], &tmpValue );   //remove ccode, returnlen_lsb/msb
+            pSensorHistory->sensor_history[i] = tmpValue;
+        }
+    }
+    else
+    {
+        //获取前240字节
+        wRet = IPMC_GetSensorHistory(&UDSSession, target_addr, SensorNumber, 0, 240, (uint8_t*)historyBuf, DEFAULT_TIMEOUT);
+        if(wRet != 0)
+        {
+            websError(wp, 404, "IPMC_GetSensorHistory error!");
+            wfree(pSensorHistory);
+            wfree(historyBuf);
+            wfree(sdr_record);
+            return;
+        }
+        for(i=0;i<240;i++)
+        {
+            ipmi_convert_reading( (uint8_t*)sdr_record, historyBuf[9+i], &tmpValue );   //remove ipmb header and ccode,returnlen_lsb/msb
+            pSensorHistory->sensor_history[i] = tmpValue;
+        }
+        //获取后240字节
+        wRet = IPMC_GetSensorHistory(&UDSSession, target_addr, SensorNumber, 240, 240, (uint8_t*)historyBuf, DEFAULT_TIMEOUT);
+        if(wRet != 0)
+        {
+            websError(wp, 404, "IPMC_GetSensorHistory error!");
+            wfree(pSensorHistory);
+            wfree(historyBuf);
+            wfree(sdr_record);
+            return;
+        }
+        for(i=0;i<240;i++)
+        {
+            ipmi_convert_reading( (uint8_t*)sdr_record, historyBuf[9+i], &tmpValue );   //remove ipmb header and ccode,returnlen_lsb/msb
+            pSensorHistory->sensor_history[240+i] = tmpValue;
+        }
+    }
+    
     //Close session
     LIBIPMI_CloseSession(&UDSSession );
     
+    char *strBuf = historyBuf;
     for(i=0;i<HISTORY_DATA_SIZE;i++)
     {
-        sprintf(tmpBuf, "%0.3f", pSensorHistory->sensor_history[i]);
+        sprintf(tmpBuf, "%0.2f", pSensorHistory->sensor_history[i]);
         j = 0;
         while(tmpBuf[j] != '\0')
         {
@@ -169,38 +255,30 @@ void webGetSensorHistory(Webs *wp)
     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);
     
-   
+    char *pStr;
     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);
+    printf("---> cJSON Str:\n%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
     if(root)
         cJSON_Delete(root);
 
-
     if(historyBuf)
         wfree(historyBuf);
     if(pSensorHistory)
         wfree(pSensorHistory);
-
-
 }