Ver código fonte

getAllSensorInfo ok

zhangbo 5 anos atrás
pai
commit
a5fd13ca91

BIN
app/bmc/bmc_app


+ 3 - 3
app/bmc/lan/LANIfc.c

@@ -501,13 +501,13 @@ int SendLANPkt (MsgPkt_T *pRes )
 	memcpy (&Dest.sin_addr.s_addr, pRes->IPAddr, sizeof (struct in_addr));
 	
 	/* Send the LAN response packet */
-	// int i;
-	// printf("\nLan send socket: %d, byte: %d: ", pRes->Socket, pRes->Size);
+	//int i;
+	//printf("\nLan send socket: %d, byte: %d: ", pRes->Socket, pRes->Size);
 	// for (i = 0; i < pRes->Size; ++i)
 	// {
 	// 	printf("%#x ", pRes->Data[i]);
 	// }
-	// printf("\n");
+	//printf("\n");
 
 	//Check the socket before send a message on a socket
 	//if (fstat(pRes->Socket, &Stat) != -1) 

+ 18 - 18
app/bmc/msghndlr/Storage/SDR.h

@@ -54,19 +54,19 @@ extern  SDRRepository_T*      g_SDRRAM;
  * These commands provide read/write access to BMC's SDR repository.
  * @{
 **/
-extern int GetSDRRepositoryInfo      ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
-extern int GetSDRRepositoryAllocInfo ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
-extern int ReserveSDRRepository      ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
-extern int GetSDR                    ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
-extern int AddSDR                    ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
-extern int PartialAddSDR             ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
-extern int DeleteSDR                 ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
-extern int ClearSDRRepository        ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
-extern int GetSDRRepositoryTime      ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
-extern int SetSDRRepositoryTime      ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
-extern int EnterSDRUpdateMode        ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
-extern int ExitSDRUpdateMode         ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
-extern int RunInitializationAgent    ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+ int GetSDRRepositoryInfo      ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+ int GetSDRRepositoryAllocInfo ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+ int ReserveSDRRepository      ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+ int GetSDR                    ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+ int AddSDR                    ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+ int PartialAddSDR             ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+ int DeleteSDR                 ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+ int ClearSDRRepository        ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+ int GetSDRRepositoryTime      ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+ int SetSDRRepositoryTime      ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+ int EnterSDRUpdateMode        ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+ int ExitSDRUpdateMode         ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+ int RunInitializationAgent    ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
 /** @} */
 
 /**
@@ -74,14 +74,14 @@ extern int RunInitializationAgent    ( uint8_t* pReq, uint8_t ReqLen,  uint8_t*
  * @param RecID - Current SDR record ID.
  * @return the next SDR record ID.
 **/
-extern uint16_t   SDR_GetNextSDRId     (uint16_t RecID);
+ uint16_t   SDR_GetNextSDRId     (uint16_t RecID);
 
 /**
  * @brief Reads SDR Repository contents.
  * @param pSDRRec - Current SDR Record header.
  * @return the next SDR Record header.
 **/
-extern  SDRRecHdr_T*   ReadSDRRepository ( SDRRecHdr_T* pSDRRec);
+  SDRRecHdr_T*   ReadSDRRepository ( SDRRecHdr_T* pSDRRec);
 
 /**
  * @brief Write into SDR Repository.
@@ -90,20 +90,20 @@ extern  SDRRecHdr_T*   ReadSDRRepository ( SDRRecHdr_T* pSDRRec);
  * @param Size    - Size of write.
  * @return the SDR Record header.
 **/
-extern void WriteSDRRepository ( SDRRecHdr_T* pSDRRec, uint8_t Offset, uint8_t Size,uint8_t SdrSize);
+ void WriteSDRRepository ( SDRRecHdr_T* pSDRRec, uint8_t Offset, uint8_t Size,uint8_t SdrSize);
 
 /**
  * @brief Get the SDR Record.
  * @param RecID - SDR Record ID.
  * @return the SDR Record.
 **/
-extern  SDRRecHdr_T* GetSDRRec  (uint16_t RecID);
+  SDRRecHdr_T* GetSDRRec  (uint16_t RecID);
 
 /**
  * @brief Initialize SDR Repository.
  * @return 0 if success, -1 if error
 **/
-extern  int  InitSDR (void);
+  int  InitSDR (void);
 
 
 #endif /* SDR_H */

+ 93 - 84
app/bmc/msghndlr/Storlead/Storlead.c

@@ -6,6 +6,7 @@
 #include "SensorMonitor.h"
 #include "Sensor.h"
 #include "com_IPMI_SDRRecord.h"
+#include "SDR.h"
 
 int  Storlead_GetSysInfo(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
 {
@@ -77,9 +78,9 @@ int  Storlead_GetSensorInfo(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
 {
 	printf("Storlead_GetSensorInfo\n" );
 
-	AMIGetSensorInfoRes_T *pAMIGetSensorInfoRes = (AMIGetSensorInfoRes_T *)pRes;
+	StorleadGetSensorInfoRes_T *pGetSensorInfoRes = (StorleadGetSensorInfoRes_T *)pRes;
     uint8_t*   		pValidSensor = NULL;
-    uint16_t       	SensorIndex = 0;
+    uint16_t       	SensorIndex = pReq[0];
     SensorInfo_T    pSensor ;
     SenInfo_T       SensorInfo;
     uint8_t 		SensorIsSigned = FALSE;
@@ -89,175 +90,183 @@ int  Storlead_GetSensorInfo(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
     FullSensorRec_T*      FullSDR;
     CompactSensorRec_T*   CompSDR;
     int i = 0;
+    int             totalsize;
 
     /* Get the Sensor Shared Memory */
     pSMSharedMem = (SensorSharedMem_T*)&g_BMCInfo.SensorSharedMem;
 
     if(g_BMCInfo.SenConfig.ValidSensorCnt == 0)
     {
-        pAMIGetSensorInfoRes->CompletionCode = OEMCC_SENSOR_INFO_EMPTY;
+        pGetSensorInfoRes->CompletionCode = OEMCC_SENSOR_INFO_EMPTY;
         printf("ValidSensorCnt is 0\n");
-        return sizeof(*pRes);
+        return 1;
     }
 
-    pValidSensor = (uint8_t*)(pAMIGetSensorInfoRes+1);
-    for(i = 0; i < g_BMCInfo.SenConfig.ValidSensorCnt; i++)
+    if(SensorIndex >= g_BMCInfo.SenConfig.ValidSensorCnt)
     {
-        SensorIndex = g_BMCInfo.SenConfig.ValidSensorList[i];
+        pGetSensorInfoRes->CompletionCode = CC_PARAM_OUT_OF_RANGE;
+        printf("Invalid SenosrIndex %d\n", SensorIndex);
+        return 1;
+    }
+
+    //pValidSensor = (uint8_t*)(pAMIGetSensorInfoRes+1);
+    // for(i = 0; i < g_BMCInfo.SenConfig.ValidSensorCnt; i++)
+    // {
+        //SensorIndex = g_BMCInfo.SenConfig.ValidSensorList[i];
         pSensor = pSMSharedMem->SensorInfo[SensorIndex];
 
         /*Copy the SDR Header*/
-        memcpy(&SensorInfo.hdr,pSensor.SDRRec,sizeof(SDRRecHdr_T));
+        memcpy(&pGetSensorInfoRes->SensorInfo.hdr,pSensor.SDRRec,sizeof(SDRRecHdr_T));
 
-        SensorInfo.SensorNumber = pSensor.SensorNumber;
-        SensorInfo.SensorTypeCode = pSensor.SensorTypeCode;
-        SensorInfo.EventTypeCode = pSensor.EventTypeCode;
+        pGetSensorInfoRes->SensorInfo.SensorNumber = pSensor.SensorNumber;
+        pGetSensorInfoRes->SensorInfo.SensorTypeCode = pSensor.SensorTypeCode;
+        pGetSensorInfoRes->SensorInfo.EventTypeCode = pSensor.EventTypeCode;
 
-        SensorInfo.Units1 = pSensor.Units1;
-        SensorInfo.Units2 = pSensor.Units2;
-        SensorInfo.Units3 = pSensor.Units3;
+        pGetSensorInfoRes->SensorInfo.Units1 = pSensor.Units1;
+        pGetSensorInfoRes->SensorInfo.Units2 = pSensor.Units2;
+        pGetSensorInfoRes->SensorInfo.Units3 = pSensor.Units3;
 
-        SensorInfo.M_LSB = pSensor.M_LSB;
-        SensorInfo.M_MSB_Tolerance = pSensor.M_MSB_Tolerance;
-        SensorInfo.B_LSB = pSensor.B_LSB;
-        SensorInfo.B_MSB_Accuracy = pSensor.B_MSB_Accuracy;
-        SensorInfo.Accuracy_MSB_Exp = pSensor.Accuracy_MSB_Exp;
-        SensorInfo.RExp_BExp = pSensor.RExp_BExp;
+        pGetSensorInfoRes->SensorInfo.M_LSB = pSensor.M_LSB;
+        pGetSensorInfoRes->SensorInfo.M_MSB_Tolerance = pSensor.M_MSB_Tolerance;
+        pGetSensorInfoRes->SensorInfo.B_LSB = pSensor.B_LSB;
+        pGetSensorInfoRes->SensorInfo.B_MSB_Accuracy = pSensor.B_MSB_Accuracy;
+        pGetSensorInfoRes->SensorInfo.Accuracy_MSB_Exp = pSensor.Accuracy_MSB_Exp;
+        pGetSensorInfoRes->SensorInfo.RExp_BExp = pSensor.RExp_BExp;
 
-        SensorInfo.LowerNonCritical = pSensor.LowerNonCritical;
-        SensorInfo.LowerCritical = pSensor.LowerCritical;
-        SensorInfo.LowerNonRecoverable = pSensor.LowerNonRecoverable;
-        SensorInfo.UpperNonCritical = pSensor.UpperNonCritical;
-        SensorInfo.UpperCritical = pSensor.UpperCritical;
-        SensorInfo.UpperNonRecoverable= pSensor.UpperNonRecoverable;
-        SensorInfo.Settable_Readable_ThreshMask= pSensor.SettableThreshMask;
+        pGetSensorInfoRes->SensorInfo.LowerNonCritical = pSensor.LowerNonCritical;
+        pGetSensorInfoRes->SensorInfo.LowerCritical = pSensor.LowerCritical;
+        pGetSensorInfoRes->SensorInfo.LowerNonRecoverable = pSensor.LowerNonRecoverable;
+        pGetSensorInfoRes->SensorInfo.UpperNonCritical = pSensor.UpperNonCritical;
+        pGetSensorInfoRes->SensorInfo.UpperCritical = pSensor.UpperCritical;
+        pGetSensorInfoRes->SensorInfo.UpperNonRecoverable= pSensor.UpperNonRecoverable;
+        pGetSensorInfoRes->SensorInfo.Settable_Readable_ThreshMask= pSensor.SettableThreshMask;
 
-        SensorInfo.Flags = pSensor.EventFlags & 0xe0;
+        pGetSensorInfoRes->SensorInfo.Flags = pSensor.EventFlags & 0xe0;
         if((pSensor.EventFlags & BIT5) != 0)
         {
-            SensorInfo.SensorReading = 0;
+            pGetSensorInfoRes->SensorInfo.SensorReading = 0;
         }
 
         SensorReading = pSensor.SensorReading;
-        SensorInfo.SensorReading = 0;
+        pGetSensorInfoRes->SensorInfo.SensorReading = 0;
         SensorIsSigned = ( 0 != (pSensor.InternalFlags & BIT1));
 
         if (THRESHOLD_SENSOR_CLASS  == pSensor.EventTypeCode)
         {
-            SensorInfo.SensorReading = (SensorReading & 0x00FF);
-            SensorInfo.ComparisonStatus = 0;
+            pGetSensorInfoRes->SensorInfo.SensorReading = (SensorReading & 0x00FF);
+            pGetSensorInfoRes->SensorInfo.ComparisonStatus = 0;
             if((pSensor.DeassertionEventEnablesByte2 & BIT6) == BIT6 )
             {
-                if (CompareValues(SensorIsSigned, SensorInfo.SensorReading, pSensor.UpperNonRecoverable) >= 0)
+                if (CompareValues(SensorIsSigned, pGetSensorInfoRes->SensorInfo.SensorReading, pSensor.UpperNonRecoverable) >= 0)
                 {
-                    SensorInfo.ComparisonStatus |= BIT5;
+                    pGetSensorInfoRes->SensorInfo.ComparisonStatus |= BIT5;
                 }
             }
             if((pSensor.DeassertionEventEnablesByte2 & BIT5) == BIT5 )
             {
-                if (CompareValues(SensorIsSigned, SensorInfo.SensorReading, pSensor.UpperCritical) >= 0)
+                if (CompareValues(SensorIsSigned, pGetSensorInfoRes->SensorInfo.SensorReading, pSensor.UpperCritical) >= 0)
                 {
-                    SensorInfo.ComparisonStatus |= BIT4;
+                    pGetSensorInfoRes->SensorInfo.ComparisonStatus |= BIT4;
                 }
             }
             if((pSensor.DeassertionEventEnablesByte2 & BIT4) == BIT4 )
             {
-                if (CompareValues(SensorIsSigned, SensorInfo.SensorReading, pSensor.UpperNonCritical) >= 0)
+                if (CompareValues(SensorIsSigned, pGetSensorInfoRes->SensorInfo.SensorReading, pSensor.UpperNonCritical) >= 0)
                 {
-                    SensorInfo.ComparisonStatus |= BIT3;
+                    pGetSensorInfoRes->SensorInfo.ComparisonStatus |= BIT3;
                 }
             }
             if((pSensor.AssertionEventEnablesByte2 & BIT6) == BIT6 )
             {
-                if (CompareValues(SensorIsSigned, SensorInfo.SensorReading, pSensor.LowerNonRecoverable) <= 0)
+                if (CompareValues(SensorIsSigned, pGetSensorInfoRes->SensorInfo.SensorReading, pSensor.LowerNonRecoverable) <= 0)
                 {
-                    SensorInfo.ComparisonStatus |= BIT2;
+                    pGetSensorInfoRes->SensorInfo.ComparisonStatus |= BIT2;
                 }
             }
             if((pSensor.AssertionEventEnablesByte2 & BIT5) == BIT5 )
             {
-                if (CompareValues(SensorIsSigned, SensorInfo.SensorReading, pSensor.LowerCritical) <= 0)
+                if (CompareValues(SensorIsSigned, pGetSensorInfoRes->SensorInfo.SensorReading, pSensor.LowerCritical) <= 0)
                 {
-                    SensorInfo.ComparisonStatus |= BIT1;
+                    pGetSensorInfoRes->SensorInfo.ComparisonStatus |= BIT1;
                 }
             }
             if((pSensor.AssertionEventEnablesByte2 & BIT4) == BIT4 )
             {
-                if (CompareValues(SensorIsSigned, SensorInfo.SensorReading, pSensor.LowerNonCritical) <= 0)
+                if (CompareValues(SensorIsSigned, pGetSensorInfoRes->SensorInfo.SensorReading, pSensor.LowerNonCritical) <= 0)
                 {
-                    SensorInfo.ComparisonStatus |= BIT0;
+                    pGetSensorInfoRes->SensorInfo.ComparisonStatus |= BIT0;
                 }
             }
 
-            SensorInfo.ComparisonStatus &= ((pSensor.SettableThreshMask >>  8) & 0xFF);
-            SensorInfo.OptionalStatus = 0;
+            pGetSensorInfoRes->SensorInfo.ComparisonStatus &= ((pSensor.SettableThreshMask >>  8) & 0xFF);
+            pGetSensorInfoRes->SensorInfo.OptionalStatus = 0;
             // For Threshold sensor, [7:6] - reserved. Returned as 1b. Ignore on read.
-            SensorInfo.ComparisonStatus |= THRESHOLD_RESERVED_BIT;
+            pGetSensorInfoRes->SensorInfo.ComparisonStatus |= THRESHOLD_RESERVED_BIT;
         }
         else
         {
-            SensorInfo.ComparisonStatus = (((uint8_t) (SensorReading & 0x00FF)) & ((uint8_t) (pSensor.SettableThreshMask & 0x00FF)) );
-            SensorInfo.OptionalStatus   = (((uint8_t) (SensorReading >> 8)) & ((uint8_t) (pSensor.SettableThreshMask >> 8)) );
+            pGetSensorInfoRes->SensorInfo.ComparisonStatus = (((uint8_t) (SensorReading & 0x00FF)) & ((uint8_t) (pSensor.SettableThreshMask & 0x00FF)) );
+            pGetSensorInfoRes->SensorInfo.OptionalStatus   = (((uint8_t) (SensorReading >> 8)) & ((uint8_t) (pSensor.SettableThreshMask >> 8)) );
             // For Discrete sensor, [7] - reserved. Returned as 1b. Ignore on read.
-            SensorInfo.OptionalStatus  |= DISCRETE_RESERVED_BIT;
+            pGetSensorInfoRes->SensorInfo.OptionalStatus  |= DISCRETE_RESERVED_BIT;
         }
 
         if((pSensor.EventFlags & BIT7) == 0)
         {
-            SensorInfo.AssertionEventByte1 = 0;
-            SensorInfo.AssertionEventByte2 = 0;
-            SensorInfo.DeassertionEventByte1 = 0;
-            SensorInfo.DeassertionEventByte2 = 0;
+            pGetSensorInfoRes->SensorInfo.AssertionEventByte1 = 0;
+            pGetSensorInfoRes->SensorInfo.AssertionEventByte2 = 0;
+            pGetSensorInfoRes->SensorInfo.DeassertionEventByte1 = 0;
+            pGetSensorInfoRes->SensorInfo.DeassertionEventByte2 = 0;
         }
         if((pSensor.SensorCaps & BIT6) == 0)
         {
-             SensorInfo.AssertionEventByte1    = (pSensor.AssertionHistoryByte1 & pSensor.AssertionEventEnablesByte1);
-             SensorInfo.AssertionEventByte2    = (pSensor.AssertionHistoryByte2 & pSensor.AssertionEventEnablesByte2);
-             SensorInfo.DeassertionEventByte1    = (pSensor.DeassertionHistoryByte1 & pSensor.DeassertionEventEnablesByte1);
-             SensorInfo.DeassertionEventByte2    = (pSensor.DeassertionHistoryByte2 & pSensor.DeassertionEventEnablesByte2);
+             pGetSensorInfoRes->SensorInfo.AssertionEventByte1    = (pSensor.AssertionHistoryByte1 & pSensor.AssertionEventEnablesByte1);
+             pGetSensorInfoRes->SensorInfo.AssertionEventByte2    = (pSensor.AssertionHistoryByte2 & pSensor.AssertionEventEnablesByte2);
+             pGetSensorInfoRes->SensorInfo.DeassertionEventByte1    = (pSensor.DeassertionHistoryByte1 & pSensor.DeassertionEventEnablesByte1);
+             pGetSensorInfoRes->SensorInfo.DeassertionEventByte2    = (pSensor.DeassertionHistoryByte2 & pSensor.DeassertionEventEnablesByte2);
         }
         else
         {
-             SensorInfo.AssertionEventByte1    = (pSensor.AssertionEventOccuredByte1 & pSensor.AssertionEventEnablesByte1);
-             SensorInfo.AssertionEventByte2    = (pSensor.AssertionEventOccuredByte2 & pSensor.AssertionEventEnablesByte2);
-             SensorInfo.DeassertionEventByte1    = (pSensor.DeassertionEventOccuredByte1 & pSensor.DeassertionEventEnablesByte1);
-             SensorInfo.DeassertionEventByte2    = (pSensor.DeassertionEventOccuredByte2 & pSensor.DeassertionEventEnablesByte2);
+             pGetSensorInfoRes->SensorInfo.AssertionEventByte1    = (pSensor.AssertionEventOccuredByte1 & pSensor.AssertionEventEnablesByte1);
+             pGetSensorInfoRes->SensorInfo.AssertionEventByte2    = (pSensor.AssertionEventOccuredByte2 & pSensor.AssertionEventEnablesByte2);
+             pGetSensorInfoRes->SensorInfo.DeassertionEventByte1    = (pSensor.DeassertionEventOccuredByte1 & pSensor.DeassertionEventEnablesByte1);
+             pGetSensorInfoRes->SensorInfo.DeassertionEventByte2    = (pSensor.DeassertionEventOccuredByte2 & pSensor.DeassertionEventEnablesByte2);
         }
         pSDRRec = GetSDRRec(pSensor.SDRRec->ID);
         if(pSensor.SDRRec->Type  == FULL_SDR_REC)       /*Full SDR*/
         {
             FullSDR = (FullSensorRec_T *)pSDRRec;
-            SensorInfo.OwnerID = FullSDR->OwnerID;
-            SensorInfo.OwnerLUN= FullSDR->OwnerLUN;
-            SensorInfo.MaxReading = FullSDR->MaxReading;
-            SensorInfo.MinReading = FullSDR->MinReading;
-            SensorInfo.Linearization = FullSDR->Linearization;
-            memset(SensorInfo.SensorName,0,MAX_ID_STR_LEN);
-            strncpy(SensorInfo.SensorName,FullSDR->IDStr, MAX_ID_STR_LEN - (sizeof(FullSensorRec_T) - sizeof(SDRRecHdr_T) - FullSDR->hdr.Len));
+            pGetSensorInfoRes->SensorInfo.OwnerID = FullSDR->OwnerID;
+            pGetSensorInfoRes->SensorInfo.OwnerLUN= FullSDR->OwnerLUN;
+            pGetSensorInfoRes->SensorInfo.MaxReading = FullSDR->MaxReading;
+            pGetSensorInfoRes->SensorInfo.MinReading = FullSDR->MinReading;
+            pGetSensorInfoRes->SensorInfo.Linearization = FullSDR->Linearization;
+            memset(pGetSensorInfoRes->SensorInfo.SensorName,0,MAX_ID_STR_LEN);
+            strncpy(pGetSensorInfoRes->SensorInfo.SensorName,FullSDR->IDStr, MAX_ID_STR_LEN - (sizeof(FullSensorRec_T) - sizeof(SDRRecHdr_T) - FullSDR->hdr.Len));
         }
         else if(pSensor.SDRRec->Type == COMPACT_SDR_REC)   /*Compact SDR*/
         {
             CompSDR = (CompactSensorRec_T *)pSDRRec;
-            SensorInfo.OwnerID = CompSDR->OwnerID;
-            SensorInfo.OwnerLUN= CompSDR->OwnerLUN;
-            SensorInfo.MaxReading = 0;
-            SensorInfo.MinReading = 0;
-            SensorInfo.Linearization = 0;
-            memset(SensorInfo.SensorName,0,MAX_ID_STR_LEN);
-            strncpy(SensorInfo.SensorName,CompSDR->IDStr, MAX_ID_STR_LEN - (sizeof(CompactSensorRec_T) - sizeof(SDRRecHdr_T) - CompSDR->hdr.Len));
+            pGetSensorInfoRes->SensorInfo.OwnerID = CompSDR->OwnerID;
+            pGetSensorInfoRes->SensorInfo.OwnerLUN= CompSDR->OwnerLUN;
+            pGetSensorInfoRes->SensorInfo.MaxReading = 0;
+            pGetSensorInfoRes->SensorInfo.MinReading = 0;
+            pGetSensorInfoRes->SensorInfo.Linearization = 0;
+            memset(pGetSensorInfoRes->SensorInfo.SensorName,0,MAX_ID_STR_LEN);
+            strncpy(pGetSensorInfoRes->SensorInfo.SensorName,CompSDR->IDStr, MAX_ID_STR_LEN - (sizeof(CompactSensorRec_T) - sizeof(SDRRecHdr_T) - CompSDR->hdr.Len));
         }
-        memcpy(pValidSensor,(uint8_t *)&SensorInfo,sizeof(SenInfo_T));
-        pValidSensor = pValidSensor + sizeof(SenInfo_T);
-    }
+        //memcpy(pValidSensor,(uint8_t *)&SensorInfo,sizeof(SenInfo_T));
+        //pValidSensor = pValidSensor + sizeof(SenInfo_T);
+    //}
 
-    pAMIGetSensorInfoRes->CompletionCode = CC_NORMAL;
-    pAMIGetSensorInfoRes->Noofentries = g_BMCInfo.SenConfig.ValidSensorCnt;
+    pGetSensorInfoRes->CompletionCode = CC_NORMAL;
+    //pAMIGetSensorInfoRes->Noofentries = g_BMCInfo.SenConfig.ValidSensorCnt;
 
-    // printf("return %d :", sizeof(AMIGetSensorInfoRes_T) + (sizeof(SenInfo_T) * g_BMCInfo.SenConfig.ValidSensorCnt));
+    //totalsize = sizeof(AMIGetSensorInfoRes_T) + (sizeof(SenInfo_T) * 11/*g_BMCInfo.SenConfig.ValidSensorCnt*/);
+    // printf("return %d :", totalsize);
     // for(i=0;i<sizeof(AMIGetSensorInfoRes_T) + (sizeof(SenInfo_T) * g_BMCInfo.SenConfig.ValidSensorCnt);i++)
     // 	printf("%#x ", pRes[i]);
     // printf("\n");
 
-    return sizeof(AMIGetSensorInfoRes_T) + (sizeof(SenInfo_T) * g_BMCInfo.SenConfig.ValidSensorCnt);
-
+    return sizeof(StorleadGetSensorInfoRes_T);
 }

+ 22 - 11
app/bmc/sensor_driver.c

@@ -33,7 +33,8 @@ int sensor_1_read(uint8_t *reading)
 //	stm32_i2c_master_read(fd, 0xAA, &buf, 1);
 //	close(fd);
 	//printf("read sensor 1: %#x!\n", buf);
-	*reading = buf;
+	//*reading = buf;
+	*reading = 0x10;
 	return 0;
 }
 
@@ -61,7 +62,8 @@ int sensor_2_read(uint8_t *reading)
 //	stm32_i2c_master_write(fd, 0xAA, &buf, 1);
 //	stm32_i2c_master_read(fd, 0xAA, &buf, 1);
 //	close(fd);
-	*reading = buf;
+	//*reading = buf;
+	*reading = 0x20;
 	return 0;
 }
 
@@ -89,7 +91,8 @@ int sensor_3_read(uint8_t *reading)
 //	stm32_i2c_master_write(fd, 0x98, &buf, 1);
 //	stm32_i2c_master_read(fd, 0x98, &buf, 1);
 //	close(fd);
-	*reading = buf;
+	//*reading = buf;
+	*reading = 0x30;
 	return 0;
 }
 
@@ -118,7 +121,8 @@ int sensor_4_read(uint8_t *reading)
 //	stm32_i2c_master_write(fd, 0x98, &buf, 1);
 //	stm32_i2c_master_read(fd, 0x98, &buf, 1);
 //	close(fd);
-	*reading = buf;
+	//*reading = buf;
+	*reading = 0x40;
 	return 0;
 }
 
