BxCmdState.go 579 B

123456789101112131415161718192021222324252627
  1. package bx
  2. import (
  3. "bytes"
  4. "encoding/binary"
  5. )
  6. type CmdState struct {
  7. baseBxCmd
  8. }
  9. func NewCmdState() CmdState {
  10. return CmdState{
  11. baseBxCmd: newBaseCmd(CMD_SYSTEM_STATE.group, CMD_SYSTEM_STATE.code),
  12. }
  13. }
  14. func (cmd CmdState) Build() []byte {
  15. w := bytes.NewBuffer(make([]byte, 0, 1024))
  16. binary.Write(w, binary.LittleEndian, cmd.Group())
  17. binary.Write(w, binary.LittleEndian, cmd.Cmd())
  18. binary.Write(w, binary.LittleEndian, cmd.ReqResp())
  19. //r0 r1
  20. binary.Write(w, binary.LittleEndian, byte(0x00))
  21. binary.Write(w, binary.LittleEndian, byte(0x00))
  22. return w.Bytes()
  23. }