1 Star 0 Fork 0

叶海丰/ipmi-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cmd_get_system_restart_cause.go 2.41 KB
一键复制 编辑 原始数据 按行查看 历史
叶海丰 提交于 2024-08-02 08:43 . init
package ipmi
import "fmt"
// 28.11 Get System Restart Cause Command
type GetSystemRestartCauseRequest struct {
// no data
}
type GetSystemRestartCauseResponse struct {
SystemRestartCause SystemRestartCause
ChannelNumber uint8
}
type SystemRestartCause uint8
var systemRestartCauses = map[SystemRestartCause]string{
0x00: "unknown", // unknown (system start/restart detected, but cause unknown)
0x01: "chassis power control command", //
0x02: "reset via pushbutton", //
0x03: "power-up via pushbutton", //
0x04: "watchdog expired", //
0x05: "OEM", //
0x06: "power-up due to always-on restore power policy", // automatic power-up on AC being applied due to 'always restore' power restore policy
0x07: "power-up due to previous restore power policy", // automatic power-up on AC being applied due to 'restore previous power state' power restore policy
0x08: "reset via PEF", //
0x09: "power-cycle via PEF", //
0x0a: "soft reset", // soft reset (e.g. CTRL-ALT-DEL) [optional]
0x0b: "power-up via RTC wakeup", // power-up via RTC (system real time clock) wakeup [optional]
}
func (c SystemRestartCause) String() string {
s, ok := systemRestartCauses[c]
if ok {
return s
}
return "invalid"
}
func (req *GetSystemRestartCauseRequest) Pack() []byte {
return []byte{}
}
func (req *GetSystemRestartCauseRequest) Command() Command {
return CommandGetSystemRestartCause
}
func (res *GetSystemRestartCauseResponse) CompletionCodes() map[uint8]string {
return map[uint8]string{}
}
func (res *GetSystemRestartCauseResponse) Unpack(msg []byte) error {
if len(msg) < 2 {
return ErrUnpackedDataTooShortWith(len(msg), 2)
}
b, _, _ := unpackUint8(msg, 0)
res.SystemRestartCause = SystemRestartCause(b)
res.ChannelNumber, _, _ = unpackUint8(msg, 1)
return nil
}
func (res *GetSystemRestartCauseResponse) Format() string {
return fmt.Sprintf("System restart cause: %s", res.SystemRestartCause.String())
}
func (c *Client) GetSystemRestartCause() (response *GetSystemRestartCauseResponse, err error) {
request := &GetSystemRestartCauseRequest{}
response = &GetSystemRestartCauseResponse{}
err = c.Exchange(request, response)
return
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/rogax/ipmi-go.git
git@gitee.com:rogax/ipmi-go.git
rogax
ipmi-go
ipmi-go
86ae46cfb58e

搜索帮助

0d507c66 1850385 C8b1a773 1850385