static void thres_read(SaHpiSessionIdT sessionid, SaHpiResourceIdT resourceid, SaHpiRdrT *rdr) { SaHpiSensorReadingT reading; SaHpiSensorThresholdsT thres; SaHpiSensorRecT *rec; SaErrorT rv; rec = &rdr->RdrTypeUnion.SensorRec; rv = saHpiSensorReadingGet(sessionid, resourceid, rec->Num, &reading); if (rv != SA_OK) { printf( "saHpiSensorReadingGet error %d\n",rv); return; } printf("sensor(%s)\n",gettext(&rdr->IdString)); printf("current reading:"); reading_print(&reading); printf("\n"); rv = saHpiSensorThresholdsGet(sessionid, resourceid, rec->Num, &thres); if (rv != SA_OK) { printf( "saHpiSensorThresholdsGet error %d\n",rv); return; } printf("current threshold:\n"); thres_print(&thres); }
int show_threshold(SaHpiSessionIdT sessionid, SaHpiResourceIdT resourceid, SaHpiSensorNumT sensornum, SaHpiSensorRecT *sen, hpi_ui_print_cb_t proc) { SaErrorT rv; SaHpiSensorThresholdsT senstbuff; SaHpiSensorThdDefnT *sendef; SaHpiSensorTypeT type; SaHpiEventCategoryT categ; char buf[SHOW_BUF_SZ]; Pr_ret_t res; sendef = &(sen->ThresholdDefn); rv = saHpiSensorTypeGet(sessionid, resourceid, sensornum, &type, &categ); if (rv != SA_OK) { snprintf(buf, SHOW_BUF_SZ, "ERROR: saHpiSensorTypeGet error = %s\n", oh_lookup_error(rv)); proc(buf); return -1; }; if (categ != SAHPI_EC_THRESHOLD) return(SA_OK); memset(&senstbuff, 0, sizeof(SaHpiSensorThresholdsT)); rv = saHpiSensorThresholdsGet(sessionid, resourceid, sensornum, &senstbuff); if (rv != SA_OK) { snprintf(buf, SHOW_BUF_SZ, "ERROR: saHpiSensorThresholdsGet error = %s\n", oh_lookup_error(rv)); proc(buf); return -1; }; if (sendef->IsAccessible == 0) { proc("Thresholds are not accessible.\n"); return -1; }; res = print_thres_value(&(senstbuff.LowMinor), "Lower Minor Threshold", sendef, SAHPI_ES_LOWER_MINOR, proc); if (res == HPI_UI_END) return(HPI_UI_END); res = print_thres_value(&(senstbuff.LowMajor), "Lower Major Threshold", sendef, SAHPI_ES_LOWER_MAJOR, proc); if (res == HPI_UI_END) return(HPI_UI_END); res = print_thres_value(&(senstbuff.LowCritical), "Lower Critical Threshold", sendef, SAHPI_ES_LOWER_CRIT, proc); if (res == HPI_UI_END) return(HPI_UI_END); res = print_thres_value(&(senstbuff.UpMinor), "Upper Minor Threshold", sendef, SAHPI_ES_UPPER_MINOR, proc); if (res == HPI_UI_END) return(HPI_UI_END); res = print_thres_value(&(senstbuff.UpMajor), "Upper Major Threshold", sendef, SAHPI_ES_UPPER_MAJOR, proc); if (res == HPI_UI_END) return(HPI_UI_END); res = print_thres_value(&(senstbuff.UpCritical), "Upper Critical Threshold", sendef, SAHPI_ES_UPPER_CRIT, proc); if (res == HPI_UI_END) return(HPI_UI_END); res = print_thres_value(&(senstbuff.PosThdHysteresis), "Positive Threshold Hysteresis", NULL, 0, proc); if (res == HPI_UI_END) return(HPI_UI_END); res = print_thres_value(&(senstbuff.NegThdHysteresis), "Negative Threshold Hysteresis", NULL, 0, proc); return SA_OK; }
static void show_thresholds(Rpt_t *Rpt, Rdr_t *R) { SaHpiSensorThresholdsT buf; SaErrorT rv; rv = saHpiSensorThresholdsGet(sessionid, Rpt->Rpt.ResourceId, R->Rdr.RdrTypeUnion.SensorRec.Num, &buf); if (rv != SA_OK) { printf("ERROR: %s\n", oh_lookup_error(rv)); return; }; printf(" Thresholds:\n"); ShowThres(&buf); if (R->is_value == 0) { R->thresholds = buf; R->is_value = 1; } }
int main(int argc, char **argv) { SaHpiSessionIdT sid = 0; SaHpiSensorThresholdsT thresholds; SaErrorT rc = SA_OK; rc = saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, &sid, NULL); if (rc != SA_OK) { dbg("Failed to open session"); return -1; } rc = saHpiDiscover(sid); if (rc != SA_OK) { dbg("Failed to run discover"); return -1; } /* get the resource id of the chassis */ SaHpiResourceIdT resid = get_resid(sid, SAHPI_ENT_SYSTEM_CHASSIS); if (resid == 0) { dbg("Couldn't find the resource id of the chassis"); return -1; } /* get sensor thresholds */ rc = saHpiSensorThresholdsGet(sid, resid, 1, &thresholds); if (rc != SA_OK) { dbg("Couldn't get sensor thresholds"); dbg("Error %s",oh_lookup_error(rc)); return -1; } /* set sensor thresholds */ rc = saHpiSensorThresholdsSet(sid, resid, 1, &thresholds); if (rc == SA_OK) { /* all our sensors are read-only so if we can change the sensor it is an error */ dbg("Error: able to write to a read-only sensor"); return -1; } return 0; }
static int sa_get_thres( SaHpiResourceIdT resourceid, SaHpiSensorNumT sensornum ) { SaErrorT rv; SaHpiSensorThresholdsT senstbuff; rv = saHpiSensorThresholdsGet(sessionid, resourceid, sensornum, &senstbuff); printf("Supported Thresholds:\n"); if (senstbuff.LowCritical.ValuesPresent & SAHPI_SRF_INTERPRETED) printf(" Lower Critical Threshold(lc): %5.2f\n", senstbuff.LowCritical.Interpreted.Value.SensorFloat32); if (senstbuff.LowMajor.ValuesPresent & SAHPI_SRF_INTERPRETED) printf(" Lower Major Threshold(la): %5.2f\n", senstbuff.LowMajor.Interpreted.Value.SensorFloat32); if (senstbuff.LowMinor.ValuesPresent & SAHPI_SRF_INTERPRETED) printf(" Lower Minor Threshold(li): %5.2f\n", senstbuff.LowMinor.Interpreted.Value.SensorFloat32); if (senstbuff.UpCritical.ValuesPresent & SAHPI_SRF_INTERPRETED) printf(" Upper Critical Threshold(uc): %5.2f\n", senstbuff.UpCritical.Interpreted.Value.SensorFloat32); if (senstbuff.UpMajor.ValuesPresent & SAHPI_SRF_INTERPRETED) printf(" Upper Major Threshold(ua): %5.2f\n", senstbuff.UpMajor.Interpreted.Value.SensorFloat32); if (senstbuff.UpMinor.ValuesPresent & SAHPI_SRF_INTERPRETED) printf(" Upper Minor Threshold(ui): %5.2f\n", senstbuff.UpMinor.Interpreted.Value.SensorFloat32); if (senstbuff.PosThdHysteresis.ValuesPresent & SAHPI_SRF_RAW) printf(" Positive Threshold Hysteresis in RAW\n"); if (senstbuff.PosThdHysteresis.ValuesPresent & SAHPI_SRF_INTERPRETED) printf(" Positive Threshold Hysteresis(ph): %5.2f\n", senstbuff.PosThdHysteresis.Interpreted.Value.SensorFloat32); if (senstbuff.NegThdHysteresis.ValuesPresent & SAHPI_SRF_RAW) printf(" Negative Threshold Hysteresis in RAW\n"); if (senstbuff.NegThdHysteresis.ValuesPresent & SAHPI_SRF_INTERPRETED) printf(" Negative Threshold Hysteresis(nh): %5.2f\n", senstbuff.NegThdHysteresis.Interpreted.Value.SensorFloat32); return SA_OK; }
int Test_Rdr(SaHpiSessionIdT session, SaHpiResourceIdT resourceId, SaHpiRdrT rdr) { SaErrorT status; int retval = SAF_TEST_UNKNOWN; SaHpiSensorNumT s_num = 0; SaHpiBoolT accessible; SaHpiSensorThdMaskT readmask; if (rdr.RdrType == SAHPI_SENSOR_RDR) { accessible = rdr.RdrTypeUnion.SensorRec.ThresholdDefn.IsAccessible; readmask = rdr.RdrTypeUnion.SensorRec.ThresholdDefn.ReadThold; s_num = rdr.RdrTypeUnion.SensorRec.Num; if (accessible == SAHPI_FALSE || readmask == 0) retval = SAF_TEST_NOTSUPPORT; } else // Non-Sensor RDR retval = SAF_TEST_NOTSUPPORT; if (retval == SAF_TEST_UNKNOWN) { // // Call saHpiSensorThresholdsGet passing in a NULL pointer to SensorThresholds // status = saHpiSensorThresholdsGet(session, resourceId, s_num, NULL); if (status != SA_ERR_HPI_INVALID_PARAMS) { if (status == SA_ERR_HPI_ENTITY_NOT_PRESENT) { m_print("sensor is not present."); retval = SAF_TEST_NOTSUPPORT; } else { e_print(saHpiSensorThresholdsGet, SA_ERR_HPI_INVALID_PARAMS || SA_ERR_HPI_ENTITY_NOT_PRESENT, status); retval = SAF_TEST_FAIL; } } else retval = SAF_TEST_PASS; } return (retval); }
int generateAssertEvents(SaHpiSessionIdT sessionId, SaHpiResourceIdT resourceId, SaHpiSensorRecT * sensorRec) { SaErrorT status; int retval; SaHpiSensorThresholdsT old_thresholds; SaHpiSensorThresholdsT thresholds; status = saHpiSensorThresholdsGet(sessionId, resourceId, sensorRec->Num, &old_thresholds); if (status != SA_OK) { retval = SAF_TEST_UNRESOLVED; e_print(saHpiSensorThresholdsGet, SA_OK, status); } else { status = setUpMinorThreshold(sessionId, resourceId, sensorRec, old_thresholds.LowMinor.Value); if (status != SA_OK) { retval = SAF_TEST_UNRESOLVED; } else { retval = SAF_TEST_PASS; initThresholds(&thresholds, sensorRec->DataFormat.ReadingType); thresholds.UpMinor.IsSupported = SAHPI_TRUE; thresholds.UpMinor.Value = old_thresholds.UpMinor.Value; sensorData[sensorCount].resourceId = resourceId; sensorData[sensorCount].sensorNum = sensorRec->Num; sensorData[sensorCount].thresholds = thresholds; sensorData[sensorCount].assert = SAHPI_FALSE; sensorData[sensorCount].deassert = SAHPI_FALSE; sensorData[sensorCount].restoreMasks = SAHPI_FALSE; sensorData[sensorCount].origEventEnable = SAHPI_TRUE; sensorCount++; } } return retval; }
int show_threshold(SaHpiSessionIdT sessionid, SaHpiResourceIdT resourceid, SaHpiSensorNumT sensornum, hpi_ui_print_cb_t proc) { SaErrorT rv; SaHpiSensorThresholdsT senstbuff; char buf[1024]; int res; rv = saHpiSensorThresholdsGet(sessionid, resourceid, sensornum, &senstbuff); if (rv != SA_OK) { snprintf(buf, 1024, "ERROR: saHpiSensorThresholdsGet error = %s\n", oh_lookup_error(rv)); proc(buf); return -1; }; res = print_thres_value(&(senstbuff.LowCritical), "Lower Critical Threshold(lc):", proc); if (res != 0) return(0); res = print_thres_value(&(senstbuff.LowMajor), "Lower Major Threshold(la):", proc); if (res != 0) return(0); res = print_thres_value(&(senstbuff.LowMinor), "Lower Minor Threshold(li):", proc); if (res != 0) return(0); res = print_thres_value(&(senstbuff.UpCritical), "Upper Critical Threshold(uc):", proc); if (res != 0) return(0); res = print_thres_value(&(senstbuff.UpMajor), "Upper Major Threshold(ua):", proc); if (res != 0) return(0); res = print_thres_value(&(senstbuff.UpMinor), "Upper Minor Threshold(ui):", proc); if (res != 0) return(0); res = print_thres_value(&(senstbuff.PosThdHysteresis), "Positive Threshold Hysteresis(ph):", proc); if (res != 0) return(0); res = print_thres_value(&(senstbuff.NegThdHysteresis), "Negative Threshold Hysteresis(nh):", proc); return SA_OK; }
static void DoEvent( SaHpiSessionIdT sessionid, SaHpiResourceIdT resourceid, SaHpiSensorRecT *sensorrec ) { SaHpiSensorNumT sensornum; SaHpiSensorReadingT reading; SaHpiSensorReadingT conv_reading; SaHpiSensorThresholdsT senstbuff1; SaHpiSensorThresholdsT senstbuff2; SaHpiTimeoutT timeout = (SaHpiInt64T)(12 * HPI_NSEC_PER_SEC); /* 12 seconds */ SaHpiEventT event; SaHpiRptEntryT rptentry; SaHpiRdrT rdr; char *unit; int eventflag = 0; int i; sensornum = sensorrec->Num; /* Get current sensor reading */ rv = saHpiSensorReadingGet( sessionid, resourceid, sensornum, &reading); if (rv != SA_OK) { printf( "\n"); /* printf("ReadingGet ret=%d\n", rv); */ return; } if ((reading.ValuesPresent & SAHPI_SRF_INTERPRETED) == 0 && (reading.ValuesPresent & SAHPI_SRF_RAW)) { /* only try convert if intrepreted not available. */ rv = saHpiSensorReadingConvert(sessionid, resourceid, sensornum, &reading, &conv_reading); if (rv != SA_OK) { printf("raw=%x conv_ret=%d\n", reading.Raw, rv); /* printf("conv_rv=%s\n", decode_error(rv)); */ return; } else { reading.Interpreted.Type = conv_reading.Interpreted.Type; reading.Interpreted.Value.SensorUint32 = conv_reading.Interpreted.Value.SensorUint32; } } /* Determine units of interpreted reading */ i = sensorrec->DataFormat.BaseUnits; if (i > NSU) i = 0; unit = units[i]; printf(" = %05.2f %s \n", reading.Interpreted.Value.SensorFloat32, unit); /* Retrieve current threshold setings, twice */ /* once for backup and once for modification */ /* Get backup copy */ rv = saHpiSensorThresholdsGet( sessionid, resourceid, sensornum, &senstbuff1); if (rv != SA_OK) return; /* Get modification copy */ rv = saHpiSensorThresholdsGet( sessionid, resourceid, sensornum, &senstbuff2); if (rv != SA_OK) return; /* Display current thresholds */ if (rv == SA_OK) { printf( " Current\n"); ShowThresh( &senstbuff2 ); } /* Set new threshold to current reading + 10% */ senstbuff2.LowMajor.Interpreted.Value.SensorFloat32 = reading.Interpreted.Value.SensorFloat32 * (SaHpiFloat32T)1.10; printf( "ValuesPresent = %x\n", senstbuff2.LowMajor.ValuesPresent); printf( "Values Mask = %x\n", (SAHPI_SRF_RAW)); senstbuff2.LowMajor.ValuesPresent = senstbuff2.LowMajor.ValuesPresent ^ (SAHPI_SRF_RAW); printf( "ValuesPresent = %x\n", senstbuff2.LowMajor.ValuesPresent); /* Display new current thresholds */ if (rv == SA_OK) { printf( " New\n"); ShowThresh( &senstbuff2 ); } /* See what Events are Enabled */ rv = saHpiSensorEventEnablesGet( sessionid, resourceid, sensornum, &enables1); if (rv != SA_OK) return; printf( "Sensor Event Enables: \n"); printf( " Sensor Status = %x\n", enables1.SensorStatus); printf( " Assert Events = %x\n", enables1.AssertEvents); printf( " Deassert Events = %x\n", enables1.DeassertEvents); /* enables1.AssertEvents = 0x0400; enables1.DeassertEvents = 0x0400; rv = saHpiSensorEventEnablesSet( sessionid, resourceid, sensornum, &enables1); if (rv != SA_OK) return; */ /************************ Temporary exit */ /* return; */ /* Subscribe to New Events, only */ printf( "Subscribe to events\n"); rv = saHpiSubscribe( sessionid, (SaHpiBoolT)0 ); if (rv != SA_OK) return; /* Set new thresholds */ printf( "Set new thresholds\n"); rv = saHpiSensorThresholdsSet( sessionid, resourceid, sensornum, &senstbuff2); if (rv != SA_OK) return; /* Go wait on event to occur */ printf( "Go and get the event\n"); eventflag = 0; while ( eventflag == 0) { rv = saHpiEventGet( sessionid, timeout, &event, &rdr, &rptentry ); if (rv != SA_OK) { if (rv != SA_ERR_HPI_TIMEOUT) { printf( "Error during EventGet - Test FAILED\n"); return; } else { printf( "Time expired during EventGet - Test FAILED\n"); /* Reset to the original thresholds */ printf( "Reset thresholds\n"); rv = saHpiSensorThresholdsSet( sessionid, resourceid, sensornum, &senstbuff1); if (rv != SA_OK) return; /* Re-read threshold values */ rv = saHpiSensorThresholdsGet( sessionid, resourceid, sensornum, &senstbuff2); if (rv != SA_OK) return; return; } } /* Decode the event information */ printf( "Decode event info\n"); if (event.EventType == SAHPI_ET_SENSOR) { printf( "Sensor # = %2d Severity = %2x\n", event.EventDataUnion.SensorEvent.SensorNum, event.Severity ); if (event.EventDataUnion.SensorEvent.SensorNum == sensornum) { eventflag = 1; printf( "Got it - Test PASSED\n"); } } } /* Reset to the original thresholds */ printf( "Reset thresholds\n"); rv = saHpiSensorThresholdsSet( sessionid, resourceid, sensornum, &senstbuff1); if (rv != SA_OK) return; /* Re-read threshold values */ rv = saHpiSensorThresholdsGet( sessionid, resourceid, sensornum, &senstbuff2); if (rv != SA_OK) return; /* Display reset thresholds */ if (rv == SA_OK) { printf( " Reset\n"); ShowThresh( &senstbuff2 ); } /* Unsubscribe to future events */ printf( "Unsubscribe\n"); rv = saHpiUnsubscribe( sessionid ); return; } /*end DoEvent*/
void list_rdr(SaHpiSessionIdT session_id, SaHpiResourceIdT resource_id) { SaErrorT err; SaHpiEntryIdT current_rdr; SaHpiEntryIdT next_rdr; SaHpiRdrT rdr; SaHpiSensorReadingT reading; SaHpiSensorTypeT sensor_type; SaHpiSensorNumT sensor_num; SaHpiEventCategoryT category; SaHpiSensorThresholdsT thres; SaHpiCtrlNumT ctrl_num; SaHpiCtrlStateT state; SaHpiCtrlTypeT ctrl_type; SaHpiEirIdT l_eirid; SaHpiInventoryDataT* l_inventdata; const SaHpiUint32T l_inventsize = 16384; SaHpiUint32T l_actualsize; printf("RDR Info:\n"); next_rdr = SAHPI_FIRST_ENTRY; do { char tmp_epath[128]; current_rdr = next_rdr; err = saHpiRdrGet(session_id, resource_id, current_rdr, &next_rdr, &rdr); if (SA_OK != err) { if (current_rdr == SAHPI_FIRST_ENTRY) printf("Empty RDR table\n"); else error("saHpiRdrGet", err); return; } printf("\tRecordId: %x\n", rdr.RecordId); printf("\tRdrType: %s\n", rdrtype2str(rdr.RdrType)); if (rdr.RdrType == SAHPI_SENSOR_RDR) { SaErrorT val; sensor_num = rdr.RdrTypeUnion.SensorRec.Num; val = saHpiSensorTypeGet(session_id, resource_id, sensor_num, &sensor_type, &category); printf("\tSensor num: %i\n\tType: %s\n", sensor_num, get_sensor_type(sensor_type)); printf("\tCategory: %s\n", get_sensor_category(category)); memset(&reading, 0, sizeof(SaHpiSensorReadingT)); err = saHpiSensorReadingGet(session_id, resource_id, sensor_num, &reading); if (err != SA_OK) { printf("Error=%d reading sensor data {sensor, %d}\n", err, sensor_num); continue; } if (reading.ValuesPresent & SAHPI_SRF_RAW) { printf("\tValues Present: RAW\n"); printf("\t\tRaw value: %d\n", reading.Raw); } if (reading.ValuesPresent & SAHPI_SRF_INTERPRETED) { printf("\tValues Present: Interpreted\n"); printf("\t\t"); interpreted2str(reading.Interpreted); } if (reading.ValuesPresent & SAHPI_SRF_EVENT_STATE) { printf("\tValues Present: Event State\n"); } if (rdr.RdrTypeUnion.SensorRec.ThresholdDefn.IsThreshold == SAHPI_TRUE) { memset(&thres, 0, sizeof(SaHpiSensorThresholdsT)); err = saHpiSensorThresholdsGet(session_id, resource_id, sensor_num, &thres); if (err != SA_OK) { printf("Error=%d reading sensor thresholds {sensor, %d}\n", err, sensor_num); continue; } if (thres.LowCritical.ValuesPresent) { printf("\t\tThreshold: Low Critical Values\n"); printreading(thres.LowCritical); } if (thres.LowMajor.ValuesPresent) { printf("\t\tThreshold: Low Major Values\n"); printreading(thres.LowMajor); } if (thres.LowMinor.ValuesPresent) { printf("\t\tThreshold: Low Minor Values\n"); printreading(thres.LowMinor); } if (thres.UpCritical.ValuesPresent) { printf("\t\tThreshold: Up Critical Values\n"); printreading(thres.UpCritical); } if (thres.UpMajor.ValuesPresent) { printf("\t\tThreshold: Up Major Values\n"); printreading(thres.UpMajor); } if (thres.UpMinor.ValuesPresent) { printf("\t\tThreshold: Up Minor Values\n"); printreading(thres.UpMinor); } if (thres.PosThdHysteresis.ValuesPresent) { printf("\t\tThreshold: Pos Threshold Hysteresis Values\n"); printreading(thres.PosThdHysteresis); } if (thres.NegThdHysteresis.ValuesPresent) { printf("\t\tThreshold: Neg Threshold Hysteresis Values\n"); printreading(thres.NegThdHysteresis); } } } if (rdr.RdrType == SAHPI_CTRL_RDR) { ctrl_num = rdr.RdrTypeUnion.CtrlRec.Num; err = saHpiControlTypeGet(session_id, resource_id, ctrl_num, &ctrl_type); if (err != SA_OK) { printf("Error=%d reading control type {control, %d}\n", err, ctrl_num); continue; } printf("\tControl num: %i\n\tType: %s\n", ctrl_num, get_control_type(ctrl_type)); err = saHpiControlStateGet(session_id, resource_id, ctrl_num, &state); if (err != SA_OK) { printf("Error=%d reading control state {control, %d}\n", err, ctrl_num); continue; } if (ctrl_type != state.Type) { printf("Control Type mismatch between saHpiControlTypeGet=%d and saHpiControlStateGet = %d\n", ctrl_type, state.Type); } switch (state.Type) { case SAHPI_CTRL_TYPE_DIGITAL: printf("\t\tControl Digital State: %s\n", ctrldigital2str(state.StateUnion.Digital)); break; case SAHPI_CTRL_TYPE_DISCRETE: printf("\t\tControl Discrete State: %x\n", state.StateUnion.Discrete); break; case SAHPI_CTRL_TYPE_ANALOG: printf("\t\tControl Analog State: %x\n", state.StateUnion.Analog); break; case SAHPI_CTRL_TYPE_STREAM: printf("\t\tControl Stream Repeat: %d\n", state.StateUnion.Stream.Repeat); printf("\t\tControl Stream Data: "); display_oembuffer(state.StateUnion.Stream.StreamLength, state.StateUnion.Stream.Stream); break; case SAHPI_CTRL_TYPE_TEXT: printf("\t\tControl Text Line Num: %c\n", state.StateUnion.Text.Line); display_textbuffer(state.StateUnion.Text.Text); break; case SAHPI_CTRL_TYPE_OEM: printf("\t\tControl OEM Manufacturer: %d\n", state.StateUnion.Oem.MId); printf("\t\tControl OEM Data: "); display_oembuffer((SaHpiUint32T)state.StateUnion.Oem.BodyLength, state.StateUnion.Oem.Body); break; default: printf("\t\tInvalid control type (%d) from saHpiControlStateGet\n", state.Type); } } if (rdr.RdrType == SAHPI_INVENTORY_RDR) { l_eirid = rdr.RdrTypeUnion.InventoryRec.EirId; l_inventdata = (SaHpiInventoryDataT *)g_malloc(l_inventsize); err = saHpiEntityInventoryDataRead(session_id, resource_id, l_eirid, l_inventsize, l_inventdata, &l_actualsize); if (err != SA_OK) { printf("Error=%d reading inventory type {EirId, %d}\n", err, l_eirid); continue; } else if (l_inventdata->Validity == SAHPI_INVENT_DATA_VALID) { printf("\tFound Inventory RDR with EirId: %x\n", l_eirid); printf("\tRDR l_inventsize = %d, actualsize = %d\n", l_inventsize, l_actualsize); switch (l_inventdata->DataRecords[0]->RecordType) { case SAHPI_INVENT_RECTYPE_INTERNAL_USE: printf( "Internal Use\n"); break; case SAHPI_INVENT_RECTYPE_PRODUCT_INFO: printf( "Product Info\n"); break; case SAHPI_INVENT_RECTYPE_CHASSIS_INFO: printf( "Chassis Info\n"); break; case SAHPI_INVENT_RECTYPE_BOARD_INFO: printf( "Board Info\n"); break; case SAHPI_INVENT_RECTYPE_OEM: printf( "OEM Record\n"); break; default: printf(" Invalid Invent Rec Type =%x\n", l_inventdata->DataRecords[0]->RecordType); break; } } g_free(l_inventdata); } printf("\tEntity: \n"); entitypath2string(&rdr.Entity, tmp_epath, sizeof(tmp_epath)); printf("\t\t%s\n", tmp_epath); printf("\tIdString: "); display_textbuffer(rdr.IdString); printf("\n"); /* Produce blank line between rdrs. */ }while(next_rdr != SAHPI_LAST_ENTRY); }
static void ShowSensor( SaHpiSessionIdT sessionid, SaHpiResourceIdT resourceid, SaHpiSensorRecT *sensorrec ) { SaHpiSensorNumT sensornum; SaHpiSensorReadingT reading; SaHpiSensorReadingT conv_reading; SaHpiSensorThresholdsT senstbuff; SaErrorT rv; char *unit; int i; sensornum = sensorrec->Num; rv = saHpiSensorReadingGet(sessionid,resourceid, sensornum, &reading); if (rv != SA_OK) { printf("ReadingGet ret=%d\n", rv); return; } if ((reading.ValuesPresent & SAHPI_SRF_INTERPRETED) == 0) { if ((reading.ValuesPresent & SAHPI_SRF_RAW) == 0) { /* no raw or interpreted, so just show event status */ /* This is a Compact Sensor */ if (reading.ValuesPresent & SAHPI_SRF_EVENT_STATE) printf(" = %x %x\n", reading.EventStatus.SensorStatus, reading.EventStatus.EventStatus); else printf(" = no reading\n"); return; } else { /* have raw, but not interpreted, so try convert. */ rv = saHpiSensorReadingConvert(sessionid, resourceid, sensornum, &reading, &conv_reading); if (rv != SA_OK) { printf("raw=%x conv_ret=%d\n", reading.Raw, rv); /* printf("conv_rv=%s\n", decode_error(rv)); */ return; } else { if (fdebug) printf("conv ok: raw=%x conv=%x\n", reading.Raw, conv_reading.Interpreted.Value.SensorUint32); reading.Interpreted.Type = conv_reading.Interpreted.Type; if (reading.Interpreted.Type == SAHPI_SENSOR_INTERPRETED_TYPE_BUFFER) { memcpy(reading.Interpreted.Value.SensorBuffer, conv_reading.Interpreted.Value.SensorBuffer, 4); /* SAHPI_SENSOR_BUFFER_LENGTH); */ /* IPMI 1.5 only returns 4 bytes */ } else reading.Interpreted.Value.SensorUint32 = conv_reading.Interpreted.Value.SensorUint32; } } } /* Also show units of interpreted reading */ i = sensorrec->DataFormat.BaseUnits; if (i >= NSU) i = 0; unit = units[i]; switch(reading.Interpreted.Type) { case SAHPI_SENSOR_INTERPRETED_TYPE_FLOAT32: printf(" = %5.2f %s\n", reading.Interpreted.Value.SensorFloat32,unit); break; case SAHPI_SENSOR_INTERPRETED_TYPE_UINT32: printf(" = %d %s\n", reading.Interpreted.Value.SensorUint32, unit); break; case SAHPI_SENSOR_INTERPRETED_TYPE_BUFFER: printf(" = %02x %02x %02x %02x\n", reading.Interpreted.Value.SensorBuffer[0], reading.Interpreted.Value.SensorBuffer[1], reading.Interpreted.Value.SensorBuffer[2], reading.Interpreted.Value.SensorBuffer[3]); break; default: printf(" = %x (itype=%x)\n", reading.Interpreted.Value.SensorUint32, reading.Interpreted.Type); } if (fshowthr) { #ifdef SHOWMAX if ( sensorrec->DataFormat.Range.Flags & SAHPI_SRF_MAX ) printf( " Max of Range: %5.2f\n", sensorrec->DataFormat.Range.Max.Interpreted.Value.SensorFloat32); if ( sensorrec->DataFormat.Range.Flags & SAHPI_SRF_MIN ) printf( " Min of Range: %5.2f\n", sensorrec->DataFormat.Range.Min.Interpreted.Value.SensorFloat32); #endif /* Show thresholds, if any */ if ((!sensorrec->Ignore) && (sensorrec->ThresholdDefn.IsThreshold)) { rv = saHpiSensorThresholdsGet(sessionid, resourceid, sensornum, &senstbuff); printf( "\t\t\t"); if ( sensorrec->ThresholdDefn.ReadThold & SAHPI_STM_LOW_MINOR ) { printf( "LoMin %5.2f ", senstbuff.LowMinor.Interpreted.Value.SensorFloat32); } if ( sensorrec->ThresholdDefn.ReadThold & SAHPI_STM_LOW_MAJOR ) { printf( "LoMaj %5.2f ", senstbuff.LowMajor.Interpreted.Value.SensorFloat32); } if ( sensorrec->ThresholdDefn.ReadThold & SAHPI_STM_LOW_CRIT ) { printf( "LoCri %5.2f ", senstbuff.LowCritical.Interpreted.Value.SensorFloat32); } if ( sensorrec->ThresholdDefn.ReadThold & SAHPI_STM_UP_MINOR ) { printf( "HiMin %5.2f ", senstbuff.UpMinor.Interpreted.Value.SensorFloat32); } if ( sensorrec->ThresholdDefn.ReadThold & SAHPI_STM_UP_MAJOR ) { printf( "HiMaj %5.2f ", senstbuff.UpMajor.Interpreted.Value.SensorFloat32); } if ( sensorrec->ThresholdDefn.ReadThold & SAHPI_STM_UP_CRIT ) { printf( "HiCri %5.2f ", senstbuff.UpCritical.Interpreted.Value.SensorFloat32); } #ifdef SHOWMAX if ( sensorrec->ThresholdDefn.ReadThold & SAHPI_STM_UP_HYSTERESIS ) { printf( "Hi Hys %5.2f ", senstbuff.PosThdHysteresis.Interpreted.Value.SensorFloat32); } if ( sensorrec->ThresholdDefn.ReadThold & SAHPI_STM_LOW_HYSTERESIS ) { printf( "Lo Hys %5.2f ", senstbuff.NegThdHysteresis.Interpreted.Value.SensorFloat32); } #endif printf( "\n"); } /* endif valid threshold */ } /* endif showthr */ return; } /*end ShowSensor*/
/* * This routine get sensor reading and threshold, and display them. * **/ static void sensor_readingthreshold(SaHpiSessionIdT sessionid, SaHpiResourceIdT resourceid, SaHpiRdrT *rdrptr) { SaHpiSensorRecT *sensorrec; SaHpiSensorNumT sensornum; SaHpiSensorReadingT reading; SaHpiSensorThresholdsT thresh; SaHpiEventStateT events; SaHpiTextBufferT text; SaErrorT rv; sensorrec = &rdrptr->RdrTypeUnion.SensorRec; sensornum = sensorrec->Num; rv = saHpiSensorReadingGet(sessionid,resourceid, sensornum, &reading, &events); if (rv != SA_OK) { printf("\nReadingGet ret=%s\n", oh_lookup_error(rv)); return; } if (!reading.IsSupported ) { printf("\t Reading Not Supported for sensor %d!\n\n", sensornum); return; } if((rv = oh_decode_sensorreading(reading, sensorrec->DataFormat, &text)) == SA_OK) { printf("\t Sensor %d reading = %s\n", sensornum, text.Data); } else { printf("\n\t Sensor %d Reading FAILED, %s\n", sensornum, oh_lookup_error(rv)); } rv = saHpiSensorThresholdsGet(sessionid,resourceid, sensornum, &thresh); if (rv != SA_OK) { printf("\t ThresholdsGet ret=%s\n\n", oh_lookup_error(rv)); return; } printf( "\t Thresholds::\n" ); if (thresh.LowCritical.IsSupported) { if((rv = oh_decode_sensorreading(thresh.LowCritical, sensorrec->DataFormat, &text)) == SA_OK) { printf( "\t\tLow Critical Threshold: %s\n", text.Data); } else { printf( "\t\tLow Critical Threshold: FAILED %s\n", oh_lookup_error(rv)); } } if (thresh.LowMajor.IsSupported) { if((rv = oh_decode_sensorreading(thresh.LowMajor, sensorrec->DataFormat, &text)) == SA_OK) { printf( "\t\tLow Major Threshold: %s\n", text.Data); } else { printf( "\t\tLow Major Threshold: FAILED %s\n", oh_lookup_error(rv)); } } if (thresh.LowMinor.IsSupported) { if((rv = oh_decode_sensorreading(thresh.LowMinor, sensorrec->DataFormat, &text)) == SA_OK) { printf( "\t\tLow Minor Threshold: %s\n", text.Data); } else { printf( "\t\tLow Minor Threshold: FAILED %s\n", oh_lookup_error(rv)); } } if (thresh.UpCritical.IsSupported) { if((rv = oh_decode_sensorreading(thresh.UpCritical, sensorrec->DataFormat, &text)) == SA_OK) { printf( "\t\tUp Critical Threshold: %s\n", text.Data); } else { printf( "\t\tUp Critical Threshold: FAILED %s\n", oh_lookup_error(rv)); } } if (thresh.UpMajor.IsSupported) { if((rv = oh_decode_sensorreading(thresh.UpMajor, sensorrec->DataFormat, &text)) == SA_OK) { printf( "\t\tUp Major Threshold: %s\n", text.Data); } else { printf( "\t\tUp Major Threshold: FAILED %s\n", oh_lookup_error(rv)); } } if (thresh.UpMinor.IsSupported) { if((rv = oh_decode_sensorreading(thresh.UpMinor, sensorrec->DataFormat, &text)) == SA_OK) { printf( "\t\tUp Minor Threshold: %s\n", text.Data); } else { printf( "\t\tUp Minor Threshold: FAILED %s\n", oh_lookup_error(rv)); } } if (thresh.PosThdHysteresis.IsSupported) { if((rv = oh_decode_sensorreading(thresh.PosThdHysteresis, sensorrec->DataFormat, &text)) == SA_OK) { printf( "\t\tPos Threshold Hysteresis: %s\n", text.Data); } else { printf( "\t\tPos Threshold Hysteresis: FAILED %s\n", oh_lookup_error(rv)); } } if (thresh.NegThdHysteresis.IsSupported) { if((rv = oh_decode_sensorreading(thresh.NegThdHysteresis, sensorrec->DataFormat, &text)) == SA_OK) { printf( "\t\tNeg Threshold Hysteresis: %s\n", text.Data); } else { printf( "\t\tNeg Threshold Hysteresis: FAILED %s\n", oh_lookup_error(rv)); } } printf("\n\n\n"); }
/************************************************************ * saHpiSensorThdNegHysteresisTable_get_value * * This routine is called for get requests to copy the data * from the context to the varbind for the request. If the * context has been properly maintained, you don't need to * change in code in this fuction. */ int saHpiSensorThdNegHysteresisTable_get_value (netsnmp_request_info * request, netsnmp_index * item, netsnmp_table_request_info * table_info) { netsnmp_variable_list *var = request->requestvb; saHpiSensorThdNegHysteresisTable_context *context = (saHpiSensorThdNegHysteresisTable_context *) item; #ifdef GET_ROUTINE_CALLS_SNMP_GET SaHpiSensorThresholdsT sensor_threshold; SaHpiSessionIdT session_id; int rc = AGENT_ERR_NOERROR; rc = getSaHpiSession (&session_id); if (rc != AGENT_ERR_NOERROR) { DEBUGMSGTL ((AGENT, "Call to getSaHpiSession failed with rc: %d\n", rc)); } rc = saHpiSensorThresholdsGet (session_id, context->resource_id, context->sensor_id, &sensor_threshold); if (rc != SA_OK) { snmp_log (LOG_ERR, "Call to saHpiSensorThresholdsGet fails with return code: %s.\n", get_error_string (rc)); DEBUGMSGTL ((AGENT, "Call to SensorThresholdGet fails with return code: %s.\n", get_error_string (rc))); return AGENT_ERR_OPERATION; } if (rc == AGENT_ERR_NOERROR) { modify_saHpiSensorThdNegHysteresisTable_row (context->domain_id, context->resource_id, context->sensor_id, NULL, &sensor_threshold. NegThdHysteresis, context); } #endif switch (table_info->colnum) { case COLUMN_SAHPISENSORTHDNEGHYSTERESISICALISREADABLE: /** TruthValue = ASN_INTEGER */ snmp_set_var_typed_value (var, ASN_INTEGER, (char *) &context-> saHpiSensorThdNegHysteresisIsReadable, sizeof (context-> saHpiSensorThdNegHysteresisIsReadable)); break; case COLUMN_SAHPISENSORTHDNEGHYSTERESISICALISWRITABLE: /** TruthValue = ASN_INTEGER */ snmp_set_var_typed_value (var, ASN_INTEGER, (char *) &context-> saHpiSensorThdNegHysteresisIsWritable, sizeof (context-> saHpiSensorThdNegHysteresisIsWritable)); break; case COLUMN_SAHPISENSORTHDNEGHYSTERESISICALISFIXED: /** TruthValue = ASN_INTEGER */ snmp_set_var_typed_value (var, ASN_INTEGER, (char *) &context-> saHpiSensorThdNegHysteresisIsFixed, sizeof (context-> saHpiSensorThdNegHysteresisIsFixed)); break; case COLUMN_SAHPISENSORTHDNEGHYSTERESISICALVALUESPRESENT: /** INTEGER = ASN_INTEGER */ snmp_set_var_typed_value (var, ASN_INTEGER, (char *) &context-> saHpiSensorThdNegHysteresisValuesPresent, sizeof (context-> saHpiSensorThdNegHysteresisValuesPresent)); break; case COLUMN_SAHPISENSORTHDNEGHYSTERESISICALRAW: /** UNSIGNED32 = ASN_UNSIGNED */ if (context->saHpiSensorThdNegHysteresisIsReadable == MIB_TRUE) snmp_set_var_typed_value (var, ASN_UNSIGNED, (char *) &context-> saHpiSensorThdNegHysteresisRaw, sizeof (context-> saHpiSensorThdNegHysteresisRaw)); break; case COLUMN_SAHPISENSORTHDNEGHYSTERESISICALINTERPRETED: /** OCTETSTR = ASN_OCTET_STR */ if (context->saHpiSensorThdNegHysteresisIsReadable == MIB_TRUE) snmp_set_var_typed_value (var, ASN_OCTET_STR, (char *) &context-> saHpiSensorThdNegHysteresisInterpreted, context-> saHpiSensorThdNegHysteresisInterpreted_len); break; default: /** We shouldn't get here */ snmp_log (LOG_ERR, "unknown column in " "saHpiSensorThdNegHysteresisTable_get_value\n"); return SNMP_ERR_GENERR; } return SNMP_ERR_NOERROR; }
int populate_sensor (SaHpiEntryIdT rdr_id, SaHpiSensorRecT * sensor, SaHpiRptEntryT * rpt_entry, oid * rdr_entry_oid, size_t rdr_entry_oid_len, oid * sensor_oid, size_t * sensor_oid_len) { int rc = AGENT_ERR_NOERROR; oid index_oid[SENSOR_INDEX_NR]; oid column[2]; netsnmp_index sensor_index; #ifdef BUG_873961 int i = 0; netsnmp_void_array *array; saHpiSensorTable_context *ctx; #endif saHpiSensorTable_context *sensor_context; SaHpiSensorThresholdsT sensor_threshold; SaHpiSessionIdT session_id; SaHpiSensorEvtEnablesT enables; SaHpiSensorReadingT current_reading; DEBUGMSGTL ((AGENT, "\n\t--- populate_sensor: Entry.\n")); if (sensor) { sensor_index.len = SENSOR_INDEX_NR; // Look at the MIB to find out what the indexs are index_oid[0] = rpt_entry->DomainId; index_oid[1] = rpt_entry->ResourceId; index_oid[2] = sensor->Num; sensor_index.oids = (oid *) & index_oid; // We are re-populating. Check for existing entries sensor_context = NULL; sensor_context = CONTAINER_FIND (cb.container, &sensor_index); // If we don't find it - we create it. #ifdef BUG_873961 if (!sensor_context) { // Bug # 873961. We use the 'rdr_id' to check to see if // it is the context. To do so, we have to search for it first. sensor_index.len = 1; // re-using the index_oid. array = CONTAINER_GET_SUBSET (cb.container, &sensor_index); if (array != NULL) { if (array->size > 0) { for (i = 0; i < array->size; i++) { ctx = array->array[i]; if (ctx->rdr_id == rdr_id) { // Found the duplicate entry! sensor_context = ctx; index_oid[1] = ctx->resource_id; index_oid[2] = ctx->saHpiSensorIndex; DEBUGMSGTL ((AGENT, "duplicate sensor entry %d, %d, %d [rdr: %d] found.\n", rpt_entry->DomainId, rpt_entry->ResourceId, sensor->Num, rdr_id)); break; } } } free (array->array); free (array); array = NULL; } // restoree it to its previous glory. sensor_index.len = SENSOR_INDEX_NR; } #endif if (!sensor_context) { // New entry. Add it sensor_context = saHpiSensorTable_create_row (&sensor_index); } if (!sensor_context) { snmp_log (LOG_ERR, "Not enough memory for a sensor row!"); return AGENT_ERR_INTERNAL_ERROR; } // Generate our full OID column[0] = 1; column[1] = COLUMN_SAHPISENSORINDEX; build_full_oid (saHpiSensorTable_oid, saHpiSensorTable_oid_len, column, 2, &sensor_index, sensor_oid, MAX_OID_LEN, sensor_oid_len); // By this stage, sensor_context surely has something in it. // '*_modify_context' does a checksum check to see if // the record needs to be altered, and if so populates with // information from RDR and the OIDs passed. // Get Threshold Data rc = getSaHpiSession (&session_id); if (rc != AGENT_ERR_NOERROR) { DEBUGMSGTL ((AGENT, "Call to getSaHpiSession failed with rc: %d\n", rc)); return rc; } if (sensor->ThresholdDefn.IsThreshold == SAHPI_TRUE) { rc = saHpiSensorThresholdsGet (session_id, rpt_entry->ResourceId, sensor->Num, &sensor_threshold); if (rc != SA_OK) { snmp_log (LOG_ERR, "Call to saHpiSensorThresholdsGet fails with return code: %s.\n", get_error_string (rc)); DEBUGMSGTL ((AGENT, "Call to SensorThresholdGet fails with return code: %s.\n", get_error_string (rc))); return AGENT_ERR_OPERATION; } } /* * No need to call a plugin that does not support * events. */ if (sensor->EventCtrl != SAHPI_SEC_NO_EVENTS) { rc = saHpiSensorEventEnablesGet (session_id, rpt_entry->ResourceId, sensor->Num, &enables); if (rc != SA_OK) { snmp_log (LOG_ERR, "Call to saHpiSensorEventEnablesGet fails with return code: %s.\n", get_error_string (rc)); DEBUGMSGTL ((AGENT, "Call to saHpiSensorEventEnablesGet fails with return code: %s.\n", get_error_string (rc))); // We continue on working. No need to bail on that one - will just use 'undefined(0)' values. } } rc = saHpiSensorReadingGet (session_id, rpt_entry->ResourceId, sensor->Num, ¤t_reading); if (rc != SA_OK) { snmp_log (LOG_ERR, "Call to saHpiSensorReadingGet fails with return code: %s.\n", get_error_string (rc)); DEBUGMSGTL ((AGENT, "Call to saHpiSensorReadingGet fails with return code: %s.\n", get_error_string (rc))); } if (saHpiSensorTable_modify_context (rdr_id, sensor, &enables, rpt_entry, rdr_entry_oid, rdr_entry_oid_len, sensor_context) == AGENT_NEW_ENTRY) { CONTAINER_INSERT (cb.container, sensor_context); sensor_count = CONTAINER_SIZE (cb.container); } /* Update our child sensor tables */ rc = populate_ReadingCurrent (rpt_entry->DomainId, rpt_entry->ResourceId, sensor->Num, sensor->Category, ¤t_reading); if (rc != AGENT_ERR_NOERROR) DEBUGMSGTL ((AGENT, "call to populate_ReadingCurrent failed with rc: %d\n", rc)); if (sensor_context->flags & SAHPI_SRF_MIN) { rc = populate_ReadingMin (rpt_entry->DomainId, rpt_entry->ResourceId, sensor->Num, sensor->Category, &sensor->DataFormat.Range.Min); if (rc != AGENT_ERR_NOERROR) DEBUGMSGTL ((AGENT, "call to populate_ReadingMin failed with rc: %d\n", rc)); } if (sensor_context->flags & SAHPI_SRF_MAX) { rc = populate_ReadingMax (rpt_entry->DomainId, rpt_entry->ResourceId, sensor->Num, sensor->Category, &sensor->DataFormat.Range.Max); if (rc != AGENT_ERR_NOERROR) DEBUGMSGTL ((AGENT, "call to populate_ReadingMax failed with rc: %d\n", rc)); } if (sensor_context->flags & SAHPI_SRF_NOMINAL) { rc = populate_ReadingNominal (rpt_entry->DomainId, rpt_entry->ResourceId, sensor->Num, sensor->Category, &sensor->DataFormat.Range.Nominal); if (rc != AGENT_ERR_NOERROR) DEBUGMSGTL ((AGENT, "call to populate_ReadingNominal failed with rc: %d\n", rc)); } if (sensor_context->flags & SAHPI_SRF_NORMAL_MAX) { rc = populate_ReadingNormalMax (rpt_entry->DomainId, rpt_entry->ResourceId, sensor->Num, sensor->Category, &sensor->DataFormat.Range. NormalMax); if (rc != AGENT_ERR_NOERROR) DEBUGMSGTL ((AGENT, "call to populate_ReadingNormalMax failed with rc: %d\n", rc)); } if (sensor_context->flags & SAHPI_SRF_NORMAL_MIN) { rc = populate_ReadingNormalMin (rpt_entry->DomainId, rpt_entry->ResourceId, sensor->Num, sensor->Category, &sensor->DataFormat.Range. NormalMin); if (rc != AGENT_ERR_NOERROR) DEBUGMSGTL ((AGENT, "call to populate_ReadingNormalMin failed with rc: %d\n", rc)); } /* * Thresholds */ if (sensor_context->saHpiSensorHasThresholds == MIB_TRUE) { /* if (sensor_context->thd_capabilities & SAHPI_STM_LOW_CRIT) */ { rc = populate_ThdLowCritical (rpt_entry->DomainId, rpt_entry->ResourceId, sensor->Num, &sensor->ThresholdDefn, &sensor_threshold.LowCritical); if (rc != AGENT_ERR_NOERROR) DEBUGMSGTL ((AGENT, "call to populate_ThdLowCritical failed with rc: %d\n", rc)); } /* if (sensor_context->thd_capabilities & SAHPI_STM_LOW_MAJOR) */ { rc = populate_ThdLowMajor (rpt_entry->DomainId, rpt_entry->ResourceId, sensor->Num, &sensor->ThresholdDefn, &sensor_threshold.LowMajor); if (rc != AGENT_ERR_NOERROR) DEBUGMSGTL ((AGENT, "call to populate_ThdLowMajor failed with rc: %d\n", rc)); } /* if (sensor_context->thd_capabilities & SAHPI_STM_LOW_MINOR) */ { rc = populate_ThdLowMinor (rpt_entry->DomainId, rpt_entry->ResourceId, sensor->Num, &sensor->ThresholdDefn, &sensor_threshold.LowMinor); if (rc != AGENT_ERR_NOERROR) DEBUGMSGTL ((AGENT, "call to populate_ThdLowMinor failed with rc: %d\n", rc)); } /* if (sensor_context->thd_capabilities & SAHPI_STM_UP_CRIT) */ { rc = populate_ThdUpCritical (rpt_entry->DomainId, rpt_entry->ResourceId, sensor->Num, &sensor->ThresholdDefn, &sensor_threshold.UpCritical); if (rc != AGENT_ERR_NOERROR) DEBUGMSGTL ((AGENT, "call to populate_ThdUpCritical failed with rc: %d\n", rc)); } /* if (sensor_context->thd_capabilities & SAHPI_STM_UP_MAJOR) */ { rc = populate_ThdUpMajor (rpt_entry->DomainId, rpt_entry->ResourceId, sensor->Num, &sensor->ThresholdDefn, &sensor_threshold.UpMajor); if (rc != AGENT_ERR_NOERROR) DEBUGMSGTL ((AGENT, "call to populate_ThdUpMajor failed with rc: %d\n", rc)); } /* if (sensor_context->thd_capabilities & SAHPI_STM_UP_MINOR) */ { rc = populate_ThdUpMinor (rpt_entry->DomainId, rpt_entry->ResourceId, sensor->Num, &sensor->ThresholdDefn, &sensor_threshold.UpMinor); if (rc != AGENT_ERR_NOERROR) DEBUGMSGTL ((AGENT, "call to populate_ThdUpMinor failed with rc: %d\n", rc)); } /* if (sensor_context->thd_capabilities & SAHPI_STM_UP_HYSTERESIS) */ { rc = populate_ThdPosHysteresis (rpt_entry->DomainId, rpt_entry->ResourceId, sensor->Num, &sensor->ThresholdDefn, &sensor_threshold. PosThdHysteresis); if (rc != AGENT_ERR_NOERROR) DEBUGMSGTL ((AGENT, "call to populate_ThdPosHysteresis failed with rc: %d\n", rc)); } /* if (sensor_context->thd_capabilities & SAHPI_STM_LOW_HYSTERESIS) */ { rc = populate_ThdNegHysteresis (rpt_entry->DomainId, rpt_entry->ResourceId, sensor->Num, &sensor->ThresholdDefn, &sensor_threshold. NegThdHysteresis); if (rc != AGENT_ERR_NOERROR) DEBUGMSGTL ((AGENT, "call to populate_ThdNegHysteresis failed with rc: %d\n", rc)); } } rc = AGENT_ERR_NOERROR; } else rc = AGENT_ERR_OPERATION; DEBUGMSGTL ((AGENT, "\n\t--- populate_sensor. Exit\n")); return rc; }
static void dordr(SaHpiSessionIdT sessionid, SaHpiResourceIdT resourceid, SaHpiRdrT *rdr) { SaHpiSensorReadingT reading; SaHpiSensorThresholdsT thres; SaHpiSensorRecT *rec; SaErrorT rv; if ( (rdr->RdrType == SAHPI_SENSOR_RDR) && !strcmp(sensor_name, gettext(&rdr->IdString))) { rec = &rdr->RdrTypeUnion.SensorRec; rv = saHpiSensorReadingGet(sessionid, resourceid, rec->Num, &reading); if (rv != SA_OK) { printf( "saHpiSensorReadingGet error %d\n",rv); return; } printf("sensor(%s)\n",gettext(&rdr->IdString)); printf("current reading:"); reading_print(&reading); printf("\n"); rv = saHpiSensorThresholdsGet(sessionid, resourceid, rec->Num, &thres); if (rv != SA_OK) { printf( "saHpiSensorThresholdsGet error %d\n",rv); return; } printf("current threshold:\n"); thres_print(&thres); if (have_minor) { struct timeval tv; thres.LowMinor.ValuesPresent = SAHPI_SRF_INTERPRETED; thres.LowMinor.Interpreted.Type = SAHPI_SENSOR_INTERPRETED_TYPE_FLOAT32; thres.LowMinor.Interpreted.Value.SensorFloat32 = minor_value; if (have_major) { thres.LowMajor.ValuesPresent = SAHPI_SRF_INTERPRETED; thres.LowMajor.Interpreted.Type = SAHPI_SENSOR_INTERPRETED_TYPE_FLOAT32; thres.LowMajor.Interpreted.Value.SensorFloat32 = major_value; } gettimeofday(&tv, NULL); printf("set thres at :%ld\n", tv.tv_sec); rv = saHpiSensorThresholdsSet(sessionid, resourceid, rec->Num, &thres); if (rv != SA_OK) { printf( "saHpiSensorThresholdsSet error %d\n",rv); return; } } exit(0); } }
int set_ThdPosHysteresis (saHpiSensorThdPosHysteresisTable_context *ctx) { SaHpiSensorThresholdsT thd; SaHpiSessionIdT session_id; SaErrorT rc; DEBUGMSGTL ((AGENT, "set_ThdPosHysteresis: Entry.\n")); if (ctx) { memset (&thd, 0x00, sizeof (SaHpiSensorThresholdsT)); rc = getSaHpiSession (&session_id); if (rc != AGENT_ERR_NOERROR) { DEBUGMSGTL ((AGENT, "Call to getSaHpiSession failed with rc: %d\n", rc)); return rc; } /* * Get the current threshold information */ DEBUGMSGTL((AGENT,"resource_id: %d, sensor_id: %d\n", ctx->resource_id, ctx->sensor_id)); rc = saHpiSensorThresholdsGet (session_id, ctx->resource_id, ctx->sensor_id, &thd); if (rc != SA_OK) { snmp_log (LOG_ERR, "Call to saHpiSensorThresholdGet fails with return code: %s.\n", get_error_string (rc)); DEBUGMSGTL ((AGENT, "Call to saHpiSensorThresholdsGet fails with return code: %s\n", get_error_string (rc))); return AGENT_ERR_OPERATION; } /* Posdate the correct entry. */ if (thd.PosThdHysteresis.ValuesPresent & SAHPI_SRF_INTERPRETED) { thd.PosThdHysteresis.Interpreted.Type = SAHPI_SENSOR_INTERPRETED_TYPE_BUFFER; memcpy(&thd.PosThdHysteresis.Interpreted.Value.SensorBuffer, &ctx->saHpiSensorThdPosHysteresisInterpreted, ctx->saHpiSensorThdPosHysteresisInterpreted_len); } if (thd.PosThdHysteresis.ValuesPresent & SAHPI_SRF_RAW) { thd.PosThdHysteresis.Raw = ctx->saHpiSensorThdPosHysteresisRaw; } /* * Set the thresholds */ rc = saHpiSensorThresholdsSet (session_id, ctx->resource_id, ctx->sensor_id, &thd); if (rc != SA_OK) { snmp_log (LOG_ERR, "Call to saHpiSensorThresholdSet fails with return code: %s.\n", get_error_string (rc)); DEBUGMSGTL ((AGENT, "Call to saHpiSensorThresholdsSet fails with return code: %s\n", get_error_string (rc))); return AGENT_ERR_OPERATION; } /* * Re-read the data. Might be different, so we will need * to populate the ctx. */ memset (&thd, 0x00, sizeof (SaHpiSensorThresholdsT)); rc = saHpiSensorThresholdsGet (session_id, ctx->resource_id, ctx->sensor_id, &thd); if (rc != SA_OK) { snmp_log (LOG_ERR, "Call to SensorThresholdGet fails with return code: %s.\n", get_error_string (rc)); DEBUGMSGTL ((AGENT, "Call to SensorThresholdGet fails with return code: %s.\n", get_error_string (rc))); return AGENT_ERR_OPERATION; } build_reading_strings (&thd.PosThdHysteresis, 0, &ctx->saHpiSensorThdPosHysteresisValuesPresent, &ctx->saHpiSensorThdPosHysteresisRaw, ctx->saHpiSensorThdPosHysteresisInterpreted, &ctx->saHpiSensorThdPosHysteresisInterpreted_len, SENSOR_THD_INTER_MAX, NULL, NULL, NULL, 0); DEBUGMSGTL ((AGENT, "set_ThdPosHysteresis: Exit.\n")); return AGENT_ERR_NOERROR; } DEBUGMSGTL ((AGENT, "set_sensor: Exit.\n")); return AGENT_ERR_NULL_DATA; }
static int sa_set_thres(int argc, char *argv[]) { SaHpiResourceIdT resourceid; SaHpiSensorNumT sensornum; SaErrorT rv; SaHpiSensorThresholdsT stbuff; int i; resourceid = (SaHpiResourceIdT)atoi(argv[1]); sensornum = (SaHpiResourceIdT)atoi(argv[2]); rv = saHpiSensorThresholdsGet(sessionid, resourceid, sensornum, &stbuff); if (rv != SA_OK) printf("saHpiSensorThresholdsGet error %d\n",rv); for (i=3; i<argc; i+=2) { if (!argv[i+1]) { return HPI_SHELL_PARM_ERROR; } printf("%s", argv[i]); if (!strcmp(argv[i],"lc")) { stbuff.LowCritical.ValuesPresent = SAHPI_SRF_INTERPRETED; stbuff.LowCritical.Interpreted.Value.SensorFloat32 = (SaHpiFloat32T)atof(argv[i+1]); } else if (!strcmp(argv[i],"la")) { stbuff.LowMajor.ValuesPresent = SAHPI_SRF_INTERPRETED; stbuff.LowMajor.Interpreted.Value.SensorFloat32 = (SaHpiFloat32T)atof(argv[i+1]); } else if (!strcmp(argv[i],"li")) { stbuff.LowMinor.ValuesPresent = SAHPI_SRF_INTERPRETED; stbuff.LowMinor.Interpreted.Value.SensorFloat32 = (SaHpiFloat32T)atof(argv[i+1]); } else if (!strcmp(argv[i],"uc")) { stbuff.UpCritical.ValuesPresent = SAHPI_SRF_INTERPRETED; stbuff.UpCritical.Interpreted.Value.SensorFloat32 = (SaHpiFloat32T)atof(argv[i+1]); } else if (!strcmp(argv[i],"ua")) { stbuff.UpMajor.ValuesPresent = SAHPI_SRF_INTERPRETED; stbuff.UpMajor.Interpreted.Value.SensorFloat32 = (SaHpiFloat32T)atof(argv[i+1]); } else if (!strcmp(argv[i],"ui")) { stbuff.UpMinor.ValuesPresent = SAHPI_SRF_INTERPRETED; stbuff.UpMinor.Interpreted.Value.SensorFloat32 = (SaHpiFloat32T)atof(argv[i+1]); } else if (!strcmp(argv[i],"ph")) { stbuff.PosThdHysteresis.ValuesPresent = SAHPI_SRF_INTERPRETED; stbuff.PosThdHysteresis.Interpreted.Value.SensorFloat32 = (SaHpiFloat32T)atof(argv[i+1]); } else if (!strcmp(argv[i],"nh")) { stbuff.NegThdHysteresis.ValuesPresent = SAHPI_SRF_INTERPRETED; stbuff.NegThdHysteresis.Interpreted.Value.SensorFloat32 = (SaHpiFloat32T)atof(argv[i+1]); } else { return HPI_SHELL_PARM_ERROR; } } rv = saHpiSensorThresholdsSet( sessionid, resourceid, sensornum, &stbuff); if (rv != SA_OK) printf("saHpiSensorThresholdsSet error %d\n",rv); else printf("Sensor Threshold Value Set Succeed.\n"); return SA_OK; }
/* * SaErrorT populate_sensor() */ SaErrorT populate_sensor(SaHpiSessionIdT sessionid, SaHpiRdrT *rdr_entry, SaHpiRptEntryT *rpt_entry, oid *full_oid, size_t full_oid_len, oid *child_oid, size_t *child_oid_len) { DEBUGMSGTL ((AGENT, "populate_sensor, called\n")); SaErrorT rv = SA_OK; SaHpiTextBufferT buffer; SaHpiSensorThresholdsT sensor_thresholds; oid sensor_oid[SENSOR_INDEX_NR]; netsnmp_index sensor_index; saHpiSensorTable_context *sensor_context; oid column[2]; int column_len = 2; DEBUGMSGTL ((AGENT, "SAHPI_SENSOR_RDR populate_sensor() called\n")); /* check for NULL pointers */ if (!rdr_entry) { DEBUGMSGTL ((AGENT, "ERROR: populate_sensor() passed NULL rdr_entry pointer\n")); return AGENT_ERR_INTERNAL_ERROR; } if (!rpt_entry) { DEBUGMSGTL ((AGENT, "ERROR: populate_sensor() passed NULL rdr_entry pointer\n")); return AGENT_ERR_INTERNAL_ERROR; } /* BUILD oid for new row */ /* assign the number of indices */ sensor_index.len = SENSOR_INDEX_NR; /** Index saHpiDomainId is external */ sensor_oid[0] = get_domain_id(sessionid); /** Index saHpiResourceId is external */ sensor_oid[1] = rpt_entry->ResourceId; /** Index saHpiResourceIsHistorical is external */ sensor_oid[2] = MIB_FALSE; /** Index saHpiSensorNum */ sensor_oid[3] = rdr_entry->RdrTypeUnion.SensorRec.Num; /* assign the indices to the index */ sensor_index.oids = (oid *) & sensor_oid; /* create full oid on This row for parent RowPointer */ column[0] = 1; column[1] = COLUMN_SAHPISENSORNUM; memset(child_oid, 0, sizeof(child_oid_len)); build_full_oid(saHpiSensorTable_oid, saHpiSensorTable_oid_len, column, column_len, &sensor_index, child_oid, MAX_OID_LEN, child_oid_len); /* See if Row exists. */ sensor_context = NULL; sensor_context = CONTAINER_FIND(cb.container, &sensor_index); if (!sensor_context) { // New entry. Add it sensor_context = saHpiSensorTable_create_row(&sensor_index); } if (!sensor_context) { snmp_log (LOG_ERR, "Not enough memory for a Sensor row!"); return AGENT_ERR_INTERNAL_ERROR; } /** SaHpiInstrumentId = ASN_UNSIGNED */ sensor_context->saHpiSensorNum = rdr_entry->RdrTypeUnion.SensorRec.Num; /** SaHpiSensorType = ASN_INTEGER */ sensor_context->saHpiSensorReadingType = rdr_entry->RdrTypeUnion.SensorRec.Type + 1; /** SaHpiEventCategory = ASN_INTEGER */ sensor_context->saHpiSensorCategory = rdr_entry->RdrTypeUnion.SensorRec.Category + 1; /** TruthValue = ASN_INTEGER */ sensor_context->saHpiSensorEnableCtrl = (rdr_entry->RdrTypeUnion.SensorRec.EnableCtrl == SAHPI_TRUE) ? MIB_TRUE : MIB_FALSE; /** INTEGER = ASN_INTEGER */ sensor_context->saHpiSensorEventCtrl = rdr_entry->RdrTypeUnion.SensorRec.EventCtrl + 1; /** SaHpiEventState = ASN_OCTET_STR */ memset(&buffer, 0, sizeof(buffer)); rv = oh_decode_eventstate(rdr_entry->RdrTypeUnion.SensorRec.Events, rdr_entry->RdrTypeUnion.SensorRec.Category, &buffer); oh_decode_char(&buffer); if (rv != SA_OK) { DEBUGMSGTL ((AGENT, "ERROR: populate_sensor() oh_decode_eventstate() ERRORED out\n")); saHpiSensorTable_delete_row( sensor_context ); return AGENT_ERR_INTERNAL_ERROR; } memset(sensor_context->saHpiSensorSupportedEventStates, 0, sizeof(sensor_context->saHpiSensorSupportedEventStates)); memcpy(sensor_context->saHpiSensorSupportedEventStates, buffer.Data, buffer.DataLength); sensor_context->saHpiSensorSupportedEventStates_len = buffer.DataLength; /** TruthValue = ASN_INTEGER */ sensor_context->saHpiSensorIsSupported = rdr_entry->RdrTypeUnion.SensorRec.DataFormat.IsSupported; /** SaHpiSensorReadingType = ASN_INTEGER */ sensor_context->saHpiSensorReadingType = rdr_entry->RdrTypeUnion.SensorRec.DataFormat.ReadingType + 1; /** SaHpiSensorUnits = ASN_INTEGER */ sensor_context->saHpiSensorBaseUnits = rdr_entry->RdrTypeUnion.SensorRec.DataFormat.BaseUnits + 1; /** SaHpiSensorUnits = ASN_INTEGER */ sensor_context->saHpiSensorBaseUnits = rdr_entry->RdrTypeUnion.SensorRec.DataFormat.ModifierUnits + 1; /** INTEGER = ASN_INTEGER */ sensor_context->saHpiSensorModifierUse = rdr_entry->RdrTypeUnion.SensorRec.DataFormat.ModifierUse + 1; /** TruthValue = ASN_INTEGER */ sensor_context->saHpiSensorPercentage = (rdr_entry->RdrTypeUnion.SensorRec.DataFormat.Percentage == SAHPI_TRUE) ? MIB_TRUE : MIB_FALSE; /** OCTETSTR = ASN_OCTET_STR */ rv = decode_sensor_range_flags(&buffer, rdr_entry->RdrTypeUnion.SensorRec.DataFormat.Range.Flags); if (rv != SA_OK) { DEBUGMSGTL ((AGENT, "ERROR: populate_sensor() decode_sensor_range_flags() ERROR'd out\n")); saHpiSensorTable_delete_row( sensor_context ); return AGENT_ERR_INTERNAL_ERROR; } memcpy(sensor_context->saHpiSensorRangeFlags, buffer.Data, buffer.DataLength); sensor_context->saHpiSensorRangeFlags_len = buffer.DataLength; /** Double = ASN_OCTET_STR */ memset(sensor_context->saHpiSensorAccuracyFactor, 0, sizeof(SaHpiFloat64T)); memcpy(sensor_context->saHpiSensorAccuracyFactor, &rdr_entry->RdrTypeUnion.SensorRec.DataFormat.AccuracyFactor, sizeof(SaHpiFloat64T)); sensor_context->saHpiSensorAccuracyFactor_len = sizeof(SaHpiFloat64T); /** UNSIGNED32 = ASN_UNSIGNED */ sensor_context->saHpiSensorOem = rdr_entry->RdrTypeUnion.SensorRec.Oem; /** RowPointer = ASN_OBJECT_ID */ memset(sensor_context->saHpiSensorRDR, 0, sizeof(sensor_context->saHpiSensorRDR)); sensor_context->saHpiSensorRDR_len = full_oid_len * sizeof(oid); memcpy(sensor_context->saHpiSensorRDR, full_oid, sensor_context->saHpiSensorRDR_len); /* populate the range reading tables */ rv = populate_sensor_max(sessionid, rdr_entry, rpt_entry); rv = populate_sensor_min(sessionid, rdr_entry, rpt_entry); rv = populate_sensor_nominal(sessionid, rdr_entry, rpt_entry); rv = populate_sensor_normal_max(sessionid, rdr_entry, rpt_entry); rv = populate_sensor_normal_min(sessionid, rdr_entry, rpt_entry); /* populate the threshold reading tables */ rv = saHpiSensorThresholdsGet(sessionid, rpt_entry->ResourceId, rdr_entry->RdrTypeUnion.SensorRec.Num, &sensor_thresholds); if (rv == SA_OK) { rv = populate_sen_thd_low_crit(sessionid, rdr_entry, rpt_entry, &sensor_thresholds); rv = populate_sen_thd_low_major(sessionid, rdr_entry, rpt_entry, &sensor_thresholds); rv = populate_sen_thd_low_minor(sessionid, rdr_entry, rpt_entry, &sensor_thresholds); rv = populate_sen_thd_up_crit(sessionid, rdr_entry, rpt_entry, &sensor_thresholds); rv = populate_sen_thd_up_major(sessionid, rdr_entry, rpt_entry, &sensor_thresholds); rv = populate_sen_thd_up_minor(sessionid, rdr_entry, rpt_entry, &sensor_thresholds); rv = populate_sen_thd_pos_hys(sessionid, rdr_entry, rpt_entry, &sensor_thresholds); rv = populate_sen_thd_neg_hys(sessionid, rdr_entry, rpt_entry, &sensor_thresholds); } else { snmp_log (LOG_ERR, "Call to saHpiResourceSeverity failed with return code: %s.\n", oh_lookup_error(rv)); DEBUGMSGTL ((AGENT, "ERROR: populate_sen_thd_low_crit() saHpiSensorThresholdsGet() ERROR: %s\n", oh_lookup_error(rv))); } CONTAINER_INSERT (cb.container, sensor_context); sensor_entry_count = CONTAINER_SIZE (cb.container); return rv; }
cOpenHpiDaemon::tResult cOpenHpiDaemon::HandleMsg( cConnection *c, const cMessageHeader &header, const void *data, cMessageHeader &rh, void *&rd ) { cHpiMarshal *hm = HpiMarshalFind( header.m_id ); // check for function and data length if ( !hm || hm->m_request_len < header.m_len ) { //MessageHeaderInit( &rh, eMhError, header.m_seq, 0, 0 ); //rd = 0; fprintf( stderr, "wrong message length: id %d !\n", header.m_id ); return eResultError; } assert( hm->m_reply_len ); // init reply header MessageHeaderInit( &rh, eMhReply, header.m_seq, header.m_id, hm->m_reply_len ); // alloc reply buffer rd = calloc( 1, hm->m_reply_len ); SaErrorT ret; switch( header.m_id ) { case eFsaHpiSessionOpen: { SaHpiDomainIdT domain_id; SaHpiSessionIdT session_id = 0; HpiDemarshalRequest1( header.m_flags & dMhEndianBit, hm, data, (void *)&domain_id ); ret = saHpiSessionOpen( domain_id, &session_id, 0 ); DbgFunc( "saHpiSessionOpen( %x, %x ) = %d\n", domain_id, session_id, ret ); if ( ret == SA_OK ) c->AddSession( session_id ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &session_id ); } break; case eFsaHpiSessionClose: { SaHpiSessionIdT session_id; HpiDemarshalRequest1( header.m_flags & dMhEndianBit, hm, data, &session_id ); ret = saHpiSessionClose( session_id ); DbgFunc( "saHpiSessionClose( %x ) = %d\n", session_id, ret ); if ( ret == SA_OK ) c->RemSession( session_id ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiResourcesDiscover: { SaHpiSessionIdT session_id; HpiDemarshalRequest1( header.m_flags & dMhEndianBit, hm, data, &session_id ); ret = saHpiResourcesDiscover( session_id ); DbgFunc( "saHpiResourcesDiscover( %x ) = %d\n", session_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiRptInfoGet: { SaHpiSessionIdT session_id; SaHpiRptInfoT rpt_info; HpiDemarshalRequest1( header.m_flags & dMhEndianBit, hm, data, &session_id ); ret = saHpiRptInfoGet( session_id, &rpt_info ); DbgFunc( "saHpiRptInfoGet( %x ) = %d\n", session_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &rpt_info ); } break; case eFsaHpiRptEntryGet: { SaHpiSessionIdT session_id; SaHpiEntryIdT entry_id; SaHpiEntryIdT next_entry_id; SaHpiRptEntryT rpt_entry; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &entry_id ); ret = saHpiRptEntryGet( session_id, entry_id, &next_entry_id, &rpt_entry ); DbgFunc( "saHpiRptEntryGet( %x, %x, %x ) = %d\n", session_id, entry_id, next_entry_id, ret ); rh.m_len = HpiMarshalReply2( hm, rd, &ret, &next_entry_id, &rpt_entry ); } break; case eFsaHpiRptEntryGetByResourceId: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiRptEntryT rpt_entry; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiRptEntryGetByResourceId( session_id, resource_id, &rpt_entry ); DbgFunc( "saHpiRptEntryGetByResourceId( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &rpt_entry ); } break; case eFsaHpiResourceSeveritySet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSeverityT severity; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &severity ); ret = saHpiResourceSeveritySet( session_id, resource_id, severity ); DbgFunc( "saHpiResourceSeveritySet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiResourceTagSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiTextBufferT resource_tag; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &resource_tag ); ret = saHpiResourceTagSet( session_id, resource_id, &resource_tag ); DbgFunc( "saHpiResourceTagSet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiResourceIdGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id = 0; HpiDemarshalRequest1( header.m_flags & dMhEndianBit, hm, data, &session_id ); ret = saHpiResourceIdGet( session_id, &resource_id ); DbgFunc( "saHpiResourceIdGet( %x ) = %d, %x\n", session_id, ret, resource_id ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &resource_id ); } break; case eFsaHpiEntitySchemaGet: { SaHpiSessionIdT session_id; SaHpiUint32T schema_id = 0; HpiDemarshalRequest1( header.m_flags & dMhEndianBit, hm, data, &session_id ); ret = saHpiEntitySchemaGet( session_id, &schema_id ); DbgFunc( "saHpiEntitySchemaGet( %x ) = %d, %x\n", session_id, ret, schema_id ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &schema_id ); } break; case eFsaHpiEventLogInfoGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSelInfoT info; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiEventLogInfoGet( session_id, resource_id, &info ); DbgFunc( "saHpiEventLogInfoGet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &info ); } break; case eFsaHpiEventLogEntryGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSelEntryIdT entry_id; SaHpiSelEntryIdT prev_entry_id = 0; SaHpiSelEntryIdT next_entry_id = 0; SaHpiSelEntryT event_log_entry; SaHpiRdrT rdr; SaHpiRptEntryT rpt_entry; memset( &rdr, 0, sizeof( SaHpiRdrT ) ); memset( &rpt_entry, 0, sizeof( SaHpiRptEntryT ) ); HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &entry_id ); ret = saHpiEventLogEntryGet( session_id, resource_id, entry_id, &prev_entry_id, &next_entry_id, &event_log_entry, &rdr, &rpt_entry ); DbgFunc( "saHpiEventLogEntryGet( %x, %x, %x ) = %d\n", session_id, resource_id, entry_id, ret ); rh.m_len = HpiMarshalReply5( hm, rd, &ret, &prev_entry_id, &next_entry_id, &event_log_entry, &rdr, &rpt_entry ); } break; case eFsaHpiEventLogEntryAdd: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSelEntryT evt_entry; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &evt_entry ); ret = saHpiEventLogEntryAdd( session_id, resource_id, &evt_entry ); DbgFunc( "saHpiEventLogEntryAdd( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiEventLogEntryDelete: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSelEntryIdT entry_id; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &entry_id ); ret = saHpiEventLogEntryDelete( session_id, resource_id, entry_id ); DbgFunc( "saHpiEventLogEntryDelete( %x, %x, %x ) = %d\n", session_id, resource_id, entry_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiEventLogClear: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiEventLogClear( session_id, resource_id ); DbgFunc( "saHpiEventLogClear( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiEventLogTimeGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiTimeT ti; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiEventLogTimeGet( session_id, resource_id, &ti ); DbgFunc( "saHpiEventLogTimeGet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &ti ); } break; case eFsaHpiEventLogTimeSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiTimeT ti; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id , &ti ); ret = saHpiEventLogTimeSet( session_id, resource_id, ti ); DbgFunc( "saHpiEventLogTimeSet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiEventLogStateGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiBoolT enable; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiEventLogStateGet( session_id, resource_id, &enable ); DbgFunc( "saHpiEventLogStateGet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &enable ); } break; case eFsaHpiEventLogStateSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiBoolT enable; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &enable ); ret = saHpiEventLogStateSet( session_id, resource_id, enable ); DbgFunc( "saHpiEventLogStateSet( %x, %x, %s ) = %d\n", session_id, resource_id, enable ? "true" : "false", ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiSubscribe: { SaHpiSessionIdT session_id; SaHpiBoolT provide_active_alarms; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &provide_active_alarms ); ret = saHpiSubscribe( session_id, provide_active_alarms ); DbgFunc( "saHpiSubscribe( %x, %s ) = %d\n", session_id, provide_active_alarms ? "true" : "false", ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiUnsubscribe: { SaHpiSessionIdT session_id; HpiDemarshalRequest1( header.m_flags & dMhEndianBit, hm, data, &session_id ); ret = saHpiUnsubscribe( session_id ); DbgFunc( "saHpiUnsubscribe( %x ) = %d\n", session_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiEventGet: { SaHpiSessionIdT session_id; SaHpiTimeoutT timeout; SaHpiEventT event; SaHpiRdrT rdr; SaHpiRptEntryT rpt_entry; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &timeout ); if ( timeout == 0 ) { ret = saHpiEventGet( session_id, timeout, &event, &rdr, &rpt_entry ); DbgFunc( "saHpiEventGet( %x ) = %d\n", session_id, ret ); rh.m_len = HpiMarshalReply3( hm, rd, &ret, &event, &rdr, &rpt_entry ); } else { cSession *s = c->FindSession( session_id ); if ( s && !s->IsEventGet() ) { s->EventGet( true ); SaHpiTimeT end; gettimeofday1( &end ); if ( timeout == SAHPI_TIMEOUT_BLOCK ) end += (SaHpiTimeT)10000*1000000000; //set a long time else end += timeout; s->Timeout() = end; s->Seq() = header.m_seq; DbgEvent( "saHpiEventGet( %x ): add to event listener.\n", s->SessionId() ); return eResultOk; } // error ret = SA_ERR_HPI_BUSY; rh.m_len = HpiMarshalReply3( hm, rd, &ret, &event, &rdr, &rpt_entry ); } } break; case eFsaHpiRdrGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiEntryIdT entry_id; SaHpiEntryIdT next_entry_id; SaHpiRdrT rdr; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &entry_id ); ret = saHpiRdrGet( session_id, resource_id, entry_id, &next_entry_id, &rdr ); DbgFunc( "saHpiRdrGet( %x, %x, %x ) = %d\n", session_id, resource_id, entry_id, ret ); rh.m_len = HpiMarshalReply2( hm, rd, &ret, &next_entry_id, &rdr ); } break; case eFsaHpiSensorReadingGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSensorNumT sensor_num; SaHpiSensorReadingT reading; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &sensor_num ); ret = saHpiSensorReadingGet( session_id, resource_id, sensor_num, &reading ); DbgFunc( "saHpiSensorReadingGet( %x, %x, %x ) = %d\n", session_id, resource_id, sensor_num, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &reading ); } break; case eFsaHpiSensorReadingConvert: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSensorNumT sensor_num; SaHpiSensorReadingT reading_input; SaHpiSensorReadingT converted_reading; HpiDemarshalRequest4( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &sensor_num, &reading_input ); ret = saHpiSensorReadingConvert( session_id, resource_id, sensor_num, &reading_input, &converted_reading ); DbgFunc( "saHpiSensorReadingConvert( %x, %x, %x ) = %d\n", session_id, resource_id, sensor_num, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &converted_reading ); } break; case eFsaHpiSensorThresholdsGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSensorNumT sensor_num; SaHpiSensorThresholdsT sensor_thresholds; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &sensor_num ); ret = saHpiSensorThresholdsGet( session_id, resource_id, sensor_num, &sensor_thresholds); DbgFunc( "saHpiSensorThresholdsGet( %x, %x, %x ) = %d\n", session_id, resource_id, sensor_num, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &sensor_thresholds ); } break; case eFsaHpiSensorThresholdsSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSensorNumT sensor_num; SaHpiSensorThresholdsT sensor_thresholds; HpiDemarshalRequest4( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &sensor_num, &sensor_thresholds ); ret = saHpiSensorThresholdsSet( session_id, resource_id, sensor_num, &sensor_thresholds ); DbgFunc( "saHpiSensorThresholdsSet( %x, %x, %x ) = %d\n", session_id, resource_id, sensor_num, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiSensorTypeGet: { SaHpiResourceIdT resource_id; SaHpiSessionIdT session_id; SaHpiSensorNumT sensor_num; SaHpiSensorTypeT type; SaHpiEventCategoryT category; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &sensor_num ); ret = saHpiSensorTypeGet( session_id, resource_id, sensor_num, &type, &category ); DbgFunc( "saHpiSensorTypeGet( %x, %x, %x ) = %d\n", session_id, resource_id, sensor_num, ret ); rh.m_len = HpiMarshalReply2( hm, rd, &ret, &type, &category ); } break; case eFsaHpiSensorEventEnablesGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSensorNumT sensor_num; SaHpiSensorEvtEnablesT enables; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &sensor_num ); ret = saHpiSensorEventEnablesGet( session_id, resource_id, sensor_num, &enables ); DbgFunc( "saHpiSensorEventEnablesGet( %x, %x, %x ) = %d\n", session_id, resource_id, sensor_num, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &enables ); } break; case eFsaHpiSensorEventEnablesSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSensorNumT sensor_num; SaHpiSensorEvtEnablesT enables; HpiDemarshalRequest4( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &sensor_num, &enables ); ret = saHpiSensorEventEnablesSet( session_id, resource_id, sensor_num, &enables ); DbgFunc( "saHpiSensorEventEnablesSet( %x, %x, %x ) = %d\n", session_id, resource_id, sensor_num, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiControlTypeGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiCtrlNumT ctrl_num; SaHpiCtrlTypeT type; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &ctrl_num ); ret = saHpiControlTypeGet( session_id, resource_id, ctrl_num, &type ); DbgFunc( "saHpiControlTypeGet( %x, %x, %x ) = %d\n", session_id, resource_id, ctrl_num, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &type ); } break; case eFsaHpiControlStateGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiCtrlNumT ctrl_num; SaHpiCtrlStateT ctrl_state; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &ctrl_num ); ret = saHpiControlStateGet( session_id, resource_id, ctrl_num, &ctrl_state ); DbgFunc( "saHpiControlStateGet( %x, %x, %x ) = %d\n", session_id, resource_id, ctrl_num, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &ctrl_state ); } break; case eFsaHpiControlStateSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiCtrlNumT ctrl_num; SaHpiCtrlStateT ctrl_state; HpiDemarshalRequest4( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &ctrl_num, &ctrl_state ); ret = saHpiControlStateSet( session_id, resource_id, ctrl_num, &ctrl_state ); DbgFunc( "saHpiControlStateSet( %x, %x, %x ) = %d\n", session_id, resource_id, ctrl_num, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiEntityInventoryDataRead: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiEirIdT eir_id; SaHpiUint32T buffer_size; unsigned char *buffer = 0; SaHpiUint32T actual_size; HpiDemarshalRequest4( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &eir_id, &buffer_size ); if ( buffer_size ) buffer = new unsigned char [buffer_size]; ret = saHpiEntityInventoryDataRead( session_id, resource_id, eir_id, buffer_size, (SaHpiInventoryDataT *)(void *)buffer, &actual_size ); DbgFunc( "saHpintityInventoryDataRead( %x, %x, %x, %d ) = %d\n", session_id, resource_id, eir_id, buffer_size, ret ); const cMarshalType *reply[4]; reply[0] = &SaErrorType; // SA_OK reply[1] = &SaHpiUint32Type; // actual size const void *params[3]; params[0] = &ret; params[1] = &actual_size; if ( ret != SA_OK || buffer == 0 ) reply[2] = 0; else { reply[2] = &SaHpiInventoryDataType, // inventory data reply[3] = 0; params[2] = buffer; } rh.m_len = MarshalArray( reply, params, rd ); if ( buffer ) delete [] buffer; } break; case eFsaHpiEntityInventoryDataWrite: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiEirIdT eir_id; unsigned char buffer[10240]; HpiDemarshalRequest4( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &eir_id, buffer ); ret = saHpiEntityInventoryDataWrite( session_id, resource_id, eir_id, (SaHpiInventoryDataT *)(void *)buffer ); DbgFunc( "saHpintityInventoryDataWrite( %x, %x, %x ) = %d\n", session_id, resource_id, eir_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiWatchdogTimerGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiWatchdogNumT watchdog_num; SaHpiWatchdogT watchdog; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &watchdog_num ); ret = saHpiWatchdogTimerGet( session_id, resource_id, watchdog_num, &watchdog ); DbgFunc( "saHpiWatchdogTimerGet( %x, %x, %x ) = %d\n", session_id, resource_id, watchdog_num, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &watchdog ); } break; case eFsaHpiWatchdogTimerSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiWatchdogNumT watchdog_num; SaHpiWatchdogT watchdog; HpiDemarshalRequest4( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &watchdog_num, &watchdog ); ret = saHpiWatchdogTimerSet( session_id, resource_id, watchdog_num, &watchdog ); DbgFunc( "saHpiWatchdogTimerSet( %x, %x, %x ) = %d\n", session_id, resource_id, watchdog_num, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiWatchdogTimerReset: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiWatchdogNumT watchdog_num; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &watchdog_num ); ret = saHpiWatchdogTimerReset( session_id, resource_id, watchdog_num ); DbgFunc( "eFsaHpiWatchdogTimerReset( %x, %x, %x ) = %d\n", session_id, resource_id, watchdog_num, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiHotSwapControlRequest: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiHotSwapControlRequest( session_id, resource_id ); DbgFunc( "saHpiHotSwapControlRequest( %x, %x ) = %d\n", session_id, resource_id , ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiResourceActiveSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiResourceActiveSet( session_id, resource_id ); DbgFunc( "saHpiResourceActiveSet( %x, %x ) = %d\n", session_id, resource_id , ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiResourceInactiveSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiResourceInactiveSet( session_id, resource_id ); DbgFunc( "saHpiResourceInactiveSet( %x, %x ) = %d\n", session_id, resource_id , ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiAutoInsertTimeoutGet: { SaHpiSessionIdT session_id; SaHpiTimeoutT timeout; HpiDemarshalRequest1( header.m_flags & dMhEndianBit, hm, data, &session_id ); ret = saHpiAutoInsertTimeoutGet( session_id, &timeout ); DbgFunc( "saHpiAutoInsertTimeoutGet( %x ) = %d\n", session_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &timeout ); } break; case eFsaHpiAutoInsertTimeoutSet: { SaHpiSessionIdT session_id; SaHpiTimeoutT timeout; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &timeout ); ret = saHpiAutoInsertTimeoutSet( session_id, timeout ); DbgFunc( "saHpiAutoInsertTimeoutSet( %x ) = %d\n", session_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiAutoExtractTimeoutGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiTimeoutT timeout; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiAutoExtractTimeoutGet( session_id, resource_id, &timeout ); DbgFunc( "saHpiAutoExtractTimeoutGet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &timeout ); } break; case eFsaHpiAutoExtractTimeoutSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiTimeoutT timeout; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &timeout ); ret = saHpiAutoExtractTimeoutSet( session_id, resource_id, timeout ); DbgFunc( "saHpiAutoExtractTimeoutSet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiHotSwapStateGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiHsStateT state; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiHotSwapStateGet( session_id, resource_id, &state ); DbgFunc( "saHpiHotSwapStateGet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &state ); } break; case eFsaHpiHotSwapActionRequest: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiHsActionT action; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &action ); ret = saHpiHotSwapActionRequest( session_id, resource_id, action ); DbgFunc( "saHpiHotSwapActionRequest( %x, %x ) = %d\n", session_id, resource_id , ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiResourcePowerStateGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiHsPowerStateT state; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiResourcePowerStateGet( session_id, resource_id, &state ); DbgFunc( "saHpiResourcePowerStateGet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &state ); } break; case eFsaHpiResourcePowerStateSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiHsPowerStateT state; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &state ); ret = saHpiResourcePowerStateSet( session_id, resource_id, state ); DbgFunc( "(saHpiResourcePowerStateSet %x, %x ) = %d\n", session_id, resource_id , ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiHotSwapIndicatorStateGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiHsIndicatorStateT state; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiHotSwapIndicatorStateGet( session_id, resource_id, &state ); DbgFunc( "saHpiHotSwapIndicatorStateGet( %x, %x ) = %d\n", session_id, resource_id , ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &state ); } break; case eFsaHpiHotSwapIndicatorStateSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiHsIndicatorStateT state; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &state ); ret = saHpiHotSwapIndicatorStateSet( session_id, resource_id, state ); DbgFunc( "saHpiHotSwapIndicatorStateSet( %x, %x ) = %d\n", session_id, resource_id , ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiParmControl: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiParmActionT action; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &action ); ret = saHpiParmControl( session_id, resource_id, action ); DbgFunc( "saHpiParmControl( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiResourceResetStateGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiResetActionT reset_action; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiResourceResetStateGet( session_id, resource_id, &reset_action ); DbgFunc( "saHpiResourceResetStateGet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &reset_action ); } break; case eFsaHpiResourceResetStateSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiResetActionT reset_action; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &reset_action ); ret = saHpiResourceResetStateSet( session_id, resource_id, reset_action ); DbgFunc( "saHpiResourceResetStateSet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; default: assert( 0 ); break; } assert( rh.m_len <= hm->m_reply_len ); return eResultReply; }
static void mod_sen(void) { int i, rpt, rdr, num; char buf[READ_BUF_SIZE], *S; Rpt_t *Rpt; Rdr_t *Rdr; SaHpiSensorThresholdsT thres; SaErrorT rv; ThresTypes_t type = UNKNOWN_TYPE; float f; SaHpiEventT event; i = get_number("RPT number: ", &rpt); if (i != 1) { printf("ERROR: no RPT number\n"); return; }; i = find_rpt_by_id(rpt); if (i < 0) { printf("ERROR: invalid RPT number\n"); return; }; rpt = i; Rpt = Rpts + rpt; show_sens_for_rpt(Rpt); i = get_number("Sensor number: ", &num); if (i != 1) { printf("ERROR: no Sensor number\n"); return; }; rdr = find_sensor_by_num(Rpt, num); if (rdr < 0) { printf("ERROR: invalid sensor number\n"); return; }; Rdr = Rpt->rdrs + rdr; oh_print_rdr(&(Rdr->Rdr), 2); show_reading_value(Rpt, Rdr); rv = saHpiSensorThresholdsGet(sessionid, Rpt->Rpt.ResourceId, Rdr->Rdr.RdrTypeUnion.SensorRec.Num, &thres); if (rv != SA_OK) { printf("ERROR: %s\n", oh_lookup_error(rv)); return; }; printf(" Thresholds:\n"); ShowThres(&thres); if (Rdr->is_value == 0) { Rdr->thresholds = thres; Rdr->is_value = 1; }; printf("threshold type (lc, la, li, uc, ua, ui, ph, nh): "); fgets(buf, READ_BUF_SIZE, stdin); S = buf; while (*S == ' ') S++; if (strlen(S) < 2) { printf("ERROR: invalid threshold type: %s\n", S); return; }; if (strncmp(S, "lc", 2) == 0) type = LOWER_CRIT; if (strncmp(S, "la", 2) == 0) type = LOWER_MAJOR; if (strncmp(S, "li", 2) == 0) type = LOWER_MINOR; if (strncmp(S, "uc", 2) == 0) type = UPPER_CRIT; if (strncmp(S, "ua", 2) == 0) type = UPPER_MAJOR; if (strncmp(S, "ui", 2) == 0) type = UPPER_MINOR; if (strncmp(S, "ph", 2) == 0) type = POS_HYST; if (strncmp(S, "nh", 2) == 0) type = NEG_HYST; if (type == UNKNOWN_TYPE) { printf("ERROR: unknown threshold type: %s\n", S); return; }; printf("new value: "); fgets(buf, READ_BUF_SIZE, stdin); i = sscanf(buf, "%f", &f); if (i == 0) { printf("ERROR: no value\n"); return; }; switch (type) { case LOWER_CRIT: set_thres_value(&(thres.LowCritical), (double)f); break; case LOWER_MAJOR: set_thres_value(&(thres.LowMajor), (double)f); break; case LOWER_MINOR: set_thres_value(&(thres.LowMinor), (double)f); break; case UPPER_CRIT: set_thres_value(&(thres.UpCritical), (double)f); break; case UPPER_MAJOR: set_thres_value(&(thres.UpMajor), (double)f); break; case UPPER_MINOR: set_thres_value(&(thres.UpMinor), (double)f); break; case POS_HYST: set_thres_value(&(thres.PosThdHysteresis), (double)f); break; case NEG_HYST: set_thres_value(&(thres.NegThdHysteresis), (double)f); break; default: printf("ERROR: unknown threshold\n"); }; printf("\n Nem threshold:\n"); ShowThres(&thres); printf("Is it correct (yes, no)?:"); fgets(buf, READ_BUF_SIZE, stdin); S = buf; while (*S == ' ') S++; if (strncmp(S, "yes", 3) != 0) return; rv = saHpiSensorThresholdsSet(sessionid, Rpt->Rpt.ResourceId, Rdr->Rdr.RdrTypeUnion.SensorRec.Num, &thres); if (rv != SA_OK) { printf("ERROR: saHpiSensorThresholdsSet: %s\n", oh_lookup_error(rv)); return; }; Rdr->modify = 1; for (i = 0; i < 10; i++) { rv = saHpiEventGet(sessionid, SAHPI_TIMEOUT_IMMEDIATE, &event, NULL, NULL, NULL); if (rv == SA_OK) break; if (fdebug) printf("sleep before saHpiEventGet\n"); sleep(1); }; saHpiSensorThresholdsGet(sessionid, Rpt->Rpt.ResourceId, Rdr->Rdr.RdrTypeUnion.SensorRec.Num, &thres); printf("Current thresholds:\n"); ShowThres(&thres); }
int isReadingWithinMinorLimits(SaHpiSessionIdT sessionId, SaHpiResourceIdT resourceId, SaHpiSensorRecT * sensorRec) { SaErrorT status; int retval = SAF_TEST_NOTSUPPORT; SaHpiSensorReadingT reading; SaHpiSensorThresholdsT thresholds; SaHpiBoolT isWithin; SaHpiSensorReadingT low, high; status = saHpiSensorReadingGet(sessionId, resourceId, sensorRec->Num, &reading, NULL); if (status != SA_OK) { retval = SAF_TEST_UNRESOLVED; e_print(saHpiSensorReadingGet, SA_OK, status); } else { status = saHpiSensorThresholdsGet(sessionId, resourceId, sensorRec->Num, &thresholds); if (status != SA_OK) { retval = SAF_TEST_UNRESOLVED; e_print(saHpiSensorThresholdsGet, SA_OK, status); } else { switch (reading.Type) { case SAHPI_SENSOR_READING_TYPE_INT64: low.Value.SensorInt64 = thresholds.LowMinor.Value.SensorInt64; if (thresholds.NegThdHysteresis.IsSupported) { low.Value.SensorInt64 += thresholds.NegThdHysteresis.Value. SensorInt64; } high.Value.SensorInt64 = thresholds.UpMinor.Value.SensorInt64; if (thresholds.PosThdHysteresis.IsSupported) { high.Value.SensorInt64 -= thresholds.PosThdHysteresis.Value. SensorInt64; } isWithin = (reading.Value.SensorInt64 > low.Value.SensorInt64) && (reading.Value.SensorInt64 < high.Value.SensorInt64); break; case SAHPI_SENSOR_READING_TYPE_UINT64: low.Value.SensorUint64 = thresholds.LowMinor.Value.SensorUint64; if (thresholds.NegThdHysteresis.IsSupported) { low.Value.SensorUint64 += thresholds.NegThdHysteresis.Value. SensorUint64; } high.Value.SensorUint64 = thresholds.UpMinor.Value.SensorUint64; if (thresholds.PosThdHysteresis.IsSupported) { high.Value.SensorUint64 -= thresholds.PosThdHysteresis.Value. SensorUint64; } isWithin = (reading.Value.SensorUint64 > low.Value.SensorUint64) && (reading.Value.SensorUint64 < high.Value.SensorUint64); break; case SAHPI_SENSOR_READING_TYPE_FLOAT64: low.Value.SensorFloat64 = thresholds.LowMinor.Value.SensorFloat64; if (thresholds.NegThdHysteresis.IsSupported) { low.Value.SensorFloat64 += thresholds.NegThdHysteresis.Value. SensorFloat64; } high.Value.SensorFloat64 = thresholds.UpMinor.Value.SensorFloat64; if (thresholds.PosThdHysteresis.IsSupported) { high.Value.SensorFloat64 -= thresholds.PosThdHysteresis.Value. SensorFloat64; } isWithin = (reading.Value.SensorFloat64 > low.Value.SensorFloat64) && (reading.Value.SensorFloat64 < high.Value.SensorFloat64); break; case SAHPI_SENSOR_READING_TYPE_BUFFER: isWithin = SAHPI_FALSE; break; } if (isWithin) { retval = SAF_TEST_PASS; } } } return retval; }