Sun Microsystems Netra CP2500 User Manual
Page 53
Chapter 2
Environmental Monitoring
39
if (picl_get_propval_by_name(nodeh, LO_SHUTDOWN_THRESHOLD,
&threshold, sizeof (threshold)) != PICL_SUCCESS) {
fprintf(stderr, "Failed to read low shutdown threshold.");
} else
fprintf(stdout, "Low shutdown threshold = %d\n", threshold);
if (picl_get_propval_by_name(nodeh, LO_WARNING_THRESHOLD,
&threshold, sizeof (threshold)) != PICL_SUCCESS) {
fprintf(stderr, "Failed to read low warning threshold.");
} else
fprintf(stderr, "Low warning threshold = %d\n", threshold);
}
void
set_sensor_thresholds(picl_nodehdl_t nodeh, char *threshold, int8_t value)
{
int8_t new_value = value;
if (picl_set_propval_by_name(nodeh, threshold, &new_value,
sizeof (new_value)) != PICL_SUCCESS)
fprintf(stderr, "Failed to set *s\n", threshold);
}
int
main(void)
{
int warning_temp;
int8_t temp;
char *sensor = "CPU-sensor";
picl_nodehdl_t rooth;
picl_nodehdl_t platformh;
picl_nodehdl_t childh;
if (picl_initialize() != PICL_SUCCESS) {
fprintf(stderr, "Failed to initialise picl\n");
return (1);
}
if (picl_get_root(&rooth) != PICL_SUCCESS) {
fprintf(stderr, "Failed to get root node\n");
picl_shutdown();
return (1);
}
if (get_child_by_name(rooth, "platform", &platformh) != PICL_SUCCESS) {
fprintf(stderr, "Failed to get platform node\n");
picl_shutdown();
CODE EXAMPLE 2-1
Sample envmond Application Program (Continued)