static void get_sensor_reading(uint8_t fru, uint8_t *sensor_list, int sensor_cnt, int num, bool threshold) { int i; uint8_t snr_num; float fvalue; char path[64]; char status[8]; thresh_sensor_t thresh; for (i = 0; i < sensor_cnt; i++) { snr_num = sensor_list[i]; /* If calculation is for a single sensor, ignore all others. */ if (num && snr_num != num) { continue; } if (sdr_get_snr_thresh(fru, snr_num, &thresh)) syslog(LOG_ERR, "sdr_init_snr_thresh failed for FRU %d num: 0x%X", fru, snr_num); usleep(50); if (pal_sensor_read(fru, snr_num, &fvalue) < 0) { printf("%-18s (0x%X) : NA | (na)\n", thresh.name, sensor_list[i]); continue; } else { get_sensor_status(fvalue, &thresh, status); print_sensor_reading(fvalue, snr_num, &thresh, threshold, status); } } }
static void calculate_sensor_reading(uint8_t fru, uint8_t *sensor_list, int sensor_cnt, int num, bool threshold) { int i; uint8_t snr_num; float fvalue; char path[64]; thresh_sensor_t thresh; for (i = 0; i < sensor_cnt; i++) { snr_num = sensor_list[i]; /* If calculation is for a single sensor, ignore all others. */ if (num && snr_num != num) { continue; } if (threshold) { if (sdr_get_snr_thresh(fru, snr_num, 0, &thresh)) syslog(LOG_ERR, "sdr_init_snr_thresh failed for FRU %d num: 0x%X", fru, snr_num); } else { sdr_get_sensor_name(fru, sensor_list[i], thresh.name); sdr_get_sensor_units(fru, sensor_list[i], thresh.units); } usleep(50); if (pal_sensor_read(fru, snr_num, &fvalue) < 0) { printf("pal_sensor_read failed: FRU: %d num: 0x%X name: %-23s\n", fru, sensor_list[i], thresh.name, thresh.units); continue; } else { print_sensor_reading(fvalue, &thresh, threshold); } } }