/
types_modbusd.go
68 lines (62 loc) · 2.14 KB
/
types_modbusd.go
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 psmb
//
// psmb to modbusd structures - downstream
//
type (
// DMbtcpRes downstream modbus tcp read/write response
DMbtcpRes struct {
// Tid unique transaction id in string format
Tid string `json:"tid"`
// Status response status string
Status string `json:"status"`
// Data for 'read function code' only.
Data []uint16 `json:"data,omitempty"`
}
// DMbtcpReadReq downstream modbus tcp read request
DMbtcpReadReq struct {
// Tid unique transaction id in `string` format
Tid string `json:"tid"`
// Cmd modbusd command type: https://github.com/taka-wang/modbusd#command-mapping-table
Cmd int `json:"cmd"`
// IP ip address or hostname of the modbus tcp slave
IP string `json:"ip"`
// Port port number of the modbus tcp slave
Port string `json:"port"`
// Slave device id of the modbus tcp slave
Slave uint8 `json:"slave"`
// Addr start address for read
Addr uint16 `json:"addr"`
// Len the length of registers or bits
Len uint16 `json:"len"`
}
// DMbtcpWriteReq downstream modbus tcp write single bit/register request
DMbtcpWriteReq struct {
// Tid unique transaction id in `string` format
Tid string `json:"tid"`
// Cmd modbusd command type: https://github.com/taka-wang/modbusd#command-mapping-table
Cmd int `json:"cmd"`
// IP ip address or hostname of the modbus tcp slave
IP string `json:"ip"`
// Port port number of the modbus tcp slave
Port string `json:"port"`
// Slave device id of the modbus tcp slave
Slave uint8 `json:"slave"`
// Addr start address for write
Addr uint16 `json:"addr"`
// Len omit for fc5, fc6
Len uint16 `json:"len,omitempty"`
// Data should be []uint16, uint16 (FC5, FC6)
Data interface{} `json:"data"`
}
// DMbtcpTimeout downstream modbus tcp set/get timeout request/response
DMbtcpTimeout struct {
// Tid unique transaction id in `string` format
Tid string `json:"tid"`
// Cmd modbusd command type: https://github.com/taka-wang/modbusd#command-mapping-table
Cmd int `json:"cmd"`
// Status for response only.
Status string `json:"status,omitempty"`
// Timeout set timeout request and get timeout response only.
Timeout int64 `json:"timeout,omitempty"`
}
)