1 Star 0 Fork 0

叶海丰/ipmi-go

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cmd_write_fru_data.go 1.53 KB
一键复制 编辑 原始数据 按行查看 历史
叶海丰 提交于 2024-08-02 08:43 +08:00 . init
package ipmi
import (
"fmt"
)
// 34.3 Write FRU Data Command
type WriteFRUDataRequest struct {
FRUDeviceID uint8
WriteOffset uint16
WriteData []byte
}
type WriteFRUDataResponse struct {
CountWritten uint8
}
func (req *WriteFRUDataRequest) Command() Command {
return CommandWriteFRUData
}
func (req *WriteFRUDataRequest) Pack() []byte {
out := make([]byte, 4)
packUint8(req.FRUDeviceID, out, 0)
packUint16L(req.WriteOffset, out, 1)
packBytes(req.WriteData, out, 3)
return out
}
func (res *WriteFRUDataResponse) Unpack(msg []byte) error {
if len(msg) < 1 {
return ErrUnpackedDataTooShortWith(len(msg), 1)
}
res.CountWritten, _, _ = unpackUint8(msg, 0)
return nil
}
func (r *WriteFRUDataResponse) CompletionCodes() map[uint8]string {
return map[uint8]string{
0x80: "write-protected offset",
0x81: "FRU device busy",
}
}
func (res *WriteFRUDataResponse) Format() string {
return fmt.Sprintf(`Count written : %d`, res.CountWritten)
}
// The command writes the specified byte or word to the FRU Inventory Info area. This is a low level direct interface to a non-volatile storage area. This means that the interface does not interpret or check any semantics or formatting for the data being written.
func (c *Client) WriteFRUData(fruDeviceID uint8, writeOffset uint16, writeData []byte) (response *WriteFRUDataResponse, err error) {
request := &WriteFRUDataRequest{
FRUDeviceID: fruDeviceID,
WriteOffset: writeOffset,
WriteData: writeData,
}
response = &WriteFRUDataResponse{}
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

搜索帮助