1 Star 0 Fork 0

叶海丰/ipmi-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
cmd_clear_sel.go 1.33 KB
一键复制 编辑 原始数据 按行查看 历史
叶海丰 提交于 2024-08-02 08:43 . init
package ipmi
import "fmt"
// 31.9 Clear SEL Command
type ClearSELRequest struct {
ReservationID uint16 // LS Byte first
GetErasureStatusFlag bool
}
type ClearSELResponse struct {
ErasureProgressStatus uint8
}
func (req *ClearSELRequest) Pack() []byte {
var out = make([]byte, 6)
packUint16L(req.ReservationID, out, 0)
packUint8('C', out, 2) // fixed 'C' char
packUint8('L', out, 3) // fixed 'L' char
packUint8('R', out, 4) // fixed 'R' char
if req.GetErasureStatusFlag {
packUint8(0x00, out, 5) // get erasure status
} else {
packUint8(0xaa, out, 5) // initiate erase
}
return out
}
func (req *ClearSELRequest) Command() Command {
return CommandClearSEL
}
func (res *ClearSELResponse) Unpack(msg []byte) error {
if len(msg) < 1 {
return ErrUnpackedDataTooShortWith(len(msg), 1)
}
res.ErasureProgressStatus, _, _ = unpackUint8(msg, 0)
return nil
}
func (res *ClearSELResponse) CompletionCodes() map[uint8]string {
// no command-specific cc
return map[uint8]string{}
}
func (res *ClearSELResponse) Format() string {
return fmt.Sprintf("%v", res)
}
func (c *Client) ClearSEL(reservationID uint16) (response *ClearSELResponse, err error) {
request := &ClearSELRequest{
ReservationID: reservationID,
GetErasureStatusFlag: false,
}
response = &ClearSELResponse{}
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
3b6556707aea

搜索帮助