|
@@ -22,7 +22,6 @@ void Web_ClearSEL(Webs *wp)
|
|
|
//Create session
|
|
|
LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
|
|
|
-// wp->index = TEST_INDEX;
|
|
|
target_addr = gIPMBAddr[wp->index];
|
|
|
if(target_addr == 0x20)
|
|
|
{
|
|
@@ -57,7 +56,6 @@ void Web_ClearSEL(Webs *wp)
|
|
|
websWrite(wp, "%s", pStr);
|
|
|
websFlush(wp, 0);
|
|
|
websDone(wp);
|
|
|
- printf("cJSON:%s\n", pStr);
|
|
|
|
|
|
if(pStr)
|
|
|
wfree(pStr);
|
|
@@ -101,10 +99,14 @@ void GetAllSELEntriesSorted(Webs *wp)
|
|
|
senNumNameTab[i].sensor_name[0] = '\0';
|
|
|
}
|
|
|
|
|
|
+ websSetStatus(wp, 200);
|
|
|
+ websWriteHeaders(wp, -1, 0);
|
|
|
+ websWriteEndHeaders(wp);
|
|
|
+ websWrite(wp, "{\"data\":[");
|
|
|
+
|
|
|
//Create session
|
|
|
LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
|
|
|
-// wp->index = TEST_INDEX;
|
|
|
target_addr = gIPMBAddr[wp->index];
|
|
|
if(target_addr == 0x20)
|
|
|
{
|
|
@@ -123,26 +125,25 @@ void GetAllSELEntriesSorted(Webs *wp)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- //printf("---> nEntries %d\n", nEntries);
|
|
|
if(nEntries > MAX_SEL_RECORD) nEntries = MAX_SEL_RECORD; //最大只能显示这么多日志
|
|
|
if(nEntries == 0)
|
|
|
{
|
|
|
cJSON_AddItemToObject(root, "data", pJsonArry);
|
|
|
|
|
|
- char *pStr;
|
|
|
- pStr = cJSON_PrintUnformatted(root);
|
|
|
- websSetStatus(wp, 200);
|
|
|
- websWriteHeaders(wp, -1, 0);
|
|
|
- websWriteEndHeaders(wp);
|
|
|
- websWrite(wp, pStr);
|
|
|
+ // char *pStr;
|
|
|
+ // pStr = cJSON_PrintUnformatted(root);
|
|
|
+ // websSetStatus(wp, 200);
|
|
|
+ // websWriteHeaders(wp, -1, 0);
|
|
|
+ // websWriteEndHeaders(wp);
|
|
|
+ // websWrite(wp, pStr);
|
|
|
+ websWrite(wp, "]}");
|
|
|
websFlush(wp, 0);
|
|
|
websDone(wp);
|
|
|
- printf("cJSON:%s\n", pStr);
|
|
|
|
|
|
- if(root)
|
|
|
- cJSON_Delete(root);
|
|
|
- if(pStr)
|
|
|
- wfree(pStr);
|
|
|
+ // if(root)
|
|
|
+ // cJSON_Delete(root);
|
|
|
+ // if(pStr)
|
|
|
+ // wfree(pStr);
|
|
|
|
|
|
return;
|
|
|
}
|
|
@@ -170,6 +171,10 @@ void GetAllSELEntriesSorted(Webs *wp)
|
|
|
RecID = 0; //first record
|
|
|
for(i=0;i<nEntries;i++)
|
|
|
{
|
|
|
+ if(i!=0)
|
|
|
+ {
|
|
|
+ websWrite(wp, ",");
|
|
|
+ }
|
|
|
//获取日志
|
|
|
GetSelReq.ReservationID = ReserveID;
|
|
|
GetSelReq.RecID = RecID;
|
|
@@ -187,31 +192,24 @@ void GetAllSELEntriesSorted(Webs *wp)
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
- cJSON_AddItemToArray(pJsonArry,pJsonsub=cJSON_CreateObject()); /* 给创建的数组增加对对象*/
|
|
|
- cJSON_AddNumberToObject(pJsonsub, "D1", SELEventData.hdr.ID); //RecordID -> D1
|
|
|
- cJSON_AddNumberToObject(pJsonsub, "D2", SELEventData.hdr.Type); //RecordType -> D2
|
|
|
- cJSON_AddNumberToObject(pJsonsub, "D3", SELEventData.hdr.TimeStamp); //TimeStamp -> D3
|
|
|
- cJSON_AddNumberToObject(pJsonsub, "D4", SELEventData.GenID[0]); //GenID1 -> D4
|
|
|
- cJSON_AddNumberToObject(pJsonsub, "D5", SELEventData.GenID[1]); //GenID2 -> D5
|
|
|
- cJSON_AddNumberToObject(pJsonsub, "D6", SELEventData.EvMRev); //EvmRev -> D6
|
|
|
- cJSON_AddNumberToObject(pJsonsub, "D7", SELEventData.SensorType); //SensorType -> D7
|
|
|
- cJSON_AddNumberToObject(pJsonsub, "D8", SELEventData.EvtDirType); //EventDirType -> D8
|
|
|
- cJSON_AddNumberToObject(pJsonsub, "D9", SELEventData.EvtData1); //EventData1 -> D9
|
|
|
- cJSON_AddNumberToObject(pJsonsub, "D10", SELEventData.EvtData2); //EventData2 -> D10
|
|
|
- cJSON_AddNumberToObject(pJsonsub, "D11", SELEventData.EvtData3); //EventData3 -> D11
|
|
|
-
|
|
|
- // cJSON_AddNumberToObject(pJsonsub, "RecordID", SELEventData.hdr.ID);
|
|
|
- // cJSON_AddNumberToObject(pJsonsub, "RecordType", SELEventData.hdr.Type);
|
|
|
- // cJSON_AddNumberToObject(pJsonsub, "TimeStamp", SELEventData.hdr.TimeStamp);
|
|
|
- // cJSON_AddNumberToObject(pJsonsub, "GenID1", SELEventData.GenID[0]);
|
|
|
- // cJSON_AddNumberToObject(pJsonsub, "GenID2", SELEventData.GenID[1]);
|
|
|
- // cJSON_AddNumberToObject(pJsonsub, "EvmRev", SELEventData.EvMRev);
|
|
|
- // cJSON_AddNumberToObject(pJsonsub, "SensorType", SELEventData.SensorType);
|
|
|
- // cJSON_AddNumberToObject(pJsonsub, "EventDirType", SELEventData.EvtDirType);
|
|
|
- // cJSON_AddNumberToObject(pJsonsub, "EventData1", SELEventData.EvtData1);
|
|
|
- // cJSON_AddNumberToObject(pJsonsub, "EventData2", SELEventData.EvtData2);
|
|
|
- // cJSON_AddNumberToObject(pJsonsub, "EventData3", SELEventData.EvtData3);
|
|
|
-
|
|
|
+ // cJSON_AddItemToArray(pJsonArry,pJsonsub=cJSON_CreateObject()); /* 给创建的数组增加对对象*/
|
|
|
+ // cJSON_AddNumberToObject(pJsonsub, "D1", SELEventData.hdr.ID); //RecordID -> D1
|
|
|
+ // cJSON_AddNumberToObject(pJsonsub, "D2", SELEventData.hdr.Type); //RecordType -> D2
|
|
|
+ // cJSON_AddNumberToObject(pJsonsub, "D3", SELEventData.hdr.TimeStamp); //TimeStamp -> D3
|
|
|
+ // cJSON_AddNumberToObject(pJsonsub, "D4", SELEventData.GenID[0]); //GenID1 -> D4
|
|
|
+ // cJSON_AddNumberToObject(pJsonsub, "D5", SELEventData.GenID[1]); //GenID2 -> D5
|
|
|
+ // cJSON_AddNumberToObject(pJsonsub, "D6", SELEventData.EvMRev); //EvmRev -> D6
|
|
|
+ // cJSON_AddNumberToObject(pJsonsub, "D7", SELEventData.SensorType); //SensorType -> D7
|
|
|
+ // cJSON_AddNumberToObject(pJsonsub, "D8", SELEventData.EvtDirType); //EventDirType -> D8
|
|
|
+ // cJSON_AddNumberToObject(pJsonsub, "D9", SELEventData.EvtData1); //EventData1 -> D9
|
|
|
+ // cJSON_AddNumberToObject(pJsonsub, "D10", SELEventData.EvtData2); //EventData2 -> D10
|
|
|
+ // cJSON_AddNumberToObject(pJsonsub, "D11", SELEventData.EvtData3); //EventData3 -> D11
|
|
|
+
|
|
|
+ websWrite(wp, "{\"D1\":%d,\"D2\":%d,\"D3\":%d,\"D4\":%d,\"D5\":%d,\"D6\":%d,\"D7\":%d,\"D8\":%d,\"D9\":%d,\"D10\":%d,\"D11\":%d,",
|
|
|
+ SELEventData.hdr.ID, SELEventData.hdr.Type, SELEventData.hdr.TimeStamp, SELEventData.GenID[0],
|
|
|
+ SELEventData.GenID[1], SELEventData.EvMRev, SELEventData.SensorType, SELEventData.EvtDirType,
|
|
|
+ SELEventData.EvtData1, SELEventData.EvtData2, SELEventData.EvtData3);
|
|
|
+
|
|
|
//获取传感器名称
|
|
|
//printf("sensor number %d\n", SELEventData.SensorNum);
|
|
|
if((SELEventData.SensorNum != 0xff) && (SELEventData.hdr.Type == 0x02))
|
|
@@ -223,9 +221,9 @@ void GetAllSELEntriesSorted(Webs *wp)
|
|
|
break;
|
|
|
|
|
|
if(senNumNameTab[i].sensor_number == SELEventData.SensorNum)
|
|
|
- {
|
|
|
- //cJSON_AddStringToObject(pJsonsub, "c", senNumNameTab[i].sensor_name);
|
|
|
- cJSON_AddStringToObject(pJsonsub, "D12", senNumNameTab[i].sensor_name); //SensorName -> D12
|
|
|
+ {
|
|
|
+ //cJSON_AddStringToObject(pJsonsub, "D12", senNumNameTab[i].sensor_name); //SensorName -> D12
|
|
|
+ websWrite(wp, "\"D12\":\"%s\"}", senNumNameTab[i].sensor_name);
|
|
|
found_flag = 1;
|
|
|
break;
|
|
|
}
|
|
@@ -242,8 +240,8 @@ void GetAllSELEntriesSorted(Webs *wp)
|
|
|
{
|
|
|
wRet = IPMC_GetSensorName(&UDSSession, target_addr,SELEventData.SensorNum, sensorName, DEFAULT_TIMEOUT);
|
|
|
}
|
|
|
- //cJSON_AddStringToObject(pJsonsub, "c", sensorName);
|
|
|
- cJSON_AddStringToObject(pJsonsub, "D12", senNumNameTab[i].sensor_name); //SensorName->D12
|
|
|
+ //cJSON_AddStringToObject(pJsonsub, "D12", senNumNameTab[i].sensor_name); //SensorName->D12
|
|
|
+ websWrite(wp, "\"D12\":\"%s\"}", senNumNameTab[i].sensor_name);
|
|
|
if(wRet == 0)
|
|
|
{
|
|
|
//将得到的传感器名称保存到缓存中
|
|
@@ -251,7 +249,6 @@ void GetAllSELEntriesSorted(Webs *wp)
|
|
|
{
|
|
|
if(senNumNameTab[i].sensor_number == 0xff)
|
|
|
{
|
|
|
- //printf("---> keep sensor name\n");
|
|
|
senNumNameTab[i].sensor_number = SELEventData.SensorNum;
|
|
|
strcpy(senNumNameTab[i].sensor_name, sensorName);
|
|
|
break;
|
|
@@ -262,13 +259,14 @@ void GetAllSELEntriesSorted(Webs *wp)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- cJSON_AddStringToObject(pJsonsub, "D12", "--"); //SensorName -> D12
|
|
|
+ //cJSON_AddStringToObject(pJsonsub, "D12", "--"); //SensorName -> D12
|
|
|
+ websWrite(wp, "\"D12\":\"%s\"}", senNumNameTab[i].sensor_name);
|
|
|
}
|
|
|
|
|
|
if(RecID == 0xffff) //last record
|
|
|
break;
|
|
|
|
|
|
- usleep(1);
|
|
|
+ //usleep(1);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -276,22 +274,17 @@ void GetAllSELEntriesSorted(Webs *wp)
|
|
|
//Close session
|
|
|
LIBIPMI_CloseSession(&UDSSession );
|
|
|
|
|
|
- cJSON_AddItemToObject(root, "data", pJsonArry);
|
|
|
+ //cJSON_AddItemToObject(root, "data", pJsonArry);
|
|
|
|
|
|
- char *pStr;
|
|
|
- pStr = cJSON_PrintUnformatted(root);
|
|
|
- websSetStatus(wp, 200);
|
|
|
- websWriteHeaders(wp, -1, 0);
|
|
|
- websWriteEndHeaders(wp);
|
|
|
- websWrite(wp, pStr);
|
|
|
+ websWrite(wp, "]}");
|
|
|
websFlush(wp, 0);
|
|
|
websDone(wp);
|
|
|
- printf("cJSON:%s\n",pStr);
|
|
|
+ //printf("cJSON:%s\n",pStr);
|
|
|
|
|
|
- if(root)
|
|
|
- cJSON_Delete(root);
|
|
|
- if(pStr)
|
|
|
- wfree(pStr);
|
|
|
+ // if(root)
|
|
|
+ // cJSON_Delete(root);
|
|
|
+ // if(pStr)
|
|
|
+ // wfree(pStr);
|
|
|
if(pSELBuff)
|
|
|
wfree(pSELBuff);
|
|
|
|
|
@@ -301,10 +294,10 @@ error_out:
|
|
|
//Close session
|
|
|
LIBIPMI_CloseSession(&UDSSession );
|
|
|
websError(wp, 404, "Get SEL error!");
|
|
|
- if(root)
|
|
|
- cJSON_Delete(root);
|
|
|
- if(pStr)
|
|
|
- wfree(pStr);
|
|
|
+ // if(root)
|
|
|
+ // cJSON_Delete(root);
|
|
|
+ // if(pStr)
|
|
|
+ // wfree(pStr);
|
|
|
if(pSELBuff)
|
|
|
wfree(pSELBuff);
|
|
|
|
|
@@ -331,7 +324,6 @@ void SetTime(Webs *wp)
|
|
|
//Create session
|
|
|
LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
|
|
|
-// wp->index = TEST_INDEX;
|
|
|
target_addr = gIPMBAddr[wp->index];
|
|
|
if(target_addr == 0x20)
|
|
|
{
|
|
@@ -382,7 +374,7 @@ void SetTime(Webs *wp)
|
|
|
websWrite(wp,"%s", pStr);
|
|
|
websFlush(wp, 0);
|
|
|
websDone(wp);
|
|
|
- printf("cJSON:%s\n", pStr);
|
|
|
+ //printf("cJSON:%s\n", pStr);
|
|
|
|
|
|
if(pStr)
|
|
|
wfree(pStr);
|
|
@@ -403,7 +395,6 @@ void GetTime(Webs *wp)
|
|
|
//Create session
|
|
|
LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
|
|
|
-// wp->index = TEST_INDEX;
|
|
|
target_addr = gIPMBAddr[wp->index];
|
|
|
if(target_addr == 0x20)
|
|
|
{
|
|
@@ -456,7 +447,7 @@ void GetTime(Webs *wp)
|
|
|
websWrite(wp,"%s", pStr);
|
|
|
websFlush(wp, 0);
|
|
|
websDone(wp);
|
|
|
- printf("cJSON:%s\n", pStr);
|
|
|
+ //printf("cJSON:%s\n", pStr);
|
|
|
|
|
|
if(pStr)
|
|
|
wfree(pStr);
|