@@ -141,7 +145,8 @@ int sensor_5_read(uint8_t *reading)
 {
 	uint16_t buf;
 //	stm32_adc_get_value(1, &buf);
-	*reading = buf>>4;
+	//*reading = buf>>4;
+	*reading = 0x50;
 	return 0;
 }
 
@@ -164,7 +169,8 @@ int sensor_6_read(uint8_t *reading)
 {
 	uint16_t buf;
 //	stm32_adc_get_value(2, &buf);
-	*reading = buf>>4;
+	//*reading = buf>>4;
+	*reading = 0x60;
 	return 0;
 }
 
@@ -187,7 +193,8 @@ int sensor_7_read(uint8_t *reading)
 {
 	uint16_t buf;
 //	stm32_adc_get_value(3, &buf);
-	*reading = buf>>4;
+	//*reading = buf>>4;
+	*reading = 0x70;
 	return 0;
 }
 
@@ -210,7 +217,8 @@ int sensor_8_read(uint8_t *reading)
 {
 	uint16_t buf;
 //	stm32_adc_get_value(4, &buf);
-	*reading = buf>>4;
+	//*reading = buf>>4;
+	*reading = 0x80;
 	return 0;
 }
 
@@ -233,7 +241,8 @@ int sensor_9_read(uint8_t *reading)
 {
 	uint16_t buf;
 //	stm32_adc_get_value(5, &buf);
-	*reading = buf>>4;
+	//*reading = buf>>4;
+	*reading = 0x90;
 	return 0;
 }
 
