|
@@ -99,6 +99,11 @@ void GetAllSELEntriesSorted(Webs *wp)
|
|
senNumNameTab[i].sensor_name[0] = '\0';
|
|
senNumNameTab[i].sensor_name[0] = '\0';
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ websSetStatus(wp, 200);
|
|
|
|
+ websWriteHeaders(wp, -1, 0);
|
|
|
|
+ websWriteEndHeaders(wp);
|
|
|
|
+ websWrite(wp, "{\"data\":[");
|
|
|
|
+
|
|
//Create session
|
|
//Create session
|
|
LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
|
|
LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
|
|
|
@@ -125,19 +130,20 @@ void GetAllSELEntriesSorted(Webs *wp)
|
|
{
|
|
{
|
|
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);
|
|
|
|
|
|
+ // char *pStr;
|
|
|
|
+ // pStr = cJSON_PrintUnformatted(root);
|
|
|
|
+ // websSetStatus(wp, 200);
|
|
|
|
+ // websWriteHeaders(wp, -1, 0);
|
|
|
|
+ // websWriteEndHeaders(wp);
|
|
|
|
+ // websWrite(wp, pStr);
|
|
|
|
+ websWrite(wp, "]}");
|
|
websFlush(wp, 0);
|
|
websFlush(wp, 0);
|
|
websDone(wp);
|
|
websDone(wp);
|
|
|
|
|
|
- if(root)
|
|
|
|
- cJSON_Delete(root);
|
|
|
|
- if(pStr)
|
|
|
|
- wfree(pStr);
|
|
|
|
|
|
+ // if(root)
|
|
|
|
+ // cJSON_Delete(root);
|
|
|
|
+ // if(pStr)
|
|
|
|
+ // wfree(pStr);
|
|
|
|
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -165,6 +171,10 @@ void GetAllSELEntriesSorted(Webs *wp)
|
|
RecID = 0; //first record
|
|
RecID = 0; //first record
|
|
for(i=0;i<nEntries;i++)
|
|
for(i=0;i<nEntries;i++)
|
|
{
|
|
{
|
|
|
|
+ if(i!=0)
|
|
|
|
+ {
|
|
|
|
+ websWrite(wp, ",");
|
|
|
|
+ }
|
|
//获取日志
|
|
//获取日志
|
|
GetSelReq.ReservationID = ReserveID;
|
|
GetSelReq.ReservationID = ReserveID;
|
|
GetSelReq.RecID = RecID;
|
|
GetSelReq.RecID = RecID;
|
|
@@ -182,18 +192,23 @@ void GetAllSELEntriesSorted(Webs *wp)
|
|
{
|
|
{
|
|
break;
|
|
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_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);
|
|
//printf("sensor number %d\n", SELEventData.SensorNum);
|
|
@@ -206,9 +221,9 @@ void GetAllSELEntriesSorted(Webs *wp)
|
|
break;
|
|
break;
|
|
|
|
|
|
if(senNumNameTab[i].sensor_number == SELEventData.SensorNum)
|
|
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;
|
|
found_flag = 1;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -225,7 +240,8 @@ void GetAllSELEntriesSorted(Webs *wp)
|
|
{
|
|
{
|
|
wRet = IPMC_GetSensorName(&UDSSession, target_addr,SELEventData.SensorNum, sensorName, DEFAULT_TIMEOUT);
|
|
wRet = IPMC_GetSensorName(&UDSSession, target_addr,SELEventData.SensorNum, sensorName, DEFAULT_TIMEOUT);
|
|
}
|
|
}
|
|
- 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)
|
|
if(wRet == 0)
|
|
{
|
|
{
|
|
//将得到的传感器名称保存到缓存中
|
|
//将得到的传感器名称保存到缓存中
|
|
@@ -243,13 +259,14 @@ void GetAllSELEntriesSorted(Webs *wp)
|
|
}
|
|
}
|
|
else
|
|
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
|
|
if(RecID == 0xffff) //last record
|
|
break;
|
|
break;
|
|
|
|
|
|
- usleep(1);
|
|
|
|
|
|
+ //usleep(1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -257,22 +274,17 @@ void GetAllSELEntriesSorted(Webs *wp)
|
|
//Close session
|
|
//Close session
|
|
LIBIPMI_CloseSession(&UDSSession );
|
|
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);
|
|
websFlush(wp, 0);
|
|
websDone(wp);
|
|
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)
|
|
if(pSELBuff)
|
|
wfree(pSELBuff);
|
|
wfree(pSELBuff);
|
|
|
|
|
|
@@ -282,10 +294,10 @@ error_out:
|
|
//Close session
|
|
//Close session
|
|
LIBIPMI_CloseSession(&UDSSession );
|
|
LIBIPMI_CloseSession(&UDSSession );
|
|
websError(wp, 404, "Get SEL error!");
|
|
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)
|
|
if(pSELBuff)
|
|
wfree(pSELBuff);
|
|
wfree(pSELBuff);
|
|
|
|
|