File: cmd_set_sensor_reading_and_event_status.go

package info (click to toggle)
golang-github-bougou-go-ipmi 0.7.8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,880 kB
  • sloc: makefile: 38
file content (68 lines) | stat: -rw-r--r-- 1,890 bytes parent folder | download | duplicates (2)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package ipmi

import "context"

// 35.17 Set Sensor Reading And Event Status Command
type SetSensorReadingAndEventStatusRequest struct {
	SensorNumber uint8

	EventDataBytesOperation  uint8
	AssertionBitsOperation   uint8
	DeassertionBitsOperation uint8
	SensorReadingOperation   uint8

	SensorReading uint8

	SensorEventFlag

	EventData1 uint8
	EventData2 uint8
	EventData3 uint8
}

type SetSensorReadingAndEventStatusResponse struct {
	// empty
}

func (req *SetSensorReadingAndEventStatusRequest) Command() Command {
	return CommandSetSensorReadingAndEventStatus
}

func (req *SetSensorReadingAndEventStatusRequest) Pack() []byte {
	out := make([]byte, 9)
	packUint8(req.SensorNumber, out, 0)

	var operation uint8
	operation |= uint8(req.EventDataBytesOperation) << 6
	operation |= (uint8(req.AssertionBitsOperation) & 0x3f) << 4
	operation |= (uint8(req.DeassertionBitsOperation) & 0x0f) << 2
	operation |= uint8(req.SensorReadingOperation) & 0x03
	packUint8(operation, out, 1)

	packUint8(req.SensorReading, out, 2)

	// Todo determine sensor is threshold based or discrete

	return out
}

func (res *SetSensorReadingAndEventStatusResponse) Unpack(msg []byte) error {
	return nil
}

func (r *SetSensorReadingAndEventStatusResponse) CompletionCodes() map[uint8]string {
	return map[uint8]string{
		0x80: "Attempt to change reading or set or clear status bits that are not settable via this command",
		0x81: "Attempted to set Event Data Bytes, but setting Event Data Bytes is not supported for this sensor.",
	}
}

func (res *SetSensorReadingAndEventStatusResponse) Format() string {
	return ""
}

func (c *Client) SetSensorReadingAndEventStatus(ctx context.Context, request *SetSensorReadingAndEventStatusRequest) (response *SetSensorReadingAndEventStatusResponse, err error) {
	response = &SetSensorReadingAndEventStatusResponse{}
	err = c.Exchange(ctx, request, response)
	return
}