@@ -256,7 +265,8 @@ int sensor_10_read(uint8_t *reading)
 {
 	uint16_t buf;
 //	stm32_adc_get_value(6, &buf);
-	*reading = buf>>4;
+	//*reading = buf>>4;
+	*reading = 0xA0;
 	return 0;
 }
 
@@ -279,7 +289,8 @@ int sensor_11_read(uint8_t *reading)
 {
 	uint16_t buf;
 //	stm32_adc_get_value(7, &buf);
-	*reading = buf>>4;
+	//*reading = buf>>4;
+	*reading = 0xB0;
 	return 0;
 }
 

+ 7 - 6
app/common_include/com_BmcType.h

@@ -216,12 +216,6 @@ typedef struct {
 } OEM_FLAGS_T;
 
 
-typedef struct
-{
-    uint8_t   CompletionCode;
-    uint16_t   Noofentries;
-} AMIGetSensorInfoRes_T;
-
 
 typedef struct
 {
@@ -262,6 +256,13 @@ typedef struct
 
 }SenInfo_T;
 
+typedef struct
+{
+    uint8_t   CompletionCode;
+    SenInfo_T SensorInfo;
+    //uint16_t   Noofentries;
+} StorleadGetSensorInfoRes_T;
+
 // typedef struct
 // {
 //     uint8_t               Used;

