forked from bougou/go-ipmi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd_get_message.go
45 lines (37 loc) · 947 Bytes
/
cmd_get_message.go
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
package ipmi
// 22.6 Get Message Command
type GetMessageRequest struct {
// empty
}
type GetMessageResponse struct {
ChannelNumber uint8
MessageData []byte
}
func (req *GetMessageRequest) Command() Command {
return CommandGetMessage
}
func (req *GetMessageRequest) Pack() []byte {
return []byte{}
}
func (res *GetMessageResponse) CompletionCodes() map[uint8]string {
return map[uint8]string{
0x80: "data not available (queue / buffer empty)",
}
}
func (res *GetMessageResponse) Unpack(msg []byte) error {
if len(msg) < 1 {
return ErrUnpackedDataTooShort
}
res.ChannelNumber, _, _ = unpackUint8(msg, 0)
res.MessageData, _, _ = unpackBytes(msg, 1, len(msg)-1)
return nil
}
func (res *GetMessageResponse) Format() string {
return ""
}
func (c *Client) GetMessage() (response *GetMessageResponse, err error) {
request := &GetMessageRequest{}
response = &GetMessageResponse{}
err = c.Exchange(request, response)
return
}