File: cmd_set_watchdog_timer.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 (67 lines) | stat: -rw-r--r-- 1,438 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
package ipmi

import "context"

// 27.6 Set Watchdog Timer Command
type SetWatchdogTimerRequest struct {
	DontLog       bool
	DontStopTimer bool
	TimerUse      TimerUse

	PreTimeoutInterrupt   PreTimeoutInterrupt
	TimeoutAction         TimeoutAction
	PreTimeoutIntervalSec uint8

	ExpirationFlags  uint8
	InitialCountdown uint16
}

type SetWatchdogTimerResponse struct {
}

func (req *SetWatchdogTimerRequest) Pack() []byte {
	out := make([]byte, 6)

	b0 := uint8(req.TimerUse)
	if req.DontLog {
		b0 = setBit7(b0)
	}
	if req.DontStopTimer {
		b0 = setBit6(b0)
	}
	packUint8(b0, out, 0)

	b1 := uint8(req.TimeoutAction)
	b1 |= uint8(req.PreTimeoutInterrupt) << 4
	packUint8(b1, out, 1)

	packUint8(req.PreTimeoutIntervalSec, out, 2)
	packUint8(req.ExpirationFlags, out, 3)
	packUint16L(req.InitialCountdown, out, 4)

	return out
}

func (req *SetWatchdogTimerRequest) Command() Command {
	return CommandSetWatchdogTimer
}

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

func (res *SetWatchdogTimerResponse) CompletionCodes() map[uint8]string {
	// no command-specific cc
	return map[uint8]string{}
}

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

func (c *Client) SetWatchdogTimer(ctx context.Context) (response *SetWatchdogTimerResponse, err error) {
	request := &SetWatchdogTimerRequest{}
	response = &SetWatchdogTimerResponse{}
	err = c.Exchange(ctx, request, response)
	return
}