+ 1 - 1
app/goahead-5.1.0/src/libipmi/inc/libipmi_sensor.h

@@ -168,7 +168,7 @@ LIBIPMI_HL_GetSensorCount( IPMI20_SESSION_T *pSession, int *sdr_count, int timeo
 
   uint16_t
 LIBIPMI_HL_GetAllSensorReadings( IPMI20_SESSION_T *pSession,
-                                 struct sensor_data *sensor_list, uint32_t* nNumSensor,int timeout );
+                                 struct sensor_data *sensor_list, uint32_t nNumSensor,int timeout );
 
 
   uint16_t 

+ 103 - 127
app/goahead-5.1.0/src/libipmi/src/libipmi_sensor.c

@@ -29,6 +29,8 @@
 #include "libipmi_AppDevice.h"
 #include "libipmi_storlead_OEM.h"
 #include "com_BmcType.h"
+#include "com_IPMIDefs.h"
+#include "com_IPMI_Storlead.h"
 
 #if 0
 /* A bunch of defines that SDRRecord needs.  We don't care about the actual */
@@ -853,142 +855,116 @@ LIBIPMI_HL_GetAllSensorReadings( IPMI20_SESSION_T *pSession,
  */
 
   uint16_t
-LIBIPMI_HL_GetAllSensorReadings( IPMI20_SESSION_T *pSession, struct sensor_data *sensor_list, uint32_t* nNumSensor, int timeout )
+LIBIPMI_HL_GetAllSensorReadings( IPMI20_SESSION_T *pSession, struct sensor_data *sensor_list, uint32_t nNumSensor, int timeout )
 {
     uint16_t wRet;
     int sdr_count;
     int i ;
-    SenInfo_T * pSensorBuff = NULL;
-    unsigned char* pSensor = NULL;
-
-    /* Load the SDRs related to sensors into memory */
-    wRet = LIBIPMI_HL_GetSensorCount( pSession,&sdr_count, timeout );
-    if( wRet != LIBIPMI_E_SUCCESS )
+  	uint8_t Req[20];
+  	StorleadGetSensorInfoRes_T GetSensorInfoRes; 
+  	uint32_t dwResLen;
+  	SenInfo_T *pSensorBuff;
+  	float tmp_float;
+  	uint16_t tmp_hw;
+
+    for(i = 0; i < nNumSensor; i++)
     {
-        printf( "Cannot load sensor SDRs\n" );
-        return( wRet );
-    }
+    	Req[0] = i;
+		wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, 	//notice!
+						(NETFN_STORLEAD << 2), CMD_GET_SENSOR_INFO,
+						Req, 1,
+						(uint8_t*)&GetSensorInfoRes, &dwResLen,
+						timeout);
+		if(wRet == LIBIPMI_E_SUCCESS)
+		{
+			pSensorBuff = &GetSensorInfoRes.SensorInfo;
+			sensor_list[ i ].sensor_num = pSensorBuff->SensorNumber;
+	        sensor_list[ i ].owner_id = pSensorBuff->OwnerID;
+	        sensor_list[ i ].owner_lun = pSensorBuff->OwnerLUN;
+	        sensor_list[ i ].sensor_type = pSensorBuff->SensorTypeCode;
+	        sensor_list[ i ].sensor_units[ 0 ] = pSensorBuff->Units1;
+	        sensor_list[ i ].sensor_units[ 1 ] = pSensorBuff->Units2;
+	        sensor_list[ i ].sensor_units[ 2 ] = pSensorBuff->Units3;
+	        sensor_list[ i ].raw_reading = pSensorBuff->SensorReading;
+	        strncpy(sensor_list[ i ].sensor_name,pSensorBuff->SensorName,MAX_ID_STR_LEN);
+	        sensor_list[i].SensorAccessibleFlags = 0;
+
+	        if(pSensorBuff->EventTypeCode > 1)
+	        {
+	            /*Updating the discrete sensor details*/
+	            sensor_list[i].discrete_state = pSensorBuff->EventTypeCode;
+	            sensor_list[i].sensor_state = 0;
+	            sensor_list[ i ].sensor_reading = (float)(pSensorBuff->ComparisonStatus | (pSensorBuff->OptionalStatus << 8));
+	        }
+	        else
+	        {
+	            sensor_list[ i ].discrete_state = 0;
+	            sensor_list[ i ].Settable_Readable_ThreshMask=pSensorBuff->Settable_Readable_ThreshMask;
+	            
+	            if(pSensorBuff->SensorReading>0)
+	            /*Convert Sensor Reading*/
+	            ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->SensorReading, &tmp_float, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1, 
+	                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
+	        	sensor_list[i].sensor_reading = tmp_float;
+
+	            /*Convert LowerNonRecoverable*/
+	            if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT2)
+	            ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->LowerNonRecoverable, &tmp_float, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1, 
+	                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
+	        	sensor_list[i].low_non_recov_thresh = tmp_float;
+
+	            /*Convert LowerCritical*/
+	            if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT1)
+	            ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->LowerCritical, &tmp_float, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1, 
+	                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
+	        	sensor_list[i].low_crit_thresh = tmp_float;
+
+	            /*Convert LowerNonCritical*/
+	            if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT0)
+	            ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->LowerNonCritical, &tmp_float, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1, 
+	                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
+	        	sensor_list[i].low_non_crit_thresh = tmp_float;
+
+	            /*Convert UpperNonCritical*/
+	            if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT3)
+	            ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->UpperNonCritical, &tmp_float, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1, 
+	                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
+	        	sensor_list[i].high_non_crit_thresh = tmp_float;
+
+	            /*Convert UpperCritical*/
+	            if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT4)
+	            ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->UpperCritical, &tmp_float, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1, 
+	                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
+	        	sensor_list[i].high_crit_thresh = tmp_float;
+
+	            /*Convert UpperNonRecoverable*/
+	            if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT5)
+	            ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->UpperNonRecoverable, &tmp_float, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1, 
+	                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
+	        	sensor_list[i].high_non_recov_thresh = tmp_float;
+
+	            /*Get the Sensor state*/
+	            SensorState(pSensorBuff->SensorReading,&tmp_hw,pSensorBuff->hdr.Type,pSensorBuff->Linearization,pSensorBuff->Units1,pSensorBuff->EventTypeCode,pSensorBuff->AssertionEventByte1,pSensorBuff->AssertionEventByte2,pSensorBuff->DeassertionEventByte1,pSensorBuff->DeassertionEventByte2);
+	            sensor_list[i].sensor_state = tmp_hw;
+            }
 
