sel: Fix the deasserted thresholds inequality

The choice of > or < when printing the threshold inequality currently
only depends on whether it is an upper or lower threshold. This is
correct when the event is asserted, but when the event is deasserted the
inequality is reversed and therefore the current code can give confusing
results, e.g.:

```
Temperature ps1_inlet_temp |
Upper Non-critical going high |
Deasserted |
Reading 43.94 > Threshold 44.88 degrees C
```

This commit fixes that.

See ipmitool/ipmitool#349

Signed-off-by: Andy Clegg <andyc@graphcore.ai>
This commit is contained in:
Andy Clegg 2022-07-25 14:20:30 +01:00 committed by Alexander Amelkin
parent 4d25a93f49
commit a1dc78c456

View File

@ -1955,8 +1955,20 @@ ipmi_sel_print_std_entry(struct ipmi_intf * intf, struct sel_event_record * evt)
(trigger_reading==(int)trigger_reading) ? 0 : 2,
trigger_reading);
if (threshold_reading_provided) {
/* According to Table 29-6, Event Data byte 1 contains,
* among other info, the offset from the Threshold type
* code. According to Table 42-2, all even offsets
* are 'going low', and all odd offsets are 'going high'
*/
bool going_high =
(evt->sel_type.standard_type.event_data[0]
& EVENT_OFFSET_MASK) % 2;
if (evt->sel_type.standard_type.event_dir) {
/* Event is de-asserted so the inequality is reversed */
going_high = !going_high;
}
printf(" %s Threshold %.*f %s",
((evt->sel_type.standard_type.event_data[0] & 0xf) % 2) ? ">" : "<",
going_high ? ">" : "<",
(threshold_reading==(int)threshold_reading) ? 0 : 2,
threshold_reading,
ipmi_sdr_get_unit_string(sdr->record.common->unit.pct,