12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- package main
- import (
- "encoding/hex"
- "fmt"
- "smart_tunnel_edge/protocol/switchRelay"
- "testing"
- )
- func Test_verify(t *testing.T) {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ints := []int{1, 2}
- command := switchRelay.MultiLoopDataPack{Address: "FE", TurnOff: 0, State: ints}.GetControlMuchSwitchRelayCommand()
-
- fmt.Println("转换后:", hex.EncodeToString(command.Bytes()))
- }
- func parseHexString(hexStr string) string {
-
- bytes, err := hex.DecodeString(hexStr)
- if err != nil {
- fmt.Println("错误: 十六进制字符串解析失败", err)
- return ""
- }
-
- return string(bytes)
- }
- func generateHexSwitchState(switches []int) []byte {
- var state int
-
- for _, s := range switches {
- state |= 1 << (s - 1)
- }
-
- return []byte{byte(state)}
- }
|