|
@@ -318,94 +318,100 @@ uint16_t LIBIPMI_HL_GetSysInfo( IPMI20_UDS_SESSION_T *pUDSSession, SysInfo_T *pS
|
|
|
|
|
|
|
|
|
|
|
|
-// uint16_t
|
|
|
-// LIBIPMI_HL_GetSensorHistory( IPMI20_UDS_SESSION_T *pUDSSession, sensor_history_st *pSensorHistory_st, int card_index, int sensor_number, int IPMB_ADDR)
|
|
|
-// {
|
|
|
-// printf(">come in history\n");
|
|
|
-// int i = 0;
|
|
|
-// uint8_t RawHistory[MAX_HISTORY_LEN];
|
|
|
-// uint16_t wRet;
|
|
|
-// uint32_t dwResLen;
|
|
|
-// uint32_t sdr_buff_size = 100;
|
|
|
-// uint8_t Req[5];
|
|
|
-// uint8_t Res[MAX_HISTORY_LEN+3];
|
|
|
-// int timeout = 3;
|
|
|
-// FullSensorRec_T sdr_buffer;
|
|
|
-// uint16_t offset = 0;
|
|
|
-// uint16_t reqLen = 0, resLen = 0;
|
|
|
-// //get factors
|
|
|
-// LIBIPMI_HL_GetSpecificSDR( pUDSSession, (uint8_t*)&sdr_buffer, &sdr_buff_size, sensor_number, timeout );
|
|
|
-
|
|
|
-// //get history
|
|
|
-// // if( pUDSSession->byMediumType == IPMB_MEDIUM )
|
|
|
-// // {
|
|
|
-// // reqLen = 22; //32 bytes - ipmb message header - response header - checksum2
|
|
|
-// // do{
|
|
|
-// // Req[0] = sensor_number;
|
|
|
-// // Req[1] = (offset>>8)&0xff;
|
|
|
-// // Req[2] = offset&0xff;
|
|
|
-// // Req[3] = (reqLen>>8)&0xff;
|
|
|
-// // Req[4] = reqLen&0xff;
|
|
|
-// // wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 0x2e<<2, 0x89,
|
|
|
-// // (uint8_t*)Req, 5,
|
|
|
-// // (uint8_t *)Res, &dwResLen,
|
|
|
-// // timeout);
|
|
|
-// // if(wRet != 0)
|
|
|
-// // {
|
|
|
-// // return -1;
|
|
|
-// // }
|
|
|
-// // resLen = (Res[1]<<8) | Res[2];
|
|
|
-// // if(resLen > MAX_HISTORY_LEN)
|
|
|
-// // {
|
|
|
-// // printf("---> response length error: resLen = %#x\n", resLen);
|
|
|
-// // return -1;
|
|
|
-// // }
|
|
|
-// // memcpy(&RawHistory[offset],&Res[3],resLen);
|
|
|
-// // offset += resLen;
|
|
|
-// // if(offset >= MAX_HISTORY_LEN) //get all history datas
|
|
|
-// // {
|
|
|
-// // reqLen = 0;
|
|
|
-// // break;
|
|
|
-// // }
|
|
|
-// // reqLen = ((MAX_HISTORY_LEN-offset)>22) ? 22 : (MAX_HISTORY_LEN-offset);
|
|
|
-// // }while(reqLen);
|
|
|
-// // }
|
|
|
-// // else
|
|
|
-// {
|
|
|
-// Req[0] = sensor_number;
|
|
|
-// Req[1] = 0;
|
|
|
-// Req[2] = 0;
|
|
|
-// Req[3] = (MAX_HISTORY_LEN>>8)&0xff;
|
|
|
-// Req[4] = MAX_HISTORY_LEN & 0xff;
|
|
|
-// wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 0x2e<<2, 0x89,
|
|
|
-// (uint8_t*)Req, 5,
|
|
|
-// (uint8_t *)Res, &dwResLen,
|
|
|
-// timeout);
|
|
|
-// if(wRet != 0)
|
|
|
-// {
|
|
|
-// return -1;
|
|
|
-// }
|
|
|
+uint16_t
|
|
|
+LIBIPMI_HL_GetSensorHistory( IPMI20_UDS_SESSION_T *pUDSSession, sensor_history_st *pSensorHistory_st, int card_index, int sensor_number, int IPMB_ADDR)
|
|
|
+{
|
|
|
+ printf("---> come in history\n");
|
|
|
+ int i = 0;
|
|
|
+ //uint8_t RawHistory[MAX_HISTORY_LEN];
|
|
|
+ uint16_t wRet;
|
|
|
+ uint32_t dwResLen;
|
|
|
+ uint32_t sdr_buff_size = 255;
|
|
|
+ uint8_t Req[5];
|
|
|
+ uint8_t *Res = (uint8_t*)walloc(MAX_HISTORY_LEN+3);
|
|
|
+ int timeout = 3;
|
|
|
+ FullSensorRec_T sdr_buffer;
|
|
|
+ uint16_t offset = 0;
|
|
|
+ uint16_t reqLen = 0, resLen = 0;
|
|
|
+ float tmpValue;
|
|
|
+ //get factors
|
|
|
+ LIBIPMI_HL_GetSpecificSDR( pUDSSession, (uint8_t*)&sdr_buffer, &sdr_buff_size, sensor_number, timeout );
|
|
|
+
|
|
|
+ //get history
|
|
|
+ // if( pUDSSession->byMediumType == IPMB_MEDIUM )
|
|
|
+ // {
|
|
|
+ // reqLen = 22; //32 bytes - ipmb message header - response header - checksum2
|
|
|
+ // do{
|
|
|
+ // Req[0] = sensor_number;
|
|
|
+ // Req[1] = (offset>>8)&0xff;
|
|
|
+ // Req[2] = offset&0xff;
|
|
|
+ // Req[3] = (reqLen>>8)&0xff;
|
|
|
+ // Req[4] = reqLen&0xff;
|
|
|
+ // wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 0x2e<<2, 0x89,
|
|
|
+ // (uint8_t*)Req, 5,
|
|
|
+ // (uint8_t *)Res, &dwResLen,
|
|
|
+ // timeout);
|
|
|
+ // if(wRet != 0)
|
|
|
+ // {
|
|
|
+ // return -1;
|
|
|
+ // }
|
|
|
+ // resLen = (Res[1]<<8) | Res[2];
|
|
|
+ // if(resLen > MAX_HISTORY_LEN)
|
|
|
+ // {
|
|
|
+ // printf("---> response length error: resLen = %#x\n", resLen);
|
|
|
+ // return -1;
|
|
|
+ // }
|
|
|
+ // memcpy(&RawHistory[offset],&Res[3],resLen);
|
|
|
+ // offset += resLen;
|
|
|
+ // if(offset >= MAX_HISTORY_LEN) //get all history datas
|
|
|
+ // {
|
|
|
+ // reqLen = 0;
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
+ // reqLen = ((MAX_HISTORY_LEN-offset)>22) ? 22 : (MAX_HISTORY_LEN-offset);
|
|
|
+ // }while(reqLen);
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ {
|
|
|
+ Req[0] = sensor_number;
|
|
|
+ Req[1] = 0;
|
|
|
+ Req[2] = 0;
|
|
|
+ Req[3] = (MAX_HISTORY_LEN>>8)&0xff;
|
|
|
+ Req[4] = MAX_HISTORY_LEN & 0xff;
|
|
|
+ wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,
|
|
|
+ NETFNLUN_IPMI_STORLEAD, CMD_GET_SENSOR_HISTORY,
|
|
|
+ (uint8_t*)Req, 5,
|
|
|
+ (uint8_t *)Res, &dwResLen,
|
|
|
+ timeout);
|
|
|
+ if(wRet != 0)
|
|
|
+ {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
|
|
|
-// resLen = (Res[1]<<8) | Res[2];
|
|
|
-// if(resLen > MAX_HISTORY_LEN)
|
|
|
-// {
|
|
|
-// printf("---> response length error: resLen = %#x\n", resLen);
|
|
|
-// return -1;
|
|
|
-// }
|
|
|
-// memcpy(RawHistory,&Res[3],resLen);
|
|
|
-// }
|
|
|
+ resLen = (Res[1]<<8) | Res[2];
|
|
|
+ if(resLen > MAX_HISTORY_LEN)
|
|
|
+ {
|
|
|
+ printf("---> response length error: resLen = %#x\n", resLen);
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ //memcpy(RawHistory,&Res[3],resLen);
|
|
|
+ }
|
|
|
|
|
|
-// for(i=0;i < 480; i++)
|
|
|
-// {
|
|
|
-// ipmi_convert_reading( (uint8_t*)&sdr_buffer, RawHistory[i], (float*)&pSensorHistory_st->sensor_history[i] );
|
|
|
-// }
|
|
|
+ for(i=0;i < 480; i++)
|
|
|
+ {
|
|
|
+ ipmi_convert_reading( (uint8_t*)&sdr_buffer, Res[3+i], &tmpValue );
|
|
|
+ pSensorHistory_st->sensor_history[i] = tmpValue;
|
|
|
+ //printf("raw: %#x, float: %f\n", Res[3+i], tmpValue);
|
|
|
+ }
|
|
|
|
|
|
-// memset(pSensorHistory_st->sensor_name, 0,sizeof(pSensorHistory_st->sensor_name));
|
|
|
-// memcpy(pSensorHistory_st->sensor_name, sdr_buffer.IDStr, sdr_buffer.IDStrTypeLen&0x3f);
|
|
|
-// pSensorHistory_st->sensor_num = sensor_number;
|
|
|
+ memset(pSensorHistory_st->sensor_name, 0,sizeof(pSensorHistory_st->sensor_name));
|
|
|
+ memcpy(pSensorHistory_st->sensor_name, sdr_buffer.IDStr, sdr_buffer.IDStrTypeLen&0x3f);
|
|
|
+ pSensorHistory_st->sensor_num = sensor_number;
|
|
|
|
|
|
-// return 0;
|
|
|
-// }
|
|
|
+ wfree(Res);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
|
|
|
|
|
|
// uint16_t LIBIPMI_HL_GetAllCards(IPMI20_UDS_SESSION_T *pUDSSession,
|