1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
package ipmi
import (
"context"
"fmt"
)
// 35.7 Get Sensor Hysteresis Command
type GetSensorHysteresisRequest struct {
SensorNumber uint8
}
type GetSensorHysteresisResponse struct {
PositiveRaw uint8
NegativeRaw uint8
}
func (req *GetSensorHysteresisRequest) Command() Command {
return CommandGetSensorHysteresis
}
func (req *GetSensorHysteresisRequest) Pack() []byte {
out := make([]byte, 2)
packUint8(req.SensorNumber, out, 0)
packUint8(0xff, out, 1) // reserved for future "hysteresis mask" definition. Write as "FFh"
return out
}
func (res *GetSensorHysteresisResponse) Unpack(msg []byte) error {
if len(msg) < 2 {
return ErrUnpackedDataTooShortWith(len(msg), 2)
}
res.PositiveRaw, _, _ = unpackUint8(msg, 0)
res.NegativeRaw, _, _ = unpackUint8(msg, 1)
return nil
}
func (r *GetSensorHysteresisResponse) CompletionCodes() map[uint8]string {
return map[uint8]string{}
}
func (res *GetSensorHysteresisResponse) Format() string {
return "" +
fmt.Sprintf("Positive Hysteresis : %d\n", res.PositiveRaw) +
fmt.Sprintf("Negative Hysteresis : %d\n", res.NegativeRaw)
}
// This command retrieves the present hysteresis values for the specified sensor.
// If the sensor hysteresis values are "fixed", then the hysteresis values can be obtained from the SDR for the sensor.
func (c *Client) GetSensorHysteresis(ctx context.Context, sensorNumber uint8) (response *GetSensorHysteresisResponse, err error) {
request := &GetSensorHysteresisRequest{
SensorNumber: sensorNumber,
}
response = &GetSensorHysteresisResponse{}
err = c.Exchange(ctx, request, response)
return
}
|