zhangbo 3 rokov pred
rodič
commit
ce409b9cf0

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

@@ -206,7 +206,6 @@ MonitorTSensors ( SensorInfo_T*     pSensorInfo)
 	int16_t                   CriticalLow;
 	int16_t                   NonRecoverableHigh;
 	int16_t                   NonRecoverableLow;
-//	uint8_t                   SensorLevel;
 	uint8_t                   SettableThreshMask;
 	uint8_t		    	 	  SensorReading;
 	uint8_t  		    		PSGood = 0;
@@ -216,17 +215,10 @@ MonitorTSensors ( SensorInfo_T*     pSensorInfo)
 	uint8_t                       DeassertionHistoryByte1;
 	uint8_t                       DeassertionHistoryByte2;
 	uint8_t                   OEMField;
-//	uint8_t			    	SensorNum;	
 	uint8_t                	SignedSensor = 0; // 1 if sensor has signed values
 	int16_t               	SensorMax = 255;
 	int16_t               	SensorMin = 0;
-	//uint16_t_t              OrgSensorValue;
 	int16_t               	DeassertThreshold;
-	// Added for Sensor Override capability
-//	int                 	Override = 0;
-//	uint8_t 				ReadFlags = 0;
-//	FullSensorRec_T*      	sfs=NULL;
-//	CompactSensorRec_T*   	scs=NULL;
 	int				index,j;
 	
 	PSGood = g_BMCInfo.PowerGoodFlag;
@@ -244,19 +236,10 @@ MonitorTSensors ( SensorInfo_T*     pSensorInfo)
 	else
 	{
 		pSensorInfo->Err	=	get_sensor_reading(pSensorInfo->SensorNumber, &SensorReading);
-		
-//		if (FULL_SDR_REC == pSensorInfo->SDRRec->Type)
-//		{
-//			sfs = ( FullSensorRec_T*)pSensorInfo->SDRRec;
-//		}
-//		else if (COMPACT_SDR_REC==pSensorInfo->SDRRec->Type)
-//		{
-//			scs = ( CompactSensorRec_T*)pSensorInfo->SDRRec;
-//		}
 		pSensorInfo->SensorReading = SensorReading;
 		
 		//keep sensor history
-		if((g_BMCInfo.CurTimerSecond%180 == 0))	//3 minutes
+		//if((g_BMCInfo.CurTimerSecond%180 == 0))	//3 minutes
 		{
 			for(index=0; index<SENSOR_NUMBERS;index++)
 			{
@@ -269,8 +252,7 @@ MonitorTSensors ( SensorInfo_T*     pSensorInfo)
 					gSensorHistoryInfo[index].History[HISTORY_DATA_SIZE-1] = pSensorInfo->SensorReading;
 				}
 			}
-		}
-		
+		}		
 	}
 
 

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

@@ -25,7 +25,8 @@ int  Storlead_GetSysInfo(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
 		while(Title[totalLen])
 		{
 			totalLen++;
-		}printf("title total len = %#x\n",totalLen);
+		}
+        //printf("title total len = %#x\n",totalLen);
 		pStr = Title;
 		break;
 	case 1:
@@ -33,7 +34,7 @@ int  Storlead_GetSysInfo(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
 		{
 			totalLen++;
 		}
-		printf("text total len = %#x\n", totalLen);
+		//printf("text total len = %#x\n", totalLen);
 		pStr = Text;
 		break;
 	default:
@@ -77,8 +78,6 @@ int  Storlead_GetSysInfo(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
 
 int  Storlead_GetSensorInfo(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
 {
-//	printf("Storlead_GetSensorInfo\n" );
-
 	StorleadGetSensorInfoRes_T *pGetSensorInfoRes = (StorleadGetSensorInfoRes_T *)pRes;
     uint8_t*   		pValidSensor = NULL;
     uint16_t       	SensorIndex = pReq[0];
@@ -336,7 +335,7 @@ int Storlead_GetSensorHistory(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
     
     if(len > (total_len - offset))
         len = total_len - offset;
-    printf("len = %d, offset = %d, total_len = %d\n", len, offset, total_len);
+    printf("Storlead_GetSensorHistory(): len = %d, offset = %d, total_len = %d\n", len, offset, total_len);
     
     *(pRes+1) = len&0xff;
     *(pRes+2) = (len>>8)&0xff;

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

@@ -500,12 +500,12 @@ PUBLIC bool websLoginUser(Webs *wp, char *username, char *password)
     wp->password = sclone(password);
 
     if (!(wp->route->verify)(wp)) {
-        printf("Password does not match");
+        printf("Password does not match\n");
         return 0;
     }
 
     //这一句打印不能去掉,去掉后在登录网页时goahead会重启。
-    printf("Login successful for %s", username);
+    printf("Login successful for %s\n", username);
 
     websCreateSession(wp);
     websSetSessionVar(wp, WEBS_SESSION_USERNAME, wp->username);

+ 1 - 1
app/goahead-3.6.5/src/libipmi/src/libipmi_storlead_OEM.c

@@ -232,7 +232,7 @@ int LIBIPMI_HL_GetFanInfo(IPMI20_UDS_SESSION_T *pUDSSession, FanInfo_T* pFanInfo
 							(uint8_t*)pRes,  &dwResLen,
 							timeout);
 
-	printf("dwResLen %d\n", dwResLen);
+	//printf("dwResLen %d\n", dwResLen);
 	if(( wRet != 0 ) || (pRes[0] != 0))
 	{
 		printf("Error LIBIPMI_HL_GetFanInfo\n");

+ 4 - 5
app/goahead-3.6.5/src/upload.c

@@ -188,7 +188,7 @@ static void processUploadHeader(Webs *wp, char *line)
         wp->uploadState = UPLOAD_CONTENT_DATA;
         return;
     }
-    printf( "Header line: %s", line);
+    //printf( "Header line: %s", line);
 
     headerTok = line;
     stok(line, ": ", &rest);
@@ -318,7 +318,7 @@ static int writeToFile(Webs *wp, char *data, ssize len)
             return -1;
         }
         file->size += len;
-        printf( "uploadFilter: Wrote %d bytes to %s", len, wp->uploadTmp);
+        //printf( "uploadFilter: Wrote %d bytes to %s", len, wp->uploadTmp);
     }
     return 0;
 }
@@ -345,7 +345,7 @@ static bool processContentData(Webs *wp)
         return 0;
     }
     if ((bp = getBoundary(wp, content->servp, size)) == 0) {
-        printf( "uploadFilter: Got boundary filename %x", wp->clientFilename);
+        //printf( "uploadFilter: Got boundary filename %x", wp->clientFilename);
         if (wp->clientFilename) {
             /*
                 No signature found yet. probably more data to come. Must handle split boundaries.
@@ -354,7 +354,6 @@ static bool processContentData(Webs *wp)
             nbytes = ((int) (content->endp - data)) - (wp->boundaryLen - 1);
             if (writeToFile(wp, content->servp, nbytes) < 0) {
                 /* Proceed to handle error */
-                printf("write >>>>>>>>>>>>>hander error\n");
                 return 1;
             }
             websConsumeInput(wp, nbytes);
@@ -389,7 +388,7 @@ static bool processContentData(Webs *wp)
                 Normal string form data variables
              */
             data[nbytes] = '\0';
-            printf( "uploadFilter: form[%s] = %s", wp->uploadVar, data);
+            //printf( "uploadFilter: form[%s] = %s", wp->uploadVar, data);
             websDecodeUrl(wp->uploadVar, wp->uploadVar, -1);
             websDecodeUrl(data, data, -1);
             websSetVar(wp, wp->uploadVar, data);

+ 1 - 1
app/goahead-3.6.5/src/web_interface/src/fw_update.c

@@ -134,7 +134,7 @@ void updateFlash(Webs *wp)
 
 //    wp->index = TEST_INDEX;
     target_addr = gIPMBAddr[wp->index];
-    printf("wp->index %d, target_addr %#x\n", wp->index, target_addr);
+    //printf("wp->index %d, target_addr %#x\n", wp->index, target_addr);
     if(target_addr == 0x20)
     {
         //Call updateFW_app

+ 109 - 129
app/goahead-3.6.5/src/web_interface/src/server_health.c

@@ -135,11 +135,11 @@ void webGetSensorHistory(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        *historyBuf = walloc(500);
+    sensor_history_st *pSensorHistory = (sensor_history_st *)walloc(sizeof(sensor_history_st));
+    char        tmpBuf[10];
+    char        *historyBuf = walloc(500);
     uint8_t     target_addr;
- //   FullSensorRec_T *sdr_record = (FullSensorRec_T*) walloc(100);
+    FullSensorRec_T *sdr_record = (FullSensorRec_T*) walloc(100);
     uint32_t     sdr_buff_size = 0;
     float       tmpValue;
     uint32_t    dwResLen;
@@ -147,142 +147,122 @@ void webGetSensorHistory(Webs *wp)
     char *strSensorNumber = websGetVar(wp, "SensorNumber", NULL);
     int   SensorNumber = atoi(strSensorNumber);
 
-    //memset(pSensorHistory->sensor_history, 0, 480);
+    memset(pSensorHistory->sensor_history, 0, HISTORY_DATA_SIZE);
     
-    // //Create session
-    // LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
-
-    // //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);
+    //Create session
+    LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
 
+    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);
     
-    // 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;
-    //     }
-    // }
+    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<HISTORY_DATA_SIZE;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 );
+    //Close session
+    LIBIPMI_CloseSession(&UDSSession );
     
-    // websSetStatus(wp, 200);
-    // websWriteHeaders(wp, -1, 0);
-    // websWriteEndHeaders(wp); 
-    // websWrite(wp, "{\"SensorNum\":%d,\"SensorName\":\"%s\",\"history\":\"", SensorNumber, sdr_record->IDStr);
-
-    // //char *strBuf = historyBuf;
-    // for(i=0;i<HISTORY_DATA_SIZE;i++)
-    // {
-    //     sprintf(tmpBuf, "%0.2f", pSensorHistory->sensor_history[i]);
-    //     j = 0;
-    //     while(tmpBuf[j] != '\0')
-    //     {
-    //         j++;
-    //         if(j>=10)
-    //             break;
-    //     }
-    //     if(i < HISTORY_DATA_SIZE-1)
-    //         tmpBuf[j] = ',';    //replace '\0' by ','   
-    //     else
-    //         tmpBuf[j] = '"';    //最后一个串结束符用引号替换
-    //     j++;        //point to next empty
-    //     websWrite(wp,"%s",tmpBuf);
-    //     //sprintf(strBuf, "%s", tmpBuf);
-    //     //strBuf += j;
-    // }
-    // websWrite(wp, "}");
-    //strBuf--;
-    //*strBuf = '\0';
+    websSetStatus(wp, 200);
+    websWriteHeaders(wp, -1, 0);
+    websWriteEndHeaders(wp); 
+    websWrite(wp, "{\"SensorNum\":%d,\"SensorName\":\"%s\",\"history\":\"", SensorNumber, sdr_record->IDStr);
+
+    //char *strBuf = historyBuf;
+    for(i=0;i<HISTORY_DATA_SIZE;i++)
+    {
+        memset(tmpBuf,0, sizeof(tmpBuf));
+        sprintf(tmpBuf, "%0.2f", pSensorHistory->sensor_history[i]);
+        j = 0;
+        while(tmpBuf[j] != '\0')
+        {
+            j++;
+            if(j>=10)
+                break;
+        }
+        if(i < HISTORY_DATA_SIZE-1)
+            tmpBuf[j] = ',';    //replace '\0' by ','   
+        else
+            tmpBuf[j] = '"';    //最后一个串结束符用引号替换
+        websWrite(wp, tmpBuf);
+    }
+    websWrite(wp, "}");
 
-    cJSON * root =  cJSON_CreateObject();
-    cJSON_AddNumberToObject(root, "SensorNum", 1);//pSensorHistory->sensor_num);
-    cJSON_AddStringToObject(root, "SensorName", "test");//pSensorHistory->sensor_name);
-    cJSON_AddStringToObject(root, "history", "");//historyBuf);
-    
-    char *pStr;
-    pStr = cJSON_PrintUnformatted(root);
-    websWrite(wp, "%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
-    //printf("cJSON:%s\n", pStr);
-
-    if(pStr)
-        wfree(pStr);
-    if(root)
-        cJSON_Delete(root);
 
-    // if(historyBuf)
-    //     wfree(historyBuf);
-    // if(pSensorHistory)
-    //     wfree(pSensorHistory);
+    if(historyBuf)
+        wfree(historyBuf);
+    if(pSensorHistory)
+        wfree(pSensorHistory);
+    if(sdr_record)
+        wfree(sdr_record);
 }