zhangbo 5 anni fa
parent
commit
02c40f8f4f

BIN
app/bmc/bmc_app


+ 13 - 13
app/bmc/main.c

@@ -96,19 +96,19 @@ void main(void)
     {
         printf("%s: Create LANIfcTask thread failed!\n", __FUNCTION__);
     }
-	/* Create IPMB interface */
-	uint8_t primaryIpmbSelect = 0;	//primary
-	gThreadIndex++;
-	if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,IPMBIfcTask,&primaryIpmbSelect))
-   {
-       printf("%s: Create LANIfcTask thread failed!\n", __FUNCTION__);
-   }
-   uint8_t secondaryIpmbSelect = 1;	//secondary
-   gThreadIndex++;
-	if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,IPMBIfcTask,&secondaryIpmbSelect))
-   {
-       printf("%s: Create LANIfcTask thread failed!\n", __FUNCTION__);
-   }
+	// /* Create IPMB interface */
+	// uint8_t primaryIpmbSelect = 0;	//primary
+	// gThreadIndex++;
+	// if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,IPMBIfcTask,&primaryIpmbSelect))
+ //   {
+ //       printf("%s: Create LANIfcTask thread failed!\n", __FUNCTION__);
+ //   }
+ //   uint8_t secondaryIpmbSelect = 1;	//secondary
+ //   gThreadIndex++;
+	// if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,IPMBIfcTask,&secondaryIpmbSelect))
+ //   {
+ //       printf("%s: Create LANIfcTask thread failed!\n", __FUNCTION__);
+ //   }
 
 	/* Create Update FPGA thread */
 

+ 1 - 1
app/bmc/sensor_driver.c

@@ -92,7 +92,7 @@ int sensor_3_read(uint8_t *reading)
 //	stm32_i2c_master_read(fd, 0x98, &buf, 1);
 //	close(fd);
 	//*reading = buf;
-	*reading = 0x30;
+	*reading = 0x80;
 	return 0;
 }
 

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

@@ -958,7 +958,7 @@ LIBIPMI_HL_GetAllSensorReadings( IPMI20_UDS_SESSION_T *pUDSSession, struct senso
 	            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);
