|
@@ -23,10 +23,11 @@ void getFruChassisInfo(Webs *wp)
|
|
|
{
|
|
|
int wRet = 0;
|
|
|
uint32_t fru_size;
|
|
|
- OemFRUChassisInfo_T chassis_data;
|
|
|
+ OemFRUChassisInfo_T *pChassis_data = walloc(sizeof(OemFRUChassisInfo_T));
|
|
|
uint8_t fruIndex = 1; //FRUDeviceID
|
|
|
char *pTmpStr = NULL;
|
|
|
uint8_t strLen = 0;
|
|
|
+ uint8_t target_addr;
|
|
|
|
|
|
char *_chassisPartNum=NULL;
|
|
|
char *_chassisSerialNum=NULL;
|
|
@@ -36,7 +37,17 @@ void getFruChassisInfo(Webs *wp)
|
|
|
|
|
|
//Create session
|
|
|
LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
- wRet = LIBIPMI_HL_GetFRUChassisData(&UDSSession,fruIndex,&fru_size,&chassis_data,DEFAULT_TIMEOUT);
|
|
|
+ wp->index = TEST_INDEX;
|
|
|
+ target_addr = gIPMBAddr[wp->index];
|
|
|
+ if(target_addr == 0x20)
|
|
|
+ {
|
|
|
+ wRet = LIBIPMI_HL_GetFRUChassisData(&UDSSession,fruIndex,&fru_size,pChassis_data,DEFAULT_TIMEOUT);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ wRet = IPMC_GetFRUChassisData(&UDSSession,target_addr, fruIndex,&fru_size,pChassis_data,DEFAULT_TIMEOUT);
|
|
|
+ }
|
|
|
+
|
|
|
if(wRet==FRU_INVALID_HEADER_VERSION)
|
|
|
{
|
|
|
printf("Invalid FRU Header Version for ID : %d\n", fruIndex);
|
|
@@ -52,15 +63,9 @@ void getFruChassisInfo(Webs *wp)
|
|
|
//Close session
|
|
|
LIBIPMI_CloseSession(&UDSSession );
|
|
|
|
|
|
- int i;
|
|
|
- uint8_t *pDebug = (uint8_t*)&chassis_data;
|
|
|
- printf("chassis_info %d: ", fru_size);
|
|
|
- for(i=0;i<fru_size;i++)
|
|
|
- printf("%#x ", pDebug[i]);
|
|
|
- printf("\n");
|
|
|
//_chassisPartNum
|
|
|
- strLen = chassis_data.Data[0] & 0x3F;
|
|
|
- pTmpStr = &chassis_data.Data[1];
|
|
|
+ strLen = pChassis_data->Data[0] & 0x3F;
|
|
|
+ pTmpStr = &pChassis_data->Data[1];
|
|
|
_chassisPartNum = walloc(strLen+1);
|
|
|
memset(_chassisPartNum, 0, strLen+1);
|
|
|
strncpy(_chassisPartNum, pTmpStr, strLen);
|
|
@@ -84,7 +89,7 @@ void getFruChassisInfo(Webs *wp)
|
|
|
//_chassisType
|
|
|
_chassisType = walloc(30);
|
|
|
memset(_chassisType, 0, 30);
|
|
|
- switch(chassis_data.ChassisType)
|
|
|
+ switch(pChassis_data->ChassisType)
|
|
|
{
|
|
|
case Other:
|
|
|
strcpy(_chassisType, "Other");
|
|
@@ -152,7 +157,7 @@ void getFruChassisInfo(Webs *wp)
|
|
|
}
|
|
|
|
|
|
|
|
|
- char *pStr;
|
|
|
+
|
|
|
cJSON * root = cJSON_CreateObject();
|
|
|
cJSON * data = cJSON_CreateObject();
|
|
|
cJSON_AddItemToObject(root, "data", data);
|
|
@@ -165,19 +170,15 @@ void getFruChassisInfo(Webs *wp)
|
|
|
cJSON_AddStringToObject(data, "SN", _chassisSerialNum);
|
|
|
cJSON_AddStringToObject(data, "OEM", _chassisCustomField);
|
|
|
|
|
|
+ char *pStr;
|
|
|
pStr = cJSON_PrintUnformatted(root);
|
|
|
-
|
|
|
websSetStatus(wp, 200);
|
|
|
websWriteHeaders(wp, -1, 0); //Set length to -1 if unknown and transfer-chunk-encoding will be employed.
|
|
|
websWriteEndHeaders(wp);
|
|
|
- int ret;
|
|
|
websWrite(wp, "%s", pStr);
|
|
|
- //printf("---> cJSON Str: %d \n%s\n", strlen(pStr), pStr);
|
|
|
- ret = websFlush(wp, 1); //wait for all data to be written to the socket
|
|
|
- if(ret != 1)
|
|
|
- printf("websFlush ret = %d\n", ret);
|
|
|
-
|
|
|
+ websFlush(wp, 0); //wait for all data to be written to the socket
|
|
|
websDone(wp);
|
|
|
+ printf("---> cJSON Str: %d \n%s\n", strlen(pStr), pStr);
|
|
|
|
|
|
if(pStr)
|
|
|
wfree(pStr);
|
|
@@ -188,8 +189,8 @@ void getFruChassisInfo(Webs *wp)
|
|
|
if(_chassisSerialNum) wfree(_chassisSerialNum);
|
|
|
if(_chassisType) wfree(_chassisType);
|
|
|
if(_chassisCustomField) wfree(_chassisCustomField);
|
|
|
+ if(pChassis_data) wfree(pChassis_data);
|
|
|
|
|
|
- printf("getFruChassisInfo over!\n");
|
|
|
}
|
|
|
|
|
|
void getFruBoardInfo(Webs *wp)
|
|
@@ -201,7 +202,8 @@ void getFruBoardInfo(Webs *wp)
|
|
|
char *pTmpStr = NULL;
|
|
|
uint8_t strLen = 0;
|
|
|
time_t tval;
|
|
|
- //char *mfrdate = NULL;
|
|
|
+ uint8_t target_addr;
|
|
|
+
|
|
|
static const uint32_t secs_from_1970_1996 = 820450800;
|
|
|
|
|
|
char *_boardMfr=NULL;
|
|
@@ -215,7 +217,18 @@ void getFruBoardInfo(Webs *wp)
|
|
|
|
|
|
//Create session
|
|
|
LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
- wRet = LIBIPMI_HL_GetFRUBoardData(&UDSSession,fruIndex,&fru_size,&board_data,DEFAULT_TIMEOUT);
|
|
|
+
|
|
|
+ wp->index = TEST_INDEX;
|
|
|
+ target_addr = gIPMBAddr[wp->index];
|
|
|
+ if(target_addr == 0x20)
|
|
|
+ {
|
|
|
+ wRet = LIBIPMI_HL_GetFRUBoardData(&UDSSession,fruIndex,&fru_size,&board_data,DEFAULT_TIMEOUT);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ wRet = IPMC_GetFRUBoardData(&UDSSession,target_addr, fruIndex,&fru_size,&board_data,DEFAULT_TIMEOUT);
|
|
|
+ }
|
|
|
+
|
|
|
if(wRet==FRU_INVALID_HEADER_VERSION)
|
|
|
{
|
|
|
printf("Invalid FRU Header Version for ID : %d\n", fruIndex);
|
|
@@ -281,7 +294,7 @@ void getFruBoardInfo(Webs *wp)
|
|
|
tval = tval + secs_from_1970_1996;
|
|
|
_MfrDate = asctime(localtime(&tval));
|
|
|
|
|
|
- char *pStr;
|
|
|
+
|
|
|
cJSON * root = cJSON_CreateObject();
|
|
|
cJSON * data = cJSON_CreateObject();
|
|
|
cJSON_AddItemToObject(root, "data", data);
|
|
@@ -296,19 +309,15 @@ void getFruBoardInfo(Webs *wp)
|
|
|
cJSON_AddStringToObject(data, "PN", _boardPartNum);
|
|
|
cJSON_AddStringToObject(data, "OEM", _boardCustomField);
|
|
|
|
|
|
+ char *pStr;
|
|
|
pStr = cJSON_PrintUnformatted(root);
|
|
|
-
|
|
|
websSetStatus(wp, 200);
|
|
|
websWriteHeaders(wp, -1, 0); //Set length to -1 if unknown and transfer-chunk-encoding will be employed.
|
|
|
websWriteEndHeaders(wp);
|
|
|
- int ret;
|
|
|
- websWrite(wp, "%s", pStr);
|
|
|
- //printf("---> cJSON Str: %d \n%s\n", strlen(pStr), pStr);
|
|
|
- ret = websFlush(wp, 1); //wait for all data to be written to the socket
|
|
|
- if(ret != 1)
|
|
|
- printf("websFlush ret = %d\n", ret);
|
|
|
-
|
|
|
+ websWrite(wp, "%s", pStr);
|
|
|
+ websFlush(wp, 0); //wait for all data to be written to the socket
|
|
|
websDone(wp);
|
|
|
+ printf("---> cJSON Str: %d \n%s\n", strlen(pStr), pStr);
|
|
|
|
|
|
if(pStr)
|
|
|
wfree(pStr);
|
|
@@ -321,8 +330,6 @@ void getFruBoardInfo(Webs *wp)
|
|
|
if(_boardPartNum) wfree(_boardPartNum);
|
|
|
if(_boardCustomField) wfree(_boardCustomField);
|
|
|
if(_MfrDate) wfree(_MfrDate);
|
|
|
-
|
|
|
- printf("getFruChassisInfo over!\n");
|
|
|
|
|
|
}
|
|
|
|
|
@@ -334,6 +341,7 @@ void getFruProductInfo(Webs *wp)
|
|
|
uint8_t fruIndex = 1; //FRUDeviceID
|
|
|
char *pTmpStr = NULL;
|
|
|
uint8_t strLen = 0;
|
|
|
+ uint8_t target_addr;
|
|
|
|
|
|
char *_ProductName=NULL;
|
|
|
char *_ProductPartNum=NULL;
|
|
@@ -345,7 +353,16 @@ void getFruProductInfo(Webs *wp)
|
|
|
|
|
|
//Create session
|
|
|
LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
- wRet = LIBIPMI_HL_GetFRUProductData(&UDSSession,fruIndex,&fru_size,&product_data,DEFAULT_TIMEOUT);
|
|
|
+ wp->index = TEST_INDEX;
|
|
|
+ target_addr = gIPMBAddr[wp->index];
|
|
|
+ if(target_addr == 0x20)
|
|
|
+ {
|
|
|
+ wRet = LIBIPMI_HL_GetFRUProductData(&UDSSession,fruIndex,&fru_size,&product_data,DEFAULT_TIMEOUT);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ wRet = IPMC_GetFRUProductData(&UDSSession,target_addr, fruIndex,&fru_size,&product_data,DEFAULT_TIMEOUT);
|
|
|
+ }
|
|
|
if(wRet==FRU_INVALID_HEADER_VERSION)
|
|
|
{
|
|
|
printf("Invalid FRU Header Version for ID : %d\n", fruIndex);
|
|
@@ -404,17 +421,11 @@ void getFruProductInfo(Webs *wp)
|
|
|
pTmpStr += strLen;
|
|
|
strLen = pTmpStr[0] & 0x3F;
|
|
|
pTmpStr++;
|
|
|
- // _AssetTag = walloc(strLen+1);
|
|
|
- // memset(_AssetTag, 0, strLen+1);
|
|
|
- // strncpy(_AssetTag, pTmpStr, strLen);
|
|
|
|
|
|
//File ID
|
|
|
pTmpStr += strLen;
|
|
|
strLen = pTmpStr[0] & 0x3F;
|
|
|
pTmpStr++;
|
|
|
- // _FRUFileID = walloc(strLen+1);
|
|
|
- // memset(_FRUFileID, 0, strLen+1);
|
|
|
- // strncpy(_FRUFileID, pTmpStr, strLen);
|
|
|
|
|
|
//Extra info
|
|
|
pTmpStr += strLen;
|
|
@@ -424,7 +435,6 @@ void getFruProductInfo(Webs *wp)
|
|
|
memset(_productCustomField, 0, strLen+1);
|
|
|
strncpy(_productCustomField, pTmpStr, strLen);
|
|
|
|
|
|
- char *pStr;
|
|
|
cJSON * root = cJSON_CreateObject();
|
|
|
cJSON * data = cJSON_CreateObject();
|
|
|
cJSON_AddItemToObject(root, "data", data);
|
|
@@ -436,19 +446,16 @@ void getFruProductInfo(Webs *wp)
|
|
|
cJSON_AddStringToObject(data, "Ver", _ProductVersion);
|
|
|
cJSON_AddStringToObject(data, "SN", _ProductSerialNum);
|
|
|
cJSON_AddStringToObject(data, "OEM", _productCustomField);
|
|
|
+
|
|
|
+ char *pStr;
|
|
|
pStr = cJSON_PrintUnformatted(root);
|
|
|
-
|
|
|
websSetStatus(wp, 200);
|
|
|
websWriteHeaders(wp, -1, 0); //Set length to -1 if unknown and transfer-chunk-encoding will be employed.
|
|
|
websWriteEndHeaders(wp);
|
|
|
- int ret;
|
|
|
websWrite(wp, "%s", pStr);
|
|
|
- //printf("---> cJSON Str: %d \n%s\n", strlen(pStr), pStr);
|
|
|
- ret = websFlush(wp, 1); //wait for all data to be written to the socket
|
|
|
- if(ret != 1)
|
|
|
- printf("websFlush ret = %d\n", ret);
|
|
|
-
|
|
|
+ websFlush(wp, 0);
|
|
|
websDone(wp);
|
|
|
+ printf("---> cJSON Str: %d \n%s\n", strlen(pStr), pStr);
|
|
|
|
|
|
if(pStr)
|
|
|
wfree(pStr);
|
|
@@ -461,354 +468,5 @@ void getFruProductInfo(Webs *wp)
|
|
|
if(_ProductVersion) wfree(_ProductVersion);
|
|
|
if(_ProductSerialNum) wfree(_ProductSerialNum);
|
|
|
if(_productCustomField) wfree(_productCustomField);
|
|
|
-
|
|
|
- printf("getFruChassisInfo over!\n");
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-// /*获取FRU信息*/
|
|
|
-// void getFruInfo(Webs *wp)
|
|
|
-// {
|
|
|
-// int wRet = 0;
|
|
|
-// uint32_t fru_size;
|
|
|
-// OemFRUData_T fru_data;
|
|
|
-// uint8_t fruIndex = 1; //FRUDeviceID
|
|
|
-// char *pTmpStr = NULL;
|
|
|
-// uint8_t strLen = 0;
|
|
|
-
|
|
|
-// time_t tval;
|
|
|
-// //char *mfrdate = NULL;
|
|
|
-// static const uint32_t secs_from_1970_1996 = 820450800;
|
|
|
-
|
|
|
-// char *_chassisPartNum=NULL;
|
|
|
-// char *_chassisSerialNum=NULL;
|
|
|
-// char *_chassisType=NULL;
|
|
|
-// char *_chassisCustomField=NULL;
|
|
|
-// char *_boardMfr=NULL;
|
|
|
-// char *_boardProductName=NULL;
|
|
|
-// char *_boardSerialNum=NULL;
|
|
|
-// char *_boardPartNum=NULL;
|
|
|
-// char *_boardCustomField=NULL;
|
|
|
-// char *_MfrName=NULL;
|
|
|
-// char *_MfrDate = NULL;
|
|
|
-// char *_ProductName=NULL;
|
|
|
-// char *_ProductPartNum=NULL;
|
|
|
-// char *_ProductVersion=NULL;
|
|
|
-// char *_ProductSerialNum=NULL;
|
|
|
-// char *_productCustomField=NULL;
|
|
|
-// IPMI20_UDS_SESSION_T UDSSession;
|
|
|
-
|
|
|
-// //Create session
|
|
|
-// LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
-// wRet = LIBIPMI_HL_GetFRUData(&UDSSession,fruIndex,&fru_size,&fru_data,DEFAULT_TIMEOUT);
|
|
|
-// if(wRet==FRU_INVALID_HEADER_VERSION)
|
|
|
-// {
|
|
|
-// printf("Invalid FRU Header Version for ID : %d\n", fruIndex);
|
|
|
-// }
|
|
|
-// if(wRet==FRU_INVALID_AREA)
|
|
|
-// {
|
|
|
-// printf("FRU Invalid Area for ID : %d\n", fruIndex);
|
|
|
-// }
|
|
|
-// if(wRet!=0)
|
|
|
-// {
|
|
|
-// printf("Device not present for ID : %d\n", fruIndex);
|
|
|
-// }
|
|
|
-// //Close session
|
|
|
-// LIBIPMI_CloseSession(&UDSSession );
|
|
|
-
|
|
|
-// //Get ChassisInfo
|
|
|
-// if(fru_data.CommonHeader.ChassisInfoAreaStartOffset != 0)
|
|
|
-// {
|
|
|
-// //_chassisPartNum
|
|
|
-// strLen = fru_data.ChassisInfo.Data[0] & 0x3F;
|
|
|
-// pTmpStr = &fru_data.ChassisInfo.Data[1];
|
|
|
-// _chassisPartNum = walloc(strLen+1);
|
|
|
-// memset(_chassisPartNum, 0, strLen+1);
|
|
|
-// strncpy(_chassisPartNum, pTmpStr, strLen);
|
|
|
-
|
|
|
-// //_chassisSerialNum
|
|
|
-// pTmpStr += strLen;
|
|
|
-// strLen = pTmpStr[0] & 0x3F;
|
|
|
-// pTmpStr++;
|
|
|
-// _chassisSerialNum = walloc(strLen+1);
|
|
|
-// memset(_chassisSerialNum, 0, strLen+1);
|
|
|
-// strncpy(_chassisSerialNum, pTmpStr, strLen);
|
|
|
-
|
|
|
-// //extra info
|
|
|
-// pTmpStr += strLen;
|
|
|
-// strLen = pTmpStr[0] & 0x3F;
|
|
|
-// pTmpStr++;
|
|
|
-// _chassisCustomField = walloc(strLen+1);
|
|
|
-// memset(_chassisCustomField, 0, strLen+1);
|
|
|
-// strncpy(_chassisCustomField, pTmpStr, strLen);
|
|
|
-
|
|
|
-// //_chassisType
|
|
|
-// _chassisType = walloc(30);
|
|
|
-// memset(_chassisType, 0, 30);
|
|
|
-// switch(fru_data.ChassisInfo.ChassisType)
|
|
|
-// {
|
|
|
-// case Other:
|
|
|
-// strcpy(_chassisType, "Other");
|
|
|
-// break;
|
|
|
-// case ChassisUnknown:
|
|
|
-// strcpy(_chassisType, "ChassisUnknown");
|
|
|
-// break;
|
|
|
-// case Desktop:
|
|
|
-// strcpy(_chassisType, "Desktop");
|
|
|
-// break;
|
|
|
-// case LowProfileDesktop:
|
|
|
-// strcpy(_chassisType, "LowProfileDesktop");
|
|
|
-// break;
|
|
|
-// case MiniTower:
|
|
|
-// strcpy(_chassisType, "MiniTower");
|
|
|
-// break;
|
|
|
-// case Tower:
|
|
|
-// strcpy(_chassisType, "Tower");
|
|
|
-// break;
|
|
|
-// case Portable:
|
|
|
-// strcpy(_chassisType, "Portable");
|
|
|
-// break;
|
|
|
-// case Notebook:
|
|
|
-// strcpy(_chassisType, "Notebook");
|
|
|
-// break;
|
|
|
-// case HandHeld:
|
|
|
-// strcpy(_chassisType, "HandHeld");
|
|
|
-// break;
|
|
|
-// case DockingStation:
|
|
|
-// strcpy(_chassisType, "DockingStation");
|
|
|
-// break;
|
|
|
-// case AllinOne:
|
|
|
-// strcpy(_chassisType, "AllinOne");
|
|
|
-// break;
|
|
|
-// case SubNotebook:
|
|
|
-// strcpy(_chassisType, "SubNotebook");
|
|
|
-// break;
|
|
|
-// case SpaceSaving:
|
|
|
-// strcpy(_chassisType, "SpaceSaving");
|
|
|
-// break;
|
|
|
-// case LunchBox:
|
|
|
-// strcpy(_chassisType, "LunchBox");
|
|
|
-// break;
|
|
|
-// case MainServerChassis:
|
|
|
-// strcpy(_chassisType, "MainServerChassis");
|
|
|
-// break;
|
|
|
-// case SubChassis:
|
|
|
-// strcpy(_chassisType, "SubChassis");
|
|
|
-// break;
|
|
|
-// case BusExpansionChassis:
|
|
|
-// strcpy(_chassisType, "BusExpansionChassis");
|
|
|
-// break;
|
|
|
-// case PeripheralChassis:
|
|
|
-// strcpy(_chassisType, "PeripheralChassis");
|
|
|
-// break;
|
|
|
-// case RAIDChassis:
|
|
|
-// strcpy(_chassisType, "RAIDChassis");
|
|
|
-// break;
|
|
|
-// case RackMountChassis:
|
|
|
-// strcpy(_chassisType, "RackMountChassis");
|
|
|
-// break;
|
|
|
-// default:
|
|
|
-// strcpy(_chassisType, "Unknown");
|
|
|
-// break;
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-// //Get BoardInfo
|
|
|
-// if(fru_data.CommonHeader.BoardInfoAreaStartOffset != 0)
|
|
|
-// {
|
|
|
-// //Manufactor
|
|
|
-// strLen = fru_data.BoardInfo.Data[0] & 0x3F;
|
|
|
-// pTmpStr = &fru_data.BoardInfo.Data[1];
|
|
|
-// _boardMfr = walloc(strLen+1);
|
|
|
-// memset(_boardMfr, 0, strLen+1);
|
|
|
-// strncpy(_boardMfr, pTmpStr, strLen);
|
|
|
-
|
|
|
-// //Product name
|
|
|
-// pTmpStr += strLen;
|
|
|
-// strLen = pTmpStr[0] & 0x3F;
|
|
|
-// pTmpStr++;
|
|
|
-// _boardProductName = walloc(strLen+1);
|
|
|
-// memset(_boardProductName, 0, strLen+1);
|
|
|
-// strncpy(_boardProductName, pTmpStr, strLen);
|
|
|
-
|
|
|
-// //Serial number
|
|
|
-// pTmpStr += strLen;
|
|
|
-// strLen = pTmpStr[0] & 0x3F;
|
|
|
-// pTmpStr++;
|
|
|
-// _boardSerialNum = walloc(strLen+1);
|
|
|
-// memset(_boardSerialNum, 0, strLen+1);
|
|
|
-// strncpy(_boardSerialNum, pTmpStr, strLen);
|
|
|
-
|
|
|
-// //Part number
|
|
|
-// pTmpStr += strLen;
|
|
|
-// strLen = pTmpStr[0] & 0x3F;
|
|
|
-// pTmpStr++;
|
|
|
-// _boardPartNum = walloc(strLen+1);
|
|
|
-// memset(_boardPartNum, 0, strLen+1);
|
|
|
-// strncpy(_boardPartNum, pTmpStr, strLen);
|
|
|
-
|
|
|
-// //FILE ID
|
|
|
-// pTmpStr += strLen;
|
|
|
-// strLen = pTmpStr[0] & 0x3F;
|
|
|
-// pTmpStr++;
|
|
|
-
|
|
|
-// //Extra Info
|
|
|
-// pTmpStr += strLen;
|
|
|
-// strLen = pTmpStr[0] & 0x3F;
|
|
|
-// pTmpStr++;
|
|
|
-// _boardCustomField = walloc(strLen+1);
|
|
|
-// memset(_boardCustomField, 0, strLen+1);
|
|
|
-// strncpy(_boardCustomField, pTmpStr, strLen);
|
|
|
-
|
|
|
-// //Date
|
|
|
-// tval = ((fru_data.BoardInfo.MfgDateTime[2] << 16) + (fru_data.BoardInfo.MfgDateTime[1] << 8) + (fru_data.BoardInfo.MfgDateTime[0]));
|
|
|
-// tval = tval * 60;
|
|
|
-// tval = tval + secs_from_1970_1996;
|
|
|
-// _MfrDate = asctime(localtime(&tval));
|
|
|
-// }
|
|
|
-
|
|
|
-// //Get Product Info
|
|
|
-// if(fru_data.CommonHeader.ProductInfoAreaStartOffset != 0)
|
|
|
-// {
|
|
|
-// //Manufactor
|
|
|
-// strLen = fru_data.ProductInfo.Data[0] & 0x3F;
|
|
|
-// pTmpStr = &fru_data.ProductInfo.Data[1];
|
|
|
-// _MfrName = walloc(strLen+1);
|
|
|
-// memset(_MfrName, 0, strLen+1);
|
|
|
-// strncpy(_MfrName, pTmpStr, strLen);
|
|
|
-
|
|
|
-// //Product Name
|
|
|
-// pTmpStr += strLen;
|
|
|
-// strLen = pTmpStr[0] & 0x3F;
|
|
|
-// pTmpStr++;
|
|
|
-// _ProductName = walloc(strLen+1);
|
|
|
-// memset(_ProductName, 0, strLen+1);
|
|
|
-// strncpy(_ProductName, pTmpStr, strLen);
|
|
|
-
|
|
|
-// //Part Number
|
|
|
-// pTmpStr += strLen;
|
|
|
-// strLen = pTmpStr[0] & 0x3F;
|
|
|
-// pTmpStr++;
|
|
|
-// _ProductPartNum = walloc(strLen+1);
|
|
|
-// memset(_ProductPartNum, 0, strLen+1);
|
|
|
-// strncpy(_ProductPartNum, pTmpStr, strLen);
|
|
|
-
|
|
|
-// //Version
|
|
|
-// pTmpStr += strLen;
|
|
|
-// strLen = pTmpStr[0] & 0x3F;
|
|
|
-// pTmpStr++;
|
|
|
-// _ProductVersion = walloc(strLen+1);
|
|
|
-// memset(_ProductVersion, 0, strLen+1);
|
|
|
-// strncpy(_ProductVersion, pTmpStr, strLen);
|
|
|
-
|
|
|
-// //Serial Number
|
|
|
-// pTmpStr += strLen;
|
|
|
-// strLen = pTmpStr[0] & 0x3F;
|
|
|
-// pTmpStr++;
|
|
|
-// _ProductSerialNum = walloc(strLen+1);
|
|
|
-// memset(_ProductSerialNum, 0, strLen+1);
|
|
|
-// strncpy(_ProductSerialNum, pTmpStr, strLen);
|
|
|
-
|
|
|
-// //Assert Tag
|
|
|
-// pTmpStr += strLen;
|
|
|
-// strLen = pTmpStr[0] & 0x3F;
|
|
|
-// pTmpStr++;
|
|
|
-// // _AssetTag = walloc(strLen+1);
|
|
|
-// // memset(_AssetTag, 0, strLen+1);
|
|
|
-// // strncpy(_AssetTag, pTmpStr, strLen);
|
|
|
-
|
|
|
-// //File ID
|
|
|
-// pTmpStr += strLen;
|
|
|
-// strLen = pTmpStr[0] & 0x3F;
|
|
|
-// pTmpStr++;
|
|
|
-// // _FRUFileID = walloc(strLen+1);
|
|
|
-// // memset(_FRUFileID, 0, strLen+1);
|
|
|
-// // strncpy(_FRUFileID, pTmpStr, strLen);
|
|
|
-
|
|
|
-// //Extra info
|
|
|
-// pTmpStr += strLen;
|
|
|
-// strLen = pTmpStr[0] & 0x3F;
|
|
|
-// pTmpStr++;
|
|
|
-// _productCustomField = walloc(strLen+1);
|
|
|
-// memset(_productCustomField, 0, strLen+1);
|
|
|
-// strncpy(_productCustomField, pTmpStr, strLen);
|
|
|
-// }
|
|
|
-
|
|
|
-// char *pStr1, *pStr2, *pStr3;
|
|
|
-// cJSON * chassis = cJSON_CreateObject();
|
|
|
-// cJSON * board = cJSON_CreateObject();
|
|
|
-// cJSON * product = cJSON_CreateObject();
|
|
|
-// //chassis
|
|
|
-// cJSON_AddStringToObject(chassis, "Type", _chassisType);
|
|
|
-// cJSON_AddStringToObject(chassis, "PN", _chassisPartNum);
|
|
|
-// cJSON_AddStringToObject(chassis, "SN", _chassisSerialNum);
|
|
|
-// cJSON_AddStringToObject(chassis, "OEM", _chassisCustomField);
|
|
|
-
|
|
|
-// //board
|
|
|
-// cJSON_AddStringToObject(board, "Date", _MfrDate);
|
|
|
-// cJSON_AddStringToObject(board, "Mfr", _boardMfr);
|
|
|
-// cJSON_AddStringToObject(board, "Name", _boardProductName);
|
|
|
-// cJSON_AddStringToObject(board, "SN", _boardSerialNum);
|
|
|
-// cJSON_AddStringToObject(board, "PN", _boardPartNum);
|
|
|
-// cJSON_AddStringToObject(board, "OEM", _boardCustomField);
|
|
|
-
|
|
|
-// //product
|
|
|
-// cJSON_AddStringToObject(product, "Mfr", _MfrName);
|
|
|
-// cJSON_AddStringToObject(product, "Name", _ProductName);
|
|
|
-// cJSON_AddStringToObject(product, "PN", _ProductPartNum);
|
|
|
-// cJSON_AddStringToObject(product, "Ver", _ProductVersion);
|
|
|
-// cJSON_AddStringToObject(product, "SN", _ProductSerialNum);
|
|
|
-// cJSON_AddStringToObject(product, "OEM", _productCustomField);
|
|
|
-
|
|
|
-// pStr1 = cJSON_PrintUnformatted(chassis);
|
|
|
-// pStr2 = cJSON_PrintUnformatted(board);
|
|
|
-// pStr3 = cJSON_PrintUnformatted(product);
|
|
|
-
|
|
|
-// websSetStatus(wp, 200);
|
|
|
-// websWriteHeaders(wp, -1, 0); //Set length to -1 if unknown and transfer-chunk-encoding will be employed.
|
|
|
-// websWriteEndHeaders(wp);
|
|
|
-// int ret;
|
|
|
-// //websWrite(wp, "{\n");
|
|
|
-// websWrite(wp, "%s", pStr1); printf("---> cJSON Str1: %d \n%s\n", strlen(pStr1), pStr1);
|
|
|
-// //websWrite(wp, "%s", pStr2); printf("---> cJSON Str2: %d \n%s\n", strlen(pStr2), pStr2);
|
|
|
-// //websWrite(wp, "%s", pStr3); printf("---> cJSON Str3: %d \n%s\n", strlen(pStr3), pStr3);
|
|
|
-// //websWrite(wp, "msg:\"\",\ncode:200\n}");
|
|
|
-
|
|
|
-// ret = websFlush(wp, 1); //wait for all data to be written to the socket
|
|
|
-// //if(ret != 1)
|
|
|
-// printf("websFlush ret = %d\n", ret);
|
|
|
-
|
|
|
-// websDone(wp);
|
|
|
-
|
|
|
-// if(pStr1)
|
|
|
-// wfree(pStr1);
|
|
|
-// if(pStr2)
|
|
|
-// wfree(pStr2);
|
|
|
-// if(pStr3)
|
|
|
-// wfree(pStr3);
|
|
|
-// if(chassis)
|
|
|
-// cJSON_Delete(chassis);
|
|
|
-// if(board)
|
|
|
-// cJSON_Delete(board);
|
|
|
-// if(product)
|
|
|
-// cJSON_Delete(product);
|
|
|
-
|
|
|
-// if(_chassisPartNum) wfree(_chassisPartNum);
|
|
|
-// if(_chassisSerialNum) wfree(_chassisSerialNum);
|
|
|
-// if(_chassisType) wfree(_chassisType);
|
|
|
-// if(_chassisCustomField) wfree(_chassisCustomField);
|
|
|
-// if(_boardMfr) wfree(_boardMfr);
|
|
|
-// if(_boardProductName) wfree(_boardProductName);
|
|
|
-// if(_boardSerialNum) wfree(_boardSerialNum);
|
|
|
-// if(_boardPartNum) wfree(_boardPartNum);
|
|
|
-// if(_boardCustomField) wfree(_boardCustomField);
|
|
|
-// if(_MfrName) wfree(_MfrName);
|
|
|
-// if(_MfrDate) wfree(_MfrDate);
|
|
|
-// if(_ProductName) wfree(_ProductName);
|
|
|
-// if(_ProductPartNum) wfree(_ProductPartNum);
|
|
|
-// if(_ProductVersion) wfree(_ProductVersion);
|
|
|
-// if(_ProductSerialNum) wfree(_ProductSerialNum);
|
|
|
-// if(_productCustomField) wfree(_productCustomField);
|
|
|
-// printf("getFruInfo over!\n");
|
|
|
-// }
|