-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevice.go
More file actions
65 lines (59 loc) · 1.17 KB
/
device.go
File metadata and controls
65 lines (59 loc) · 1.17 KB
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
package gomcprotocol
// Mode selects binary or ASCII framing.
type Mode int
const (
ModeBinary Mode = iota // binary (3E/4E) framing
ModeASCII // ASCII (3E/4E) framing
)
// Binary device codes (iQ-R / Q series).
var binCode = map[string]byte{
"D": 0xA8,
"W": 0xB4,
"R": 0xAF,
"ZR": 0xB0,
"X": 0x9C,
"Y": 0x9D,
"M": 0x90,
"L": 0x92,
"B": 0xA0,
"F": 0x93,
"V": 0x94,
"TC": 0xC0,
"TS": 0xC1,
"STC": 0xC6,
"STS": 0xC7,
"CC": 0xC3,
"CS": 0xC4,
"SB": 0xA1,
"SW": 0xB5,
"SM": 0x91,
"SD": 0xA9,
"TN": 0xC2,
"STN": 0xC8,
"CN": 0xC5,
"S": 0x98,
"DX": 0xA2,
"DY": 0xA3,
"Z": 0xCC,
}
// decimalAddrDevs records devices whose device numbers are decimal in ASCII mode.
var decimalAddrDevs = map[string]bool{
"SM": true, "SD": true,
"M": true, "L": true, "F": true, "V": true,
"D": true, "R": true,
"TC": true, "TS": true, "TN": true,
"STC": true, "STS": true, "STN": true,
"CC": true, "CS": true, "CN": true,
"S": true, "Z": true,
}
var ascCode = map[string]string{
"STC": "SC",
"STS": "SS",
"STN": "SN",
}
const (
cmdRead uint16 = 0x0401
cmdWrite uint16 = 0x1401
subcWord uint16 = 0x0000
subcBit uint16 = 0x0001
)