Beispiel #1
0
void restoreSensors(SaHpiSessionIdT sessionId) {
    int       i;
    SaErrorT  status;

    for (i = 0; i < sensorCount; i++) {
            status = saHpiSensorThresholdsSet(sessionId, 
                                              sensorData[i].resourceId,
                                              sensorData[i].sensorNum,
                                              &sensorData[i].thresholds);
            if (status != SA_OK) {
                    e_print(saHpiSensorThresholdsSet, SA_OK, status);
            }
                        

           if (sensorData[i].restoreMasks) {
                // restore event masks
                if (!(sensorData[i].assertEventMask & SAHPI_ES_UPPER_MINOR)) {
                        status = saHpiSensorEventMasksSet(sessionId, sensorData[i].resourceId,
                                                          sensorData[i].sensorNum,
                                                          SAHPI_SENS_REMOVE_EVENTS_FROM_MASKS,
                                                          SAHPI_ES_UPPER_MINOR, 0x0);
                        if (status != SA_OK) {
                                e_print(saHpiSensorEventMasksSet, SA_OK, status);
                        }
                }

                if (!(sensorData[i].deassertEventMask & SAHPI_ES_UPPER_MINOR)) {
                        status = saHpiSensorEventMasksSet(sessionId, sensorData[i].resourceId,
                                                          sensorData[i].sensorNum,
                                                          SAHPI_SENS_REMOVE_EVENTS_FROM_MASKS,
                                                          0x0, SAHPI_ES_UPPER_MINOR);
                        if (status != SA_OK) {
                                e_print(saHpiSensorEventMasksSet, SA_OK, status);
                        }
                }
           }
                        
           if (sensorData[i].origEventEnable == SAHPI_FALSE) {
                // restore EventEnabled state
                status =
                    saHpiSensorEventEnableSet(sessionId,
                                              sensorData[i].resourceId,
                                              sensorData[i].sensorNum,
                                              SAHPI_FALSE);
                if (status != SA_OK) {
                        e_print(saHpiSensorEventEnableSet, SA_OK, status);
                }
           }
        }
}
Beispiel #2
0
int main(int argc, char **argv) 
{

	/* ************************
	 * Local variables
	 * ***********************/	 
	int testfail = 0;
	SaErrorT          err;
	SaErrorT expected_err;
	SaHpiRptEntryT rptentry;
	SaHpiResourceIdT  id = 0;
        SaHpiSessionIdT sessionid;
	 
	SaHpiSensorNumT sid = 0;
	SaHpiSensorThresholdsT thres;

	/* *************************************	 	 
	 * 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_FALSE);
	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 SA_OK;
	}

	id = rptentry.ResourceId;

        /************************** 
	 * Test : Invalid capability
         **************************/
        expected_err = SA_ERR_HPI_CAPABILITY;
	err = saHpiSensorThresholdsSet(sessionid, id, sid, &thres);
        checkstatus(err, expected_err, testfail);
											
	/***************************
	 * Cleanup after all tests
	 ***************************/
	err = tcleanup(&sessionid);
	return testfail;

}
Beispiel #3
0
static void undo(void)
{
	int			i, j;
	Rpt_t			*Rpt;
	Rdr_t			*Rdr;

	for (i = 0, Rpt = Rpts; i < nrpts; i++, Rpt++) {
		for (j = 0, Rdr = Rpt->rdrs; j < Rpt->nrdrs; j++, Rdr++) {
			if (Rdr->modify == 0) continue;
			saHpiSensorThresholdsSet(sessionid, Rpt->Rpt.ResourceId,
				Rdr->Rdr.RdrTypeUnion.SensorRec.Num, &(Rdr->thresholds));
			Rdr->modify = 0;
		}
	}
}
Beispiel #4
0
int checkForEvents(SaHpiSessionIdT sessionId)
{
    int i;
    int retval = SAF_TEST_PASS;
    SaErrorT status;
    SaHpiEventT event;
    SaHpiSensorNumT sensorNum;
    SaHpiBoolT assertion;

    while (SAHPI_TRUE && retval == SAF_TEST_PASS) {
         status = saHpiEventGet(sessionId, SAHPI_TIMEOUT_IMMEDIATE, &event, NULL, NULL, NULL);
         if (status == SA_ERR_HPI_TIMEOUT) {
              break;
         } else if (status != SA_OK) {
              retval = SAF_TEST_UNRESOLVED;
              e_print(saHpiEventGet, SA_OK, status);
              break;
         } else if ((event.EventType == SAHPI_ET_SENSOR) &&
                    (event.EventDataUnion.SensorEvent.EventState == SAHPI_ES_UPPER_MINOR)) {

              assertion = event.EventDataUnion.SensorEvent.Assertion;
              sensorNum = event.EventDataUnion.SensorEvent.SensorNum;
              for (i = 0; i < sensorCount; i++) {
                  if ((sensorData[i].resourceId == event.Source) &&
                      (sensorData[i].sensorNum == sensorNum)) {

                          if (assertion) {
                                  sensorData[i].assert = SAHPI_TRUE;
                                  // restore threshold which should kick off a deassert event
                                  status = saHpiSensorThresholdsSet(sessionId, 
                                                                    sensorData[i].resourceId,
                                                                    sensorData[i].sensorNum,
                                                                    &sensorData[i].thresholds);
                                  if (status != SA_OK) {
                                          e_print(saHpiSensorThresholdsSet, SA_OK, status);
                                          retval = SAF_TEST_UNRESOLVED;
                                  }
                          } else {
                                  sensorData[i].deassert = SAHPI_TRUE;
                          }
                          break;
                  }
              }
         }
    }

    return retval;
}
Beispiel #5
0
int main(int argc, char **argv)
{
    SaHpiSessionIdT sid = 0;
    SaHpiSensorThresholdsT thresholds;
    SaErrorT rc = SA_OK;

    rc = saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, &sid, NULL);
    if (rc != SA_OK) {
        dbg("Failed to open session");
        return -1;
    }

    rc = saHpiDiscover(sid);
    if (rc != SA_OK) {
        dbg("Failed to run discover");
        return -1;
    }

    /* get the resource id of the chassis */
    SaHpiResourceIdT resid = get_resid(sid, SAHPI_ENT_SYSTEM_CHASSIS);
    if (resid == 0) {
        dbg("Couldn't find the resource id of the chassis");
        return -1;
    }

    /* get sensor thresholds */
    rc = saHpiSensorThresholdsGet(sid, resid, 1, &thresholds);
    if (rc != SA_OK) {
        dbg("Couldn't get sensor thresholds");
        dbg("Error %s",oh_lookup_error(rc));
        return -1;
    }

    /* set sensor thresholds */
    rc = saHpiSensorThresholdsSet(sid, resid, 1, &thresholds);
    if (rc == SA_OK) {
        /* all our sensors are read-only so if we can change the
           sensor it is an error */
        dbg("Error: able to write to a read-only sensor");
        return -1;
    }

    return 0;
}
/*
 * int set_table_ctrl_analog_mode()
 */