-    pSensorBuff = (SenInfo_T*) malloc(sdr_count* sizeof(SenInfo_T));
-    if(pSensorBuff == NULL)
-    {
-        printf("Error in Allocating the Memory\n");
-        return -1;
-    }
-    pSensor = (unsigned char *)pSensorBuff;
-
-  //   if(pSession->byMediumType == 5)	//IPMB
-  //   {
-  //   	wRet = LIBIPMI_HL_GetIPMCSensorInfo(pSession, pSensorBuff, nNumSensor, timeout);
-		// if ( wRet != LIBIPMI_E_SUCCESS )
-		// {
-		// 	free(pSensorBuff);
-		// 	if( wRet == LIBIPMI_E_SENSOR_INFO_EMPTY)
-		// 	{
-		// 		TINFO("Sensor Info is empty\n");
-		// 	}
-		// 	else
-		// 	{
-		// 		printf("Error in getting sensor info\n");
-		// 	}
-		// 	return (wRet);
-		// }
-  //   }
-  //   else
-    {
-    	wRet = LIBIPMI_HL_AMIGetSensorInfo(pSession, pSensorBuff, nNumSensor, timeout);
-		if ( wRet != LIBIPMI_E_SUCCESS )
+	        /* If sensor scanning is disabled or the reading is unavailable... */
+	        if( !( pSensorBuff->Flags & SENSOR_SCANNING_BIT)  || (pSensorBuff->Flags & UNABLE_TO_READ_SENSOR) )
+	        {
+	            /* Return an error code to let the caller know */
+	            sensor_list[i].SensorAccessibleFlags = SENSOR_NOT_AVAILABLE;
+	            sensor_list[i].sensor_reading = 0;
+	            sensor_list[i].discrete_state = 0;
+	            sensor_list[i].raw_reading = 0;
+	        }
+
+	        printf("sensor_list[%d]: SensorNum %d, SensorName %s, SensorReading = %f\n", i, sensor_list[i].sensor_num, sensor_list[i].sensor_name, sensor_list[i].sensor_reading);
+		}
+		else
 		{
-			free(pSensorBuff);
-			if( wRet == LIBIPMI_E_SENSOR_INFO_EMPTY)
-			{
-				printf("Sensor Info is empty\n");
-			}
-			else
-			{
-				printf("Error in getting sensor info\n");
-			}
-			return (wRet);
+			printf("error getting sensor info %d\n",wRet);
 		}
     }
-
-    for(i = 0; i < *nNumSensor; i++)
-    {
-        sensor_list[ i ].sensor_num = pSensorBuff->SensorNumber;
-        sensor_list[ i ].owner_id = pSensorBuff->OwnerID;
-        sensor_list[ i ].owner_lun = pSensorBuff->OwnerLUN;
-        sensor_list[ i ].sensor_type = pSensorBuff->SensorTypeCode;
-        sensor_list[ i ].sensor_units[ 0 ] = pSensorBuff->Units1;
-        sensor_list[ i ].sensor_units[ 1 ] = pSensorBuff->Units2;
-        sensor_list[ i ].sensor_units[ 2 ] = pSensorBuff->Units3;
-        sensor_list[ i ].raw_reading = pSensorBuff->SensorReading;
-        strncpy(sensor_list[ i ].sensor_name,pSensorBuff->SensorName,MAX_ID_STR_LEN);
-        sensor_list[i].SensorAccessibleFlags = 0;
-
-        if(pSensorBuff->EventTypeCode > 1)
-        {
-            /*Updating the discrete sensor details*/
-            sensor_list[i].discrete_state = pSensorBuff->EventTypeCode;
-            sensor_list[i].sensor_state = 0;
-            sensor_list[ i ].sensor_reading = (float)(pSensorBuff->ComparisonStatus | (pSensorBuff->OptionalStatus << 8));
-        }
-        else
-        {
-            sensor_list[ i ].discrete_state = 0;
-            sensor_list[ i ].Settable_Readable_ThreshMask=pSensorBuff->Settable_Readable_ThreshMask;
-            
-            if(pSensorBuff->SensorReading>0)
-            /*Convert Sensor Reading*/
-            ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->SensorReading, &sensor_list[i].sensor_reading, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1, 
-                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
-
-            /*Convert LowerNonRecoverable*/
-            if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT2)
-            ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->LowerNonRecoverable, &sensor_list[i].low_non_recov_thresh, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1, 
-                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
-
-            /*Convert LowerCritical*/
-            if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT1)
-            ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->LowerCritical, &sensor_list[i].low_crit_thresh, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1, 
-                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
-
-            /*Convert LowerNonCritical*/
-            if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT0)
-            ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->LowerNonCritical, &sensor_list[i].low_non_crit_thresh, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1, 
-                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
-
-            /*Convert UpperNonCritical*/
-            if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT3)
-            ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->UpperNonCritical, &sensor_list[i].high_non_crit_thresh, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1, 
-                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
-
-            /*Convert UpperCritical*/
-            if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT4)
-            ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->UpperCritical, &sensor_list[i].high_crit_thresh, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1, 
-                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
-
-            /*Convert UpperNonRecoverable*/
-            if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT5)
-            ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->UpperNonRecoverable, &sensor_list[i].high_non_recov_thresh, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1, 
-                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
-
-            /*Get the Sensor state*/
-            SensorState(pSensorBuff->SensorReading,&sensor_list[i].sensor_state,pSensorBuff->hdr.Type,pSensorBuff->Linearization,pSensorBuff->Units1,pSensorBuff->EventTypeCode,pSensorBuff->AssertionEventByte1,pSensorBuff->AssertionEventByte2,pSensorBuff->DeassertionEventByte1,pSensorBuff->DeassertionEventByte2);
-
-        }
-
-        /* If sensor scanning is disabled or the reading is unavailable... */
-        if( !( pSensorBuff->Flags & SENSOR_SCANNING_BIT)  || (pSensorBuff->Flags & UNABLE_TO_READ_SENSOR) )
-        {
-            /* Return an error code to let the caller know */
-            sensor_list[i].SensorAccessibleFlags = SENSOR_NOT_AVAILABLE;
-            sensor_list[i].sensor_reading = 0;
-            sensor_list[i].discrete_state = 0;
-            sensor_list[i].raw_reading = 0;
-        }
-        pSensorBuff++;
-    }
-    free(pSensor);
     return wRet ;
 }
 

+ 60 - 73
app/goahead-5.1.0/src/libipmi/src/libipmi_storlead_OEM.c

@@ -26,9 +26,9 @@ OemWebFlags_T g_OemWebFlags;
 *@param pAMIGetSensorInfoRes - Pointer to the response of AMI Get SensorInfo command
 *@param timeout - Timeout Value
 **/
-uint16_t IPMICMD_GetIPMCSensorInfo(IPMI20_SESSION_T *pSession, AMIGetSensorInfoRes_T *pGetIPMCSensorInfoRes,int timeout)
-{
- 	uint16_t wRet = 0;
+// uint16_t IPMICMD_GetIPMCSensorInfo(IPMI20_SESSION_T *pSession, AMIGetSensorInfoRes_T *pGetIPMCSensorInfoRes,int timeout)
+// {
+//  	uint16_t wRet = 0;
 	
 // 	uint16_t reservation_id;
 // 	uint16_t record_id = 0;
@@ -175,43 +175,43 @@ uint16_t IPMICMD_GetIPMCSensorInfo(IPMI20_SESSION_T *pSession, AMIGetSensorInfoR
 // //		printf("%#2x ",((uint8_t*)pGetIPMCSensorInfoRes)[i]);
 // //	printf("\n");
 	
-	return (wRet);
-}
+// 	return (wRet);
+// }
 
 
-uint16_t LIBIPMI_HL_GetIPMCSensorInfo(IPMI20_SESSION_T *pSession,SenInfo_T *pSensorInfo,uint32_t *nNumSensor,int timeout)
-{
-	uint16_t wRet = 0;
-	AMIGetSensorInfoRes_T *pGetIPMCSensorInfoRes;
-	uint8_t *SensorEntries;
-	int i;
+// uint16_t LIBIPMI_HL_GetIPMCSensorInfo(IPMI20_SESSION_T *pSession,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;
-	}
+// 	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(pSession,(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);
-}
+// 	memset(SensorEntries,0,MAX_SENSOR_INFO_SIZE);
+// 	pGetIPMCSensorInfoRes = (AMIGetSensorInfoRes_T *)SensorEntries;
+// 	wRet = IPMICMD_GetIPMCSensorInfo(pSession,(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_FanCtrol( IPMI20_SESSION_T *pSession, uint8_t fanIndex, uint8_t fanMode, uint8_t fanLevel, int timeout)
 {
@@ -610,52 +610,39 @@ int LIBIPMI_HL_SetSensorHistoryEn(IPMI20_SESSION_T *pSession, uint8_t sensorNum,
  return 0;
 }
 
-uint16_t IPMICMD_AMIGetSensorInfo(IPMI20_SESSION_T *pSession, AMIGetSensorInfoRes_T *pAMIGetSensorInfoRes,int timeout)
+uint16_t IPMICMD_GetSensorInfo(IPMI20_SESSION_T *pSession, uint8_t SensorIndex, StorleadGetSensorInfoRes_T *pGetSensorInfoRes,int timeout)
 {
 	uint16_t wRet;
-	uint32_t dwResLen;
+	uint32_t dwResLen = 0;
 	uint8_t Req[20];
-	dwResLen = sizeof(AMIGetSensorInfoRes_T);
 	
+	Req[0] = SensorIndex;
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, 	//notice!
 						(NETFN_STORLEAD << 2), CMD_GET_SENSOR_INFO,
-						Req, 0,
-						(uint8_t*)pAMIGetSensorInfoRes, &dwResLen,
+						Req, 1,
+						(uint8_t*)pGetSensorInfoRes, &dwResLen,
 						timeout);
 	
 	return (wRet);
 }
 
-uint16_t LIBIPMI_HL_AMIGetSensorInfo(IPMI20_SESSION_T *pSession,SenInfo_T *pSensorInfo,uint32_t *nNumSensor,int timeout)
-{
-	uint16_t wRet = 0;
-	AMIGetSensorInfoRes_T *pAMIGetSensorInfoRes;
-	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;
-	}
+// uint16_t LIBIPMI_HL_GetSensorInfo(IPMI20_SESSION_T *pSession,SenInfo_T *pSensorInfo,uint32_t nNumSensor,int timeout)
+// {
+// 	uint16_t wRet = 0;
+// 	StorleadGetSensorInfoRes_T GetSensorInfoRes;
+// 	int i;
 
-	memset(SensorEntries,0,MAX_SENSOR_INFO_SIZE);
-	pAMIGetSensorInfoRes = (AMIGetSensorInfoRes_T *)SensorEntries;
-	wRet = IPMICMD_AMIGetSensorInfo(pSession,(AMIGetSensorInfoRes_T *)SensorEntries,timeout);
-	if(wRet == LIBIPMI_E_SUCCESS)
-	{
-		*nNumSensor = pAMIGetSensorInfoRes->Noofentries;
-		for(i = 0; i < pAMIGetSensorInfoRes->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);
-}
+// 	for(i=0;i<nNumSensor;i++)
+// 	{
+// 		wRet = IPMICMD_AMIGetSensorInfo(pSession, i, &GetSensorInfoRes,timeout);
+// 		if(wRet == LIBIPMI_E_SUCCESS)
+// 		{
+// 			memcpy((uint8_t *)&pSensorInfo[i], GetSensorInfoRes.SensorInfo);
+// 		}
+// 		else
+// 		{
+// 			printf("error getting sensor info %d\n",wRet);
+// 		}
+// 	}
+// 	return (wRet);
+// }

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

@@ -842,9 +842,9 @@ int ipmi_conv_reading(uint8_t SDRType, uint8_t raw_reading, float *converted_rea
     switch( 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:
@@ -858,9 +858,9 @@ int ipmi_conv_reading(uint8_t SDRType, uint8_t raw_reading, float *converted_rea
             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:
@@ -874,9 +874,9 @@ int ipmi_conv_reading(uint8_t SDRType, uint8_t raw_reading, float *converted_rea
             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:

+ 34 - 32
app/goahead-5.1.0/src/web_interface/src/dashboard.c

@@ -218,7 +218,6 @@ void getSensorInfo(Webs *wp){
     struct sensor_data *pSensorBuff = NULL;
     long int reading,lownr,lowct,lownc,highnc,highct,highnr = 0;
     unsigned char *pStartBuff = NULL;
-    uint32_t nNumSensor = 0;
 
     //Create session
     wRet = LIBIPMI_CreateSession(&wp->ipmi_session, 10);
@@ -250,8 +249,12 @@ void getSensorInfo(Webs *wp){
         memset(pSensorBuff, 0, nSensors * sizeof(struct sensor_data));
         pStartBuff = (unsigned char *)pSensorBuff;
 
-        wRet = LIBIPMI_HL_GetAllSensorReadings(&wp->ipmi_session,pSensorBuff, &nNumSensor,DEFAULT_TIMEOUT);
+        printf("sensorcount = %d\n", nSensors);
+        nSensors -= 1;  //remove first sdr
+        wRet = LIBIPMI_HL_GetAllSensorReadings(&wp->ipmi_session,pSensorBuff, nSensors,DEFAULT_TIMEOUT);
         
+        //Close session
+        LIBIPMI_CloseSession(&wp->ipmi_session );
 
         if(wRet != 0)
         {
@@ -261,12 +264,12 @@ void getSensorInfo(Webs *wp){
         else
         {
 
-            cchar *pStr;
-            int code = 200;
-            cJSON * root =  cJSON_CreateObject();
-            cJSON  *pJsonArry,*pJsonsub;
+            // cchar *pStr;
+            // int code = 200;
+            // cJSON * root =  cJSON_CreateObject();
+            // cJSON  *pJsonArry,*pJsonsub;
    
-            pJsonArry=cJSON_CreateArray();   /*创建数组*/
+            // pJsonArry=cJSON_CreateArray();   /*创建数组*/
             
 
            
@@ -278,7 +281,7 @@ void getSensorInfo(Webs *wp){
             // cJSON_AddStringToObject(data, "fwVersion", FwVersion);
             //printf("sesscess reading All Sensors, nNumSensor = %d\n", nNumSensor);    //this is sensor number
             /* Write entries here */
-            while(nNumSensor)
+            while(nSensors)
             {
                 reading = pSensorBuff->sensor_reading * 1000;
                 lownr = pSensorBuff->low_non_recov_thresh * 1000;
@@ -309,37 +312,36 @@ void getSensorInfo(Webs *wp){
                 //             highct,
                 //             highnr,
                 //             pSensorBuff->SensorAccessibleFlags);
-                cJSON_AddItemToArray(pJsonArry,pJsonsub=cJSON_CreateObject()); /* 给创建的数组增加对对象*/
-                cJSON_AddStringToObject(pJsonsub, "PROV_BRANCH_NO","000002");      /* 给对象增加内容 */                   
-                cJSON_AddStringToObject(pJsonsub, "SRC_SYS","UBPS");                                        
-                cJSON_AddStringToObject(pJsonsub, "CUST_OAC_BRANCH_NO","120101");                                                         
-                cJSON_AddStringToObject(pJsonsub, "ROLE","3");                 
-                cJSON_AddStringToObject(pJsonsub, "IPSN_NO","1");   
+                // cJSON_AddItemToArray(pJsonArry,pJsonsub=cJSON_CreateObject()); /* 给创建的数组增加对对象*/
+                // cJSON_AddStringToObject(pJsonsub, "PROV_BRANCH_NO","000002");      /* 给对象增加内容 */                   
+                // cJSON_AddStringToObject(pJsonsub, "SRC_SYS","UBPS");                                        
+                // cJSON_AddStringToObject(pJsonsub, "CUST_OAC_BRANCH_NO","120101");                                                         
+                // cJSON_AddStringToObject(pJsonsub, "ROLE","3");                 
+                // cJSON_AddStringToObject(pJsonsub, "IPSN_NO","1");   
 
                 pSensorBuff++;
-                nNumSensor--;
+                nSensors--;
             }
 
-            cJSON_AddItemToObject(root, "data", pJsonArry);//根节点下添加
-            cJSON_AddItemToObject(root, "msg", cJSON_CreateString(""));
-            cJSON_AddItemToObject(root, "code", cJSON_CreateString("200"));
-            pStr = cJSON_Print(pJsonArry);
-
-            logmsg(2, "-----------------------sensor----------------------%s", pStr);
-
-            websSetStatus(wp, 200);
-            websWriteHeaders(wp, -1, 0);
-            websWriteEndHeaders(wp); 
-            //websWrite(wp, "[");
-            websWrite(wp, pStr);
-            //websWrite(wp, "]");
-            //websFlush(wp, 0);
-            websDone(wp);
+            // cJSON_AddItemToObject(root, "data", pJsonArry);//根节点下添加
+            // cJSON_AddItemToObject(root, "msg", cJSON_CreateString(""));
+            // cJSON_AddItemToObject(root, "code", cJSON_CreateString("200"));
+            // pStr = cJSON_Print(pJsonArry);
+
+            logmsg(2, "-----------------------sensor----------------------");
+
+            // websSetStatus(wp, 200);
+            // websWriteHeaders(wp, -1, 0);
+            // websWriteEndHeaders(wp); 
+            // //websWrite(wp, "[");
+            // websWrite(wp, pStr);
+            // //websWrite(wp, "]");
+            // //websFlush(wp, 0);
+            // websDone(wp);
         }
     }
 
-    //Close session
-    LIBIPMI_CloseSession(&wp->ipmi_session );
+    
 
     //TODO: lusa
 

BIN
app/test_app/test_app