int Test_Rdr(SaHpiSessionIdT session_id, SaHpiResourceIdT resource_id, SaHpiRdrT rdr) { SaHpiBoolT enable, enable_old; SaErrorT val; SaHpiSensorNumT num; int ret = SAF_TEST_UNKNOWN; SaHpiSensorReadingT reading; /* Need to skip sensors which we can't set */ if (rdr.RdrType == SAHPI_SENSOR_RDR && rdr.RdrTypeUnion.SensorRec.EnableCtrl != SAHPI_FALSE) { num = rdr.RdrTypeUnion.SensorRec.Num; val = saHpiSensorEnableGet(session_id, resource_id, num, &enable_old); if (val != SA_OK) { e_print(saHpiSensorEnableGet, SA_OK, val); ret = SAF_TEST_UNRESOLVED; goto out; } if (enable_old) { enable = SAHPI_FALSE; val = saHpiSensorEnableSet(session_id, resource_id, num, enable); if (val != SA_OK) { e_print(saHpiSensorEnableSet, SA_OK, val); ret = SAF_TEST_UNRESOLVED; goto out1; } } val = saHpiSensorReadingGet(session_id, resource_id, num, &reading, NULL); if (val != SA_ERR_HPI_INVALID_REQUEST) { e_print(saHpiSensorReadingGet, val != SA_OK, val); ret = SAF_TEST_FAIL; } else ret = SAF_TEST_PASS; if (ret == SAF_TEST_UNKNOWN) ret = SAF_TEST_PASS; out1: val = saHpiSensorEnableSet(session_id, resource_id, num, enable_old); if (val != SA_OK) e_print(saHpiSensorEnableSet, SA_OK, val); } else ret = SAF_TEST_NOTSUPPORT; out: return ret; }
int canTest(SaHpiSessionIdT sessionId, SaHpiResourceIdT resourceId, SaHpiRdrT * rdr) { SaErrorT status; int retval = SAF_TEST_NOTSUPPORT; SaHpiSensorRecT *sensorRec; SaHpiBoolT sensorEnabled; if (rdr->RdrType == SAHPI_SENSOR_RDR) { sensorRec = &rdr->RdrTypeUnion.SensorRec; if ((sensorCount < MAX_SENSORS) && (sensorRec->ThresholdDefn.IsAccessible) && (sensorRec->Events & SAHPI_ES_UPPER_MINOR) && (sensorRec->ThresholdDefn.ReadThold & SAHPI_STM_LOW_MINOR) && (sensorRec->ThresholdDefn.ReadThold & SAHPI_STM_UP_MINOR) && (sensorRec->ThresholdDefn. WriteThold & SAHPI_STM_UP_MINOR)) { status = saHpiSensorEnableGet(sessionId, resourceId, sensorRec->Num, &sensorEnabled); if (status == SA_ERR_HPI_ENTITY_NOT_PRESENT) { retval = SAF_TEST_NOTSUPPORT; } else if (status != SA_OK) { retval = SAF_TEST_UNRESOLVED; e_print(saHpiSensorEnableGet, SA_OK, status); } else if (sensorEnabled) { retval = isReadingWithinMinorLimits(sessionId, resourceId, sensorRec); } } } return retval; }
SaErrorT show_sensor(SaHpiSessionIdT sessionid, SaHpiResourceIdT resourceid, SaHpiSensorNumT sensornum, hpi_ui_print_cb_t proc) { SaHpiSensorReadingT reading; SaHpiEventStateT status, assert, deassert; SaHpiRdrT rdr; SaErrorT rv; SaHpiBoolT val; char buf[SHOW_BUF_SZ]; char errbuf[SHOW_BUF_SZ]; Pr_ret_t res; rv = saHpiRdrGetByInstrumentId(sessionid, resourceid, SAHPI_SENSOR_RDR, sensornum, &rdr); if (rv != SA_OK) { snprintf(errbuf, SHOW_BUF_SZ, "\nERROR: saHpiRdrGetByInstrumentId: error: %s\n", oh_lookup_error(rv)); proc(errbuf); return(rv); }; snprintf(buf, SHOW_BUF_SZ, "Sensor(%d/%d) %s", resourceid, sensornum, oh_lookup_sensortype(rdr.RdrTypeUnion.SensorRec.Type)); proc(buf); res = print_text_buffer_text(" ", &(rdr.IdString), "\n", proc); if (res != HPI_UI_OK) return(SA_OK); rv = saHpiSensorEnableGet(sessionid, resourceid, sensornum, &val); if (rv != SA_OK) { snprintf(errbuf, SHOW_BUF_SZ, "\nERROR: saHpiSensorEnableGet: error: %s\n", oh_lookup_error(rv)); if (proc(errbuf) != HPI_UI_OK) return(rv); } else { if (val) res = proc("Enable "); else res = proc("Disable "); if (res != HPI_UI_OK) return(SA_OK); }; rv = saHpiSensorEventEnableGet(sessionid, resourceid, sensornum, &val); if (rv != SA_OK) { snprintf(errbuf, SHOW_BUF_SZ, "\nERROR: saHpiSensorEventEnableGet: error: %s\n", oh_lookup_error(rv)); if (proc(errbuf) != HPI_UI_OK) return(rv); } else { if (proc(" event : ") != HPI_UI_OK) return(SA_OK); if (val) res = proc("Enable"); else res = proc("Disable"); if (res != HPI_UI_OK) return(SA_OK); }; rv = saHpiSensorEventMasksGet(sessionid, resourceid, sensornum, &assert, &deassert); if (rv != SA_OK) { snprintf(errbuf, SHOW_BUF_SZ, "\nERROR: saHpiSensorEventMasksGet: error: %s\n", oh_lookup_error(rv)); if (proc(errbuf) != HPI_UI_OK) return(rv); } else { snprintf(buf, SHOW_BUF_SZ, " supported: 0x%4.4x masks: assert = 0x%4.4x" " deassert = 0x%4.4x\n", rdr.RdrTypeUnion.SensorRec.Events, assert, deassert); if (proc(buf) != HPI_UI_OK) return(rv); }; rv = saHpiSensorReadingGet(sessionid, resourceid, sensornum, &reading, &status); if (rv != SA_OK) { snprintf(errbuf, SHOW_BUF_SZ, "\nERROR: saHpiSensorReadingGet: error: %s\n", oh_lookup_error(rv)); proc(errbuf); return(rv); }; snprintf(buf, SHOW_BUF_SZ, "\tEvent states = 0x%x\n", status); if (proc(buf) != HPI_UI_OK) return(SA_OK); if (reading.IsSupported) { res = print_thres_value(&reading, "\tReading Value =", NULL, 0, proc); if (res == HPI_UI_END) return(SA_OK); } else { if (proc("\tReading not supported\n") != HPI_UI_OK) return(SA_OK); } show_threshold(sessionid, resourceid, sensornum, &(rdr.RdrTypeUnion.SensorRec), proc); return SA_OK; }