+	        //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
 		{

+ 65 - 28
app/goahead-3.6.5/src/web_interface/src/dashboard.c

@@ -89,6 +89,7 @@ void getDeviceInfo(Webs *wp){
     cJSON_AddStringToObject(data, "fwVersion", FwVersion);
     cJSON_AddStringToObject(data, "macAddr", MacAddr);
     cJSON_AddStringToObject(data, "ipAddr", IpAddr);
+    cJSON_AddStringToObject(data, "netMode", "static");
 
     pStr = cJSON_Print(root);
 
@@ -200,7 +201,7 @@ void getSensorInfo(Webs *wp){
     int         HighNRThresh;
     int         SensorAccessibleFlags;
     struct sensor_data *pSensorBuff = NULL;
-    long int reading,lownr,lowct,lownc,highnc,highct,highnr = 0;
+    char reading[10], lownr[10],lowct[10],lownc[10],highnc[10],highct[10],highnr[10];
     unsigned char *pStartBuff = NULL;
     IPMI20_UDS_SESSION_T    UDSSession;
     
@@ -249,7 +250,7 @@ void getSensorInfo(Webs *wp){
         else
         {
 
-            cchar *pStr;
+            char *pStr;
             int code = 200;
             cJSON * root =  cJSON_CreateObject();
             cJSON  *pJsonArry,*pJsonsub;
@@ -257,33 +258,61 @@ void getSensorInfo(Webs *wp){
             logmsg(2, "-----------------------sensor----------------------");
             while(nSensors)
             {
-                reading = pSensorBuff->sensor_reading * 1000;
-                lownr = pSensorBuff->low_non_recov_thresh * 1000;
-                lowct = pSensorBuff->low_crit_thresh * 1000;
-                lownc = pSensorBuff->low_non_crit_thresh * 1000;
-                highnc = pSensorBuff->high_non_crit_thresh * 1000;
-                highct = pSensorBuff->high_crit_thresh * 1000;
-                highnr = pSensorBuff->high_non_recov_thresh * 1000;
+                sprintf(reading, "%.3f", pSensorBuff->sensor_reading);
+                sprintf(lownr, "%.3f", pSensorBuff->low_non_recov_thresh);
+                sprintf(lowct, "%.3f", pSensorBuff->low_crit_thresh);
+                sprintf(lownc, "%.3f", pSensorBuff->low_non_crit_thresh);
+                sprintf(highnc, "%.3f", pSensorBuff->high_non_crit_thresh);
+                sprintf(highct, "%.3f", pSensorBuff->high_crit_thresh);
+                sprintf(highnr, "%.3f", pSensorBuff->high_non_recov_thresh);
+
                 cJSON_AddItemToArray(pJsonArry,pJsonsub=cJSON_CreateObject()); /* 给创建的数组增加对对象*/
-                cJSON_AddNumberToObject(pJsonsub, "sensorNum", pSensorBuff->sensor_num); 
+                //cJSON_AddNumberToObject(pJsonsub, "sensorNum", pSensorBuff->sensor_num); 
                 cJSON_AddStringToObject(pJsonsub, "sensorName", pSensorBuff->sensor_name);
-                cJSON_AddNumberToObject(pJsonsub, "ownerId",    pSensorBuff->owner_id);
-                cJSON_AddNumberToObject(pJsonsub, "ownerNun",   pSensorBuff->owner_lun);
-                cJSON_AddNumberToObject(pJsonsub, "sensorType", pSensorBuff->sensor_type);
-                cJSON_AddNumberToObject(pJsonsub, "sensorUnits1", pSensorBuff->sensor_units[0]);
-                cJSON_AddNumberToObject(pJsonsub, "sensorUnits2", pSensorBuff->sensor_units[1]);
-                cJSON_AddNumberToObject(pJsonsub, "sensorUnits3", pSensorBuff->sensor_units[2]);
-                cJSON_AddNumberToObject(pJsonsub, "rawReading", pSensorBuff->raw_reading);
-                cJSON_AddNumberToObject(pJsonsub, "sensorState", pSensorBuff->sensor_state);
-                cJSON_AddNumberToObject(pJsonsub, "discreteState", pSensorBuff->discrete_state);
-                cJSON_AddNumberToObject(pJsonsub, "SensorAccessibleFlags", pSensorBuff->SensorAccessibleFlags); 
-                cJSON_AddNumberToObject(pJsonsub, "reading", reading);      /* 给对象增加内容 */    
-                cJSON_AddNumberToObject(pJsonsub, "lownr", lownr);                                        
-                cJSON_AddNumberToObject(pJsonsub, "lowct", lowct);                                                         
-                cJSON_AddNumberToObject(pJsonsub, "highnc", highnc);                 
-                cJSON_AddNumberToObject(pJsonsub, "highct", highct);   
-                cJSON_AddNumberToObject(pJsonsub, "highnr", highnr);  
-
+                //cJSON_AddNumberToObject(pJsonsub, "ownerId",    pSensorBuff->owner_id);
+                //cJSON_AddNumberToObject(pJsonsub, "ownerNun",   pSensorBuff->owner_lun);
+                //cJSON_AddNumberToObject(pJsonsub, "sensorType", pSensorBuff->sensor_type);
+                // cJSON_AddNumberToObject(pJsonsub, "sensorUnits1", pSensorBuff->sensor_units[0]);
+                // cJSON_AddNumberToObject(pJsonsub, "sensorUnits2", pSensorBuff->sensor_units[1]);
+                // cJSON_AddNumberToObject(pJsonsub, "sensorUnits3", pSensorBuff->sensor_units[2]);
+
+                //cJSON_AddNumberToObject(pJsonsub, "rawReading", pSensorBuff->raw_reading);
+                //cJSON_AddNumberToObject(pJsonsub, "sensorState", pSensorBuff->sensor_state);
+                //cJSON_AddNumberToObject(pJsonsub, "discreteState", pSensorBuff->discrete_state);
+                //cJSON_AddNumberToObject(pJsonsub, "SensorAccessibleFlags", pSensorBuff->SensorAccessibleFlags); 
+                cJSON_AddStringToObject(pJsonsub, "reading", reading);      /* 给对象增加内容 */    
+                cJSON_AddStringToObject(pJsonsub, "lownr", lownr);                                        
+                cJSON_AddStringToObject(pJsonsub, "lowct", lowct);                                                         
+                cJSON_AddStringToObject(pJsonsub, "highnc", highnc);                 
+                cJSON_AddStringToObject(pJsonsub, "highct", highct);   
+                cJSON_AddStringToObject(pJsonsub, "highnr", highnr);  
+
+                switch(pSensorBuff->sensor_units[1])    //sensorUinits2
+                {
+                case 0: cJSON_AddStringToObject(pJsonsub, "Unit", "unspecified"); break;                    
+                case 1: cJSON_AddStringToObject(pJsonsub, "Unit", "degree C"); break;
+                case 2: cJSON_AddStringToObject(pJsonsub, "Unit", "degree F"); break;
+                case 3: cJSON_AddStringToObject(pJsonsub, "Unit", "degree K"); break;
+                case 4: cJSON_AddStringToObject(pJsonsub, "Unit", "Volts"); break;
+                case 5: cJSON_AddStringToObject(pJsonsub, "Unit", "Amps"); break;
+                case 6: cJSON_AddStringToObject(pJsonsub, "Unit", "Watts"); break;
+                case 18: cJSON_AddStringToObject(pJsonsub, "Unit", "RPM"); break;
+                default: cJSON_AddStringToObject(pJsonsub, "Unit", "unknown"); break;
+                }
+
+                switch(pSensorBuff->sensor_state)
+                {
+                case 0x1:  cJSON_AddStringToObject(pJsonsub, "State", "ok"); break;
+                case 0x2:  cJSON_AddStringToObject(pJsonsub, "State", "Upper Non-Critical"); break;    
+                case 0x4:  cJSON_AddStringToObject(pJsonsub, "State", "Upper Critical Threshold"); break;    
+                case 0x8:  cJSON_AddStringToObject(pJsonsub, "State", "Lower Non-Critical"); break;    
+                case 0x10:  cJSON_AddStringToObject(pJsonsub, "State", "Lower Critical"); break;    
+                case 0x20:  cJSON_AddStringToObject(pJsonsub, "State", "Access failed"); break;    
+                case 0x40:  cJSON_AddStringToObject(pJsonsub, "State", "Upper Non-Recoverable"); break;    
+                case 0x80:  cJSON_AddStringToObject(pJsonsub, "State", "Lower Non-Recoverable"); break;    
+                default:  cJSON_AddNumberToObject(pJsonsub, "State", pSensorBuff->sensor_state); break;      
+                }
+                
                 pSensorBuff++;
                 nSensors--;
             }
@@ -294,6 +323,7 @@ void getSensorInfo(Webs *wp){
             // pStr = cJSON_Print(pJsonArry);
             cJSON_AddItemToObject(root, "data", pJsonArry);
             pStr = cJSON_PrintUnformatted(root);
+            printf("---> pStr %d: %s\n", strlen(pStr), pStr);
 
             websSetStatus(wp, 200);
             websWriteHeaders(wp, -1, 0);
@@ -303,6 +333,9 @@ void getSensorInfo(Webs *wp){
             //websWrite(wp, "]");
             //websFlush(wp, 0);
             websDone(wp);
+
+            if(root)
+                cJSON_Delete(root);
           
         }
     }
@@ -310,7 +343,6 @@ void getSensorInfo(Webs *wp){
 error_out:
     if(pStartBuff)
         free(pStartBuff);
-
     
 }
 
@@ -331,6 +363,11 @@ void buy(Webs *wp)
     websWrite(wp, "age %s", age); 
     websFlush(wp, 0);
     websDone(wp);
+
+    if(name)
+        wfree(name);
+    if(age)
+        wfree(age);
 }