コード例 #1
0
ファイル: 6.c プロジェクト: basheerk/autotest-client-tests
int Test_Rdr(SaHpiSessionIdT session,
	     SaHpiResourceIdT resourceId, SaHpiRdrT rdr)
{
	SaErrorT status;
	int retval = SAF_TEST_UNKNOWN;
	SaHpiSensorReadingT reading;
	SaHpiEventStateT EventState;

	if (rdr.RdrType == SAHPI_SENSOR_RDR) {
		//
		//  Call saHpiSensorReadingGet passing in a bad Sensor Number
		//
		status = saHpiSensorReadingGet(session,
					       resourceId,
					       UNLIKELY_SENSOR_NUM,
					       &reading, &EventState);
		if (status != SA_ERR_HPI_NOT_PRESENT) {
			e_print(saHpiSensorReadingGet, SA_ERR_HPI_NOT_PRESENT,
				status);
			retval = SAF_TEST_FAIL;
		} else
			retval = SAF_TEST_PASS;
	} else
		retval = SAF_TEST_NOTSUPPORT;

	return (retval);
}
コード例 #2
0
ファイル: show.c プロジェクト: openhpi1/testrepo
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;
}
コード例 #3
0
ファイル: set_thres.c プロジェクト: openhpi1/openhpitest
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);
}
コード例 #4
0
ファイル: bladehpi.c プロジェクト: ystk/debian-cluster-glue
static int
bladehpi_status(StonithPlugin *s)
{
	struct pluginDevice *	dev;
	SaErrorT		ohrc;
	SaHpiDomainInfoT 	ohdi;
	int rc = S_OK;
	
	if (Debug) {
		LOG(PIL_DEBUG, "%s: called", __FUNCTION__);
	}

	ERRIFWRONGDEV(s, S_OOPS);

	dev = (struct pluginDevice *)s;
	rc = open_hpi_session(dev);
	if( rc != S_OK )
		return rc;

	/* Refresh the hostlist only if RPTs updated */
	ohrc = saHpiDomainInfoGet(dev->ohsession, &ohdi);
	if (ohrc != SA_OK) {
		LOG(PIL_CRIT, "Unable to get domain info in %s (%d)"
		,	__FUNCTION__, ohrc);
		rc = S_BADCONFIG;
		goto done;
	}
	if (dev->ohrptcnt != ohdi.RptUpdateCount) {
		free_bladehpi_hostlist(dev);
		if (get_bladehpi_hostlist(dev) != S_OK) {
			LOG(PIL_CRIT, "Unable to obtain list of hosts in %s"
			,	__FUNCTION__);
			rc = S_BADCONFIG;
			goto done;
		}
	}

	/* At this point, hostlist is up to date */
	if (dev->ohsensid && dev->ohsensnum) {
		/*
		 * For accurate status, need to make a call that goes out to
		 * BladeCenter MM because the calls made so far by this
		 * function (and perhaps get_bladehpi_hostlist) only retrieve
		 * information from memory cached by OpenHPI
		 */
		ohrc = saHpiSensorReadingGet(dev->ohsession
			, dev->ohsensid, dev->ohsensnum, NULL, NULL);
		if (ohrc == SA_ERR_HPI_BUSY || ohrc == SA_ERR_HPI_NO_RESPONSE) {
			LOG(PIL_CRIT, "Unable to connect to BladeCenter in %s"
			,	__FUNCTION__);
			rc = S_OOPS;
			goto done;
		}
	}

done:
	close_hpi_session(dev);
	return (rc == S_OK) ? (dev->ohdevid ? S_OK : S_OOPS) : rc;
}
コード例 #5
0
ファイル: 7.c プロジェクト: basheerk/autotest-client-tests
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;
}
コード例 #6
0
ファイル: hpithres.c プロジェクト: openhpi1/testrepo
static void show_reading_value(Rpt_t *Rpt, Rdr_t *R)
{
	SaHpiSensorUnitsT	k;
	SaErrorT		rv;
	char			unit[128];

	rv = saHpiSensorReadingGet(sessionid, Rpt->Rpt.ResourceId,
		R->Rdr.RdrTypeUnion.SensorRec.Num, &(R->reading), NULL);

	if (rv != SA_OK) {
		printf("ERROR: %s\n", oh_lookup_error(rv));
		return;
	};
	k = R->Rdr.RdrTypeUnion.SensorRec.DataFormat.BaseUnits;
	printf("Reading value: ");
	snprintf(unit, 128, "%s", oh_lookup_sensorunits(k));
	print_value(&(R->reading), unit);
}
コード例 #7
0
ファイル: sim_sanity_004.c プロジェクト: openhpi1/testrepo
int main(int argc, char **argv)
{
	SaHpiSessionIdT sid = 0;
	SaHpiSensorReadingT reading;
	SaHpiEventStateT state;
	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 a sensor reading */
        rc = saHpiSensorReadingGet(sid, resid, 1, &reading, &state);
        if (rc != SA_OK) {
		dbg("Couldn't get a sensor reading");
		dbg("Error %s",oh_lookup_error(rc));
                return -1;
	}

	return 0;
}
コード例 #8
0
ファイル: list_resources.c プロジェクト: openhpi1/testrepo
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);
}
コード例 #9
0
ファイル: hpisensor.c プロジェクト: CSU-GH/okl4_3.0
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*/
コード例 #10
0
ファイル: hpitree.c プロジェクト: openhpi1/testrepo
/* 
 * 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");
}
コード例 #11
0
ファイル: show.c プロジェクト: openhpi1/testrepo
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;
}
コード例 #12
0
ファイル: tsensorget013.c プロジェクト: openhpi1/openhpitest
int main(int argc, char **argv) 
{

	/* ************************
	 * Local variables
	 * ***********************/	 
	int testfail = 0;
	SaErrorT          err;
	SaErrorT expected_err;

	SaHpiResourceIdT  id;
        SaHpiSessionIdT sessionid;
        SaHpiRptEntryT    rptentry;
	SaHpiRdrT         rdr;
	SaHpiSensorNumT   dd_sid = 0;
	SaHpiEventStateT state;
	SaHpiSensorReadingT reading;
	SaHpiEntryIdT entryid;
	SaHpiEntryIdT nextentryid;
	SaHpiBoolT foundSensor;			
													    
	/* *************************************	 	 
	 * Find a resource with Sensor type rdr
	 * ************************************* */
	err = tsetup(&sessionid);
	if (err != SA_OK) {
		printf("Error! Can not open session for test environment\n");
		printf("      File=%s, Line=%d\n", __FILE__, __LINE__);
		return -1;

	}
	err = tfind_resource(&sessionid,SAHPI_CAPABILITY_SENSOR,SAHPI_FIRST_ENTRY, &rptentry, SAHPI_TRUE);
	if (err != SA_OK) {
		printf("Error! Can not find resources for test environment\n");
		printf("      File=%s, Line=%d\n", __FILE__, __LINE__);
		err = tcleanup(&sessionid);
		return -1;
	}

	id = rptentry.ResourceId;
	/************************** 
	 * Test: find a sensor with desired property
	 **************************/
	entryid = SAHPI_FIRST_ENTRY;
	foundSensor = SAHPI_FALSE;			
	do {
		err = saHpiRdrGet(sessionid,id,entryid,&nextentryid, &rdr);
		if (err == SA_OK)
		{
			if ((rdr.RdrType == SAHPI_SENSOR_RDR) &&
				(rdr.RdrTypeUnion.SensorRec.DataFormat.IsSupported == SAHPI_TRUE))
			{
				foundSensor = SAHPI_TRUE;
				break;
														
			}
			entryid = nextentryid;
		}
	} while ((err == SA_OK) && (entryid != SAHPI_LAST_ENTRY)) ;

	if (!foundSensor) {
		err("Did not find desired resource for test\n");
		return(SA_OK);
	} else {
		dd_sid = rdr.RdrTypeUnion.SensorRec.Num; 
	}	

	/************************** 
	 * Test : Read sensor with NULL Reading area. State only 
	 **************************/
	expected_err = SA_OK;                   
	err = saHpiSensorReadingGet(sessionid, id, dd_sid, NULL, &state);
	checkstatus(err, expected_err, testfail);

	/************************** 
	 * Test:Read with NULL State area, Read Value only 
	 **************************/
	err = saHpiSensorReadingGet(sessionid, id, dd_sid, &reading, NULL);
	checkstatus(err, expected_err, testfail);

	/************************** 
	 * Test: Both Reading and State are NULL. ie checking for sensor existance
	 **************************/
	err = saHpiSensorReadingGet(sessionid, id, dd_sid, NULL, NULL);
	checkstatus(err, expected_err, testfail);
	
	/***************************
	 * Cleanup after all tests
	 ***************************/
	 err = tcleanup(&sessionid);
	 return testfail;

}
コード例 #13
0
ファイル: openhpid.cpp プロジェクト: openhpi1/testrepo
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;
}
コード例 #14
0
ファイル: 9.c プロジェクト: basheerk/autotest-client-tests
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;
}
コード例 #15
0
ファイル: saHpiSensorTable.c プロジェクト: openhpi1/testrepo
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, &current_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, &current_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;
}
コード例 #16
0
ファイル: set_thres.c プロジェクト: openhpi1/openhpitest
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);
        }
}
コード例 #17
0
ファイル: hpievent.c プロジェクト: openhpi1/testrepo
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*/
コード例 #18
0
ファイル: commands.c プロジェクト: openhpi1/testrepo
static int sa_show_sensor(
        SaHpiResourceIdT resourceid,
        SaHpiSensorNumT sensornum )
{
        SaHpiSensorReadingT reading;
        SaHpiSensorReadingT conv_reading;
        SaErrorT rv;

        rv = saHpiSensorReadingGet(sessionid,resourceid, sensornum, &reading);
        if (rv != SA_OK)  {
                printf("ReadingGet ret=%d\n", rv);
                return rv;
        }

        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(" = event-only sensor\n");
                        return SA_OK;
                } 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 rv;
                        }
                        else {
                                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;
                        }
                }
        }
        switch(reading.Interpreted.Type)
        {
        case SAHPI_SENSOR_INTERPRETED_TYPE_FLOAT32:
                printf("Value: %5.2f \n",
                       reading.Interpreted.Value.SensorFloat32);
                break;
        case SAHPI_SENSOR_INTERPRETED_TYPE_UINT32:
                printf("Value: %d \n",
                       reading.Interpreted.Value.SensorUint32);
                break;
        case SAHPI_SENSOR_INTERPRETED_TYPE_BUFFER:
                printf("Value: %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("Value: %x (itype=%x)\n",
                       reading.Interpreted.Value.SensorUint32,
                       reading.Interpreted.Type);
        }

#if 0
	printf("Sensor Status: ");
        if (reading.EventStatus.SensorStatus & SAHPI_SENSTAT_EVENTS_ENABLED) {
                printf("Event Enabled.\n");
	} else if (reading.EventStatus.SensorStatus & SAHPI_SENSTAT_SCAN_ENABLED) {
                printf("Scan Enabled.\n");
	} else if (reading.EventStatus.SensorStatus & SAHPI_SENSTAT_BUSY) {
                printf("Busy.\n");
	} else {
                printf("Unknown.\n");
	}
#endif

	sa_sen_evt_get(resourceid, sensornum);
	sa_get_thres(resourceid, sensornum);

	return SA_OK;
}