int set_table_sen_thds_low_minor (saHpiSensorThdLowMinorTable_context *row_ctx)
{

 	DEBUGMSGTL ((AGENT, "set_table_sen_thds_low_minor, called\n"));

	SaErrorT            	rc = SA_OK;
	SaHpiSessionIdT     	session_id;
	SaHpiResourceIdT    	resource_id;
	SaHpiSensorNumT	    	sensor_num;	
	SaHpiSensorThresholdsT 	sensor_thresholds;

	if (!row_ctx)
		return AGENT_ERR_NULL_DATA;

	session_id = get_session_id(row_ctx->index.oids[saHpiThdLoMinDomainId_INDEX]);
	resource_id = row_ctx->index.oids[saHpiThdLoMinResourceEntryId_INDEX];
	sensor_num = row_ctx->index.oids[saHpiSensorThdLoMinNum_INDEX];

	memset(&sensor_thresholds, 0, sizeof(sensor_thresholds));

	sensor_thresholds.LowMinor.IsSupported = SAHPI_TRUE;
	sensor_thresholds.LowMinor.Type = row_ctx->saHpiSensorThdLowMinorType - 1;
	set_sen_thd_value(&sensor_thresholds.LowMinor.Value,
			  sensor_thresholds.LowMinor.Type,
			  row_ctx->saHpiSensorThdLowMinorValue, 
			  row_ctx->saHpiSensorThdLowMinorValue_len);

	rc = saHpiSensorThresholdsSet(session_id, resource_id, 
				      sensor_num, &sensor_thresholds);

	if (rc != SA_OK) {
		snmp_log (LOG_ERR,
			  "SAHPI_STM_LOW_MINOR: Call to saHpiSensorThresholdsSet failed to set Mode rc: %s.\n",
			  oh_lookup_error(rc));
		DEBUGMSGTL ((AGENT,
			     "SAHPI_STM_LOW_MINOR: Call to saHpiSensorThresholdsSet failed to set Mode rc: %s.\n",
			     oh_lookup_error(rc)));
		return get_snmp_error(rc);
	} 

	return SNMP_ERR_NOERROR; 
}
Beispiel #7
0
SaErrorT setUpMinorThreshold(SaHpiSessionIdT sessionId,
                             SaHpiResourceIdT resourceId,
                             SaHpiSensorRecT * sensorRec,
                             SaHpiSensorReadingUnionT upMinorValue)
{
        SaErrorT status;
        SaHpiSensorThresholdsT thresholds;

        initThresholds(&thresholds, sensorRec->DataFormat.ReadingType);

        thresholds.UpMinor.IsSupported = SAHPI_TRUE;
        thresholds.UpMinor.Value = upMinorValue;

        status =
            saHpiSensorThresholdsSet(sessionId, resourceId, sensorRec->Num,
                                     &thresholds);
        if (status != SA_OK) {
                e_print(saHpiSensorThresholdsSet, SA_OK, status);
        }

        return status;
}
Beispiel #8
0
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*/
Beispiel #9
0
int main(int argc, char **argv) 
{

	/* ************************
	 * Local variables
	 * ***********************/	 
	int testfail = 0;
	SaErrorT          err;
	SaErrorT expected_err;
	SaHpiResourceIdT  id = 0;
        SaHpiSessionIdT sessionid;
	SaHpiRptEntryT rptentry;
	SaHpiRdrT	rdr;	 
	SaHpiSensorNumT sid = 0;
	SaHpiSensorThresholdsT thres;
	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 SA_OK;
	}

	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.Category == SAHPI_EC_THRESHOLD) &&
				(rdr.RdrTypeUnion.SensorRec.ThresholdDefn.WriteThold == 0))
			{
				foundSensor = SAHPI_TRUE;
				break;
														
			}
			entryid = nextentryid;
		}
	} while ((err == SA_OK) && (entryid != SAHPI_LAST_ENTRY)) ;

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


        /************************** 
	 * Test: setting to a non-writeable sensor
         **************************/
        expected_err = SA_ERR_HPI_INVALID_CMD;
	err = saHpiSensorThresholdsSet(sessionid, id, sid, &thres);
        checkstatus(err, expected_err, testfail);
											
	/***************************
	 * Cleanup after all tests
	 ***************************/
	err = tcleanup(&sessionid);
	return testfail;

}
Beispiel #10
0
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);
        }
}
Beispiel #11
0
int main(int argc, char **argv) 
{

	/* ************************
	 * Local variables
	 * ***********************/	 
	int testfail = 0;
	SaErrorT          err;
	SaErrorT expected_err;
	SaHpiRptEntryT rptentry;				
	SaHpiResourceIdT  id = 0;
        SaHpiSessionIdT sessionid;
	 
	SaHpiSensorNumT sid = 0;
	SaHpiSensorThresholdsT thres;

	/* *************************************	 	 
	 * 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 SA_OK;
	}

	id = rptentry.ResourceId;
	/************************** 
	 * Test: Invalid handler
	 **************************/
	expected_err = SA_ERR_HPI_INVALID_PARAMS;                   
	err = snmp_bc_set_sensor_thresholds(NULL, id, sid, &thres);
	checkstatus(err, expected_err, testfail);

	/************************** 
	 * Test: Invalid pointer   
	 **************************/
	expected_err = SA_ERR_HPI_INVALID_PARAMS;
	err = saHpiSensorThresholdsSet(sessionid, id, sid, NULL);
	checkstatus(err, expected_err, testfail);

	/************************** 
	 * Test: Invalid resource   
	 **************************/
	expected_err = SA_ERR_HPI_INVALID_RESOURCE;                   
	err = saHpiSensorThresholdsSet(sessionid, 5000, sid, &thres);
	checkstatus(err, expected_err, testfail);

	/************************** 
	 * Test: Invalid sensor id
	 **************************/
	expected_err = SA_ERR_HPI_NOT_PRESENT;                   
	err = saHpiSensorThresholdsSet(sessionid, id, 5000, &thres);
	checkstatus(err, expected_err, testfail);

	/***************************
	 * Cleanup after all tests
	 ***************************/
	err = tcleanup(&sessionid);
	return testfail;

}
int set_ThdPosHysteresis (saHpiSensorThdPosHysteresisTable_context *ctx) {

  SaHpiSensorThresholdsT thd;
  SaHpiSessionIdT session_id;
  SaErrorT rc;

  DEBUGMSGTL ((AGENT, "set_ThdPosHysteresis: Entry.\n"));
  if (ctx)
    {

      memset (&thd, 0x00, sizeof (SaHpiSensorThresholdsT));

      rc = getSaHpiSession (&session_id);
      if (rc != AGENT_ERR_NOERROR)
	{
	  DEBUGMSGTL ((AGENT, "Call to getSaHpiSession failed with rc: %d\n",
		       rc));
	  return rc;
	}
      /*
       * Get the current threshold information
       */
      DEBUGMSGTL((AGENT,"resource_id: %d, sensor_id: %d\n", ctx->resource_id, ctx->sensor_id));
      rc = saHpiSensorThresholdsGet (session_id,
				     ctx->resource_id,
				     ctx->sensor_id, &thd);

      if (rc != SA_OK)
	{
	  snmp_log (LOG_ERR,
		    "Call to saHpiSensorThresholdGet fails with return code: %s.\n",
		    get_error_string (rc));
	  DEBUGMSGTL ((AGENT,
		       "Call to saHpiSensorThresholdsGet fails with return code: %s\n",
		       get_error_string (rc)));
	  return AGENT_ERR_OPERATION;
	}

	/* Posdate the correct entry.	 */
      
      if (thd.PosThdHysteresis.ValuesPresent & SAHPI_SRF_INTERPRETED) {
	thd.PosThdHysteresis.Interpreted.Type = SAHPI_SENSOR_INTERPRETED_TYPE_BUFFER;
	memcpy(&thd.PosThdHysteresis.Interpreted.Value.SensorBuffer,
		&ctx->saHpiSensorThdPosHysteresisInterpreted,
		ctx->saHpiSensorThdPosHysteresisInterpreted_len);
	       
      }
      if (thd.PosThdHysteresis.ValuesPresent & SAHPI_SRF_RAW) {
	thd.PosThdHysteresis.Raw = ctx->saHpiSensorThdPosHysteresisRaw;
      }

      /*
       * Set the thresholds 
       */
      rc = saHpiSensorThresholdsSet (session_id,
				     ctx->resource_id,
				     ctx->sensor_id, &thd);

      if (rc != SA_OK)
	{
	  snmp_log (LOG_ERR,
		    "Call to saHpiSensorThresholdSet fails with return code: %s.\n",
		    get_error_string (rc));
	  DEBUGMSGTL ((AGENT,
		       "Call to saHpiSensorThresholdsSet fails with return code: %s\n",
		       get_error_string (rc)));
	  return AGENT_ERR_OPERATION;
	}

      /* 
       * Re-read the data. Might be different, so we will need
       * to populate the ctx.
       */

      memset (&thd, 0x00, sizeof (SaHpiSensorThresholdsT));
      rc = saHpiSensorThresholdsGet (session_id,
				     ctx->resource_id,
				     ctx->sensor_id, &thd);

      if (rc != SA_OK)
	{
	  snmp_log (LOG_ERR,
		    "Call to  SensorThresholdGet fails with return code: %s.\n",
		    get_error_string (rc));
	  DEBUGMSGTL ((AGENT,
		       "Call to  SensorThresholdGet fails with return code: %s.\n",
		       get_error_string (rc)));
	  return AGENT_ERR_OPERATION;
	}
      build_reading_strings (&thd.PosThdHysteresis,
			     0,
			     &ctx->saHpiSensorThdPosHysteresisValuesPresent,
			     &ctx->saHpiSensorThdPosHysteresisRaw,
			     ctx->saHpiSensorThdPosHysteresisInterpreted,
			     &ctx->saHpiSensorThdPosHysteresisInterpreted_len,
			     SENSOR_THD_INTER_MAX,
			     NULL, NULL, NULL, 0);


      DEBUGMSGTL ((AGENT, "set_ThdPosHysteresis: Exit.\n"));
      return AGENT_ERR_NOERROR;
    }
  DEBUGMSGTL ((AGENT, "set_sensor: Exit.\n"));

  return AGENT_ERR_NULL_DATA;


}
Beispiel #13
0
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;
}
Beispiel #14
0
static void mod_sen(void)
{
	int			i, rpt, rdr, num;
	char			buf[READ_BUF_SIZE], *S;
	Rpt_t			*Rpt;
	Rdr_t			*Rdr;
	SaHpiSensorThresholdsT	thres;
	SaErrorT		rv;
	ThresTypes_t		type = UNKNOWN_TYPE;
	float			f;
	SaHpiEventT		event;

	i = get_number("RPT number: ", &rpt);
	if (i != 1) {
		printf("ERROR: no RPT number\n");
		return;
	};
	i = find_rpt_by_id(rpt);
	if (i < 0) {
		printf("ERROR: invalid RPT number\n");
		return;
	};
	rpt = i;
	Rpt = Rpts + rpt;
	show_sens_for_rpt(Rpt);
	i = get_number("Sensor number: ", &num);
	if (i != 1) {
		printf("ERROR: no Sensor number\n");
		return;
	};
	rdr = find_sensor_by_num(Rpt, num);
	if (rdr < 0) {
		printf("ERROR: invalid sensor number\n");
		return;
	};
	Rdr = Rpt->rdrs + rdr;
	oh_print_rdr(&(Rdr->Rdr), 2);
	show_reading_value(Rpt, Rdr);
	rv = saHpiSensorThresholdsGet(sessionid, Rpt->Rpt.ResourceId,
		Rdr->Rdr.RdrTypeUnion.SensorRec.Num, &thres);
	if (rv != SA_OK) {
		printf("ERROR: %s\n", oh_lookup_error(rv));
		return;
	};
	printf("  Thresholds:\n");
	ShowThres(&thres);
	if (Rdr->is_value == 0) {
		Rdr->thresholds = thres;
		Rdr->is_value = 1;
	};
	printf("threshold type (lc, la, li, uc, ua, ui, ph, nh): ");
	fgets(buf, READ_BUF_SIZE, stdin);
	S = buf;
	while (*S == ' ') S++;
	if (strlen(S) < 2) {
		printf("ERROR: invalid threshold type: %s\n", S);
		return;
	};

	if (strncmp(S, "lc", 2) == 0) type = LOWER_CRIT;
	if (strncmp(S, "la", 2) == 0) type = LOWER_MAJOR;
	if (strncmp(S, "li", 2) == 0) type = LOWER_MINOR;
	if (strncmp(S, "uc", 2) == 0) type = UPPER_CRIT;
	if (strncmp(S, "ua", 2) == 0) type = UPPER_MAJOR;
	if (strncmp(S, "ui", 2) == 0) type = UPPER_MINOR;
	if (strncmp(S, "ph", 2) == 0) type = POS_HYST;
	if (strncmp(S, "nh", 2) == 0) type = NEG_HYST;

	if (type == UNKNOWN_TYPE) {
		printf("ERROR: unknown threshold type: %s\n", S);
		return;
	};
	
	printf("new value: ");
	fgets(buf, READ_BUF_SIZE, stdin);
	i = sscanf(buf, "%f", &f);
	if (i == 0) {
		printf("ERROR: no value\n");
		return;
	};
	switch (type) {
		case LOWER_CRIT:
			set_thres_value(&(thres.LowCritical), (double)f);
			break;
		case LOWER_MAJOR:
			set_thres_value(&(thres.LowMajor), (double)f);
			break;
		case LOWER_MINOR:
			set_thres_value(&(thres.LowMinor), (double)f);
			break;
		case UPPER_CRIT:
			set_thres_value(&(thres.UpCritical), (double)f);
			break;
		case UPPER_MAJOR:
			set_thres_value(&(thres.UpMajor), (double)f);
			break;
		case UPPER_MINOR:
			set_thres_value(&(thres.UpMinor), (double)f);
			break;
		case POS_HYST:
			set_thres_value(&(thres.PosThdHysteresis), (double)f);
			break;
		case NEG_HYST:
			set_thres_value(&(thres.NegThdHysteresis), (double)f);
			break;
		default:
			printf("ERROR: unknown threshold\n");
	};
	printf("\n  Nem threshold:\n");
	ShowThres(&thres);
	printf("Is it correct (yes, no)?:");
	fgets(buf, READ_BUF_SIZE, stdin);
	S = buf;
	while (*S == ' ') S++;
	if (strncmp(S, "yes", 3) != 0)
		return;
	rv = saHpiSensorThresholdsSet(sessionid, Rpt->Rpt.ResourceId,
		Rdr->Rdr.RdrTypeUnion.SensorRec.Num, &thres);
	if (rv != SA_OK) {
		printf("ERROR: saHpiSensorThresholdsSet: %s\n", oh_lookup_error(rv));
		return;
	};
	Rdr->modify = 1;
	for (i = 0; i < 10; i++) {
		rv = saHpiEventGet(sessionid, SAHPI_TIMEOUT_IMMEDIATE, &event,
			NULL, NULL, NULL);
		if (rv == SA_OK)
			break;
		if (fdebug) printf("sleep before saHpiEventGet\n");
		sleep(1);
	};
	saHpiSensorThresholdsGet(sessionid, Rpt->Rpt.ResourceId,
		Rdr->Rdr.RdrTypeUnion.SensorRec.Num, &thres);
	printf("Current thresholds:\n");
	ShowThres(&thres);
}
Beispiel #15
0
int Test_Rdr(SaHpiSessionIdT sessionId,
	     SaHpiResourceIdT resourceId, SaHpiRdrT rdr)
{
	SaErrorT status;
	int retval = SAF_TEST_NOTSUPPORT;
	SaHpiSensorRecT *sensorRec;
	SaHpiSensorThresholdsT threshold;
	SaHpiSensorReadingTypeT type;
	SaHpiSensorReadingUnionT maxValue;

	if (canTest(sessionId, resourceId, &rdr)) {

		sensorRec = &rdr.RdrTypeUnion.SensorRec;
		type = sensorRec->DataFormat.ReadingType;

		if (hasMax(sensorRec)) {

			maxValue = getMaxValue(sensorRec);
			if (!isOverflow(maxValue, type)) {

				if (hasWriteThreshold
				    (sensorRec, SAHPI_STM_UP_CRIT)) {

					initThresholds(&threshold, type);

					threshold.UpCritical.IsSupported =
					    SAHPI_TRUE;
					threshold.UpCritical.Value =
					    increaseValue(maxValue, type);

					status =
					    saHpiSensorThresholdsSet(sessionId,
								     resourceId,
								     sensorRec->
								     Num,
								     &threshold);

					if (status == SA_ERR_HPI_INVALID_CMD) {
						retval = SAF_TEST_PASS;
					} else {
						retval = SAF_TEST_FAIL;
						e_print
						    (saHpiSensorThresholdsSet,
						     SA_ERR_HPI_INVALID_CMD,
						     status);
					}
				} else
				    if (hasWriteThreshold
					(sensorRec, SAHPI_STM_UP_MAJOR)) {

					initThresholds(&threshold, type);

					threshold.UpMajor.IsSupported =
					    SAHPI_TRUE;
					threshold.UpMajor.Value =
					    increaseValue(maxValue, type);

					status =
					    saHpiSensorThresholdsSet(sessionId,
								     resourceId,
								     sensorRec->
								     Num,
								     &threshold);

					if (status == SA_ERR_HPI_INVALID_CMD) {
						retval = SAF_TEST_PASS;
					} else {
						retval = SAF_TEST_FAIL;
						e_print
						    (saHpiSensorThresholdsSet,
						     SA_ERR_HPI_INVALID_CMD,
						     status);
					}
				} else
				    if (hasWriteThreshold
					(sensorRec, SAHPI_STM_UP_MINOR)) {

					initThresholds(&threshold, type);

					threshold.UpMinor.IsSupported =
					    SAHPI_TRUE;
					threshold.UpMinor.Value =
					    increaseValue(maxValue, type);

					status =
					    saHpiSensorThresholdsSet(sessionId,
								     resourceId,
								     sensorRec->
								     Num,
								     &threshold);

					if (status == SA_ERR_HPI_INVALID_CMD) {
						retval = SAF_TEST_PASS;
					} else {
						retval = SAF_TEST_FAIL;
						e_print
						    (saHpiSensorThresholdsSet,
						     SA_ERR_HPI_INVALID_CMD,
						     status);
					}
				}
			}
		}
	}

	return retval;
}
Beispiel #16
0
static int sa_set_thres(int argc, char *argv[])
{
	SaHpiResourceIdT resourceid;
	SaHpiSensorNumT sensornum; 
	SaErrorT rv;
	SaHpiSensorThresholdsT stbuff;
	int i;

	resourceid = (SaHpiResourceIdT)atoi(argv[1]);
	sensornum = (SaHpiResourceIdT)atoi(argv[2]);

	rv = saHpiSensorThresholdsGet(sessionid, resourceid,
					sensornum, &stbuff);
	if (rv != SA_OK) 
		printf("saHpiSensorThresholdsGet error %d\n",rv);

	for (i=3; i<argc; i+=2) {
		if (!argv[i+1]) {
	 		return HPI_SHELL_PARM_ERROR;
	 	}
		printf("%s", argv[i]);
		if (!strcmp(argv[i],"lc")) {
			stbuff.LowCritical.ValuesPresent = SAHPI_SRF_INTERPRETED;
			stbuff.LowCritical.Interpreted.Value.SensorFloat32 =
				(SaHpiFloat32T)atof(argv[i+1]);
		} else if (!strcmp(argv[i],"la")) {
			stbuff.LowMajor.ValuesPresent = SAHPI_SRF_INTERPRETED;
			stbuff.LowMajor.Interpreted.Value.SensorFloat32 =
				(SaHpiFloat32T)atof(argv[i+1]);
		} else if (!strcmp(argv[i],"li")) {
			stbuff.LowMinor.ValuesPresent = SAHPI_SRF_INTERPRETED;
			stbuff.LowMinor.Interpreted.Value.SensorFloat32 =
				(SaHpiFloat32T)atof(argv[i+1]);
		} else if (!strcmp(argv[i],"uc")) {
			stbuff.UpCritical.ValuesPresent = SAHPI_SRF_INTERPRETED;
			stbuff.UpCritical.Interpreted.Value.SensorFloat32 =
				(SaHpiFloat32T)atof(argv[i+1]);
		} else if (!strcmp(argv[i],"ua")) {
			stbuff.UpMajor.ValuesPresent = SAHPI_SRF_INTERPRETED;
			stbuff.UpMajor.Interpreted.Value.SensorFloat32 =
				(SaHpiFloat32T)atof(argv[i+1]);
		} else if (!strcmp(argv[i],"ui")) {
			stbuff.UpMinor.ValuesPresent = SAHPI_SRF_INTERPRETED;
			stbuff.UpMinor.Interpreted.Value.SensorFloat32 =
				(SaHpiFloat32T)atof(argv[i+1]);
		} else if (!strcmp(argv[i],"ph")) {
			stbuff.PosThdHysteresis.ValuesPresent = SAHPI_SRF_INTERPRETED;
			stbuff.PosThdHysteresis.Interpreted.Value.SensorFloat32 =
				(SaHpiFloat32T)atof(argv[i+1]);
		} else if (!strcmp(argv[i],"nh")) {
			stbuff.NegThdHysteresis.ValuesPresent = SAHPI_SRF_INTERPRETED;
			stbuff.NegThdHysteresis.Interpreted.Value.SensorFloat32 =
				(SaHpiFloat32T)atof(argv[i+1]);
		} else {
			return HPI_SHELL_PARM_ERROR;
		}
	}

	rv = saHpiSensorThresholdsSet(
			sessionid, resourceid, sensornum, &stbuff);
	if (rv != SA_OK) 
		printf("saHpiSensorThresholdsSet error %d\n",rv);
	else
		printf("Sensor Threshold Value Set Succeed.\n");

	return SA_OK;
}