Example #1
0
int main(int argc, char* argv[]){
	int data[MAXCHAN];
	int bit = 0;
	int retries;

	if (argc > 1){
		maxchan = atoi(argv[1]);
	}

	printf( "%s maxchan %d\n", "$Version:$", maxchan);

	for (bit = 0; bit < 32; ++bit){
//		printf("bit %d\n", bit);

		setDIO32_bit(bit, 1);

		retries = 0;
		do {
			getMeans(data);
//			show_treshold(data);
		} while(over_threshold(data) == 0 && ++retries < 20);

		if (retries >= 20){
			show_threshold(data, bit);
			fprintf(stderr, "ERROR:TIMEOUT waiting for non-zero\n");
		}

		if (over_threshold(data) < maxchan/32){
			fprintf(stderr, "ERROR: bust channel? %d\n",
					bit+1);
		}else if (over_threshold(data) != maxchan/32){
			fprintf(stderr, "ERROR: crossed wires! %d\n",
					bit + 1);
		}
		show_threshold(data, bit);

		setDIO32_bit(bit, 0);

		retries = 0;
		do {
			getMeans(data);
//			show_threshold(data);
		} while (over_threshold(data) && ++retries < 20);

		if (retries >= 20){
			show_threshold(data, bit);
			fprintf(stderr, "ERROR:TIMEOUT waiting for zero\n");
		}
	}

	return 0;
}
Example #2
0
SaErrorT show_sensor(SaHpiSessionIdT sessionid, SaHpiResourceIdT resourceid,
	SaHpiSensorNumT sensornum, hpi_ui_print_cb_t proc)
{
        SaHpiSensorReadingT	reading;
	SaHpiEventStateT	status;
        SaErrorT		rv;
	char			buf[1024];

        rv = saHpiSensorReadingGet(sessionid, resourceid, sensornum,
		&reading, &status);
        if (rv != SA_OK)  {
		snprintf(buf, 1024, "ERROR: saHpiSensorReadingGet error = %s\n",
			oh_lookup_error(rv));
		proc(buf);
		return rv;
        }

        if (reading.IsSupported) {
		snprintf(buf, 1024, " : Sensor status = %x", status);
		proc(buf);
		print_thres_value(&reading, "  Reading Value =", proc);
	};

	show_sensor_status(sessionid, resourceid, sensornum, proc);
	show_threshold(sessionid, resourceid, sensornum, proc);

	return SA_OK;
}
Example #3
0
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;
}