1 Star 0 Fork 0

叶海丰/ipmi-go

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cmd_get_sensor_hysteresis.go 1.50 KB
一键复制 编辑 原始数据 按行查看 历史
叶海丰 提交于 2024-08-02 08:43 +08:00 . init
package ipmi
import "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
Negative Hysteresis : %d`,
res.PositiveRaw,
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(sensorNumber uint8) (response *GetSensorHysteresisResponse, err error) {
request := &GetSensorHysteresisRequest{
SensorNumber: sensorNumber,
}
response = &GetSensorHysteresisResponse{}
err = c.Exchange(request, response)
return
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/rogax/ipmi-go.git
git@gitee.com:rogax/ipmi-go.git
rogax
ipmi-go
ipmi-go
86ae46cfb58e

搜索帮助