You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The default configuration file is configured to initialize every register with a `0x0000`.
35
43
To set register values, you need to create your own configuration file.
36
44
37
-
An example can be found in the GIT repo: [abb_coretec_example.json](./examples/abb_coretec_example.json)
38
-
39
45
```bash
40
46
docker run --rm -p 5020:5020 -v ./server_config.json:/server_config.json oitc/modbus-server:latest -f /server_config.json
41
47
```
42
48
49
+
or you mount the config file over the default file, then you can skip the file parameter:
50
+
51
+
```bash
52
+
docker run --rm -p 5020:5020 -v ./server_config.json:/app/modbus_server.json oitc/modbus-server:latest
53
+
```
54
+
43
55
# Configuration
44
56
45
-
## Default configuration
57
+
## Configuration file
58
+
59
+
The path and filename to the general configuration file can be set via command option `-f <file>` after mounting it inside of the container. By default, the script will use `/app/modbus_server.json`.
60
+
61
+
### Default configuration file of the container
62
+
63
+
The `/app/modbus_server.json` file comes with following content:
|`server`| Object | Modbus slave specific runtime parameters. |
97
+
|`server.listenerAddress`| String | The IPv4 Address to bound to when starting the server. `"0.0.0.0"` let the server listens on all interface addresses. |
98
+
|`server.listenerPort`| Integer | The TCP port number of the modbus slave to listen to. |
99
+
|`server.tlsParams`| Object | Configuration parameters to use TLS encrypted modbus tcp slave. (untested) |
100
+
|`server.tlsParams.description`| String | No configuration option, just a description of the parameters. |
101
+
|`server.tlsParams.privateKey`| String | Filesystem path of the private key to use for a TLS encrypted communication. |
102
+
|`server.tlsParams.certificate`| String | Filesystem path of the TLS certificate to use for a TLS encrypted communication. |
103
+
|`server.logging`| Object | Log specific configuration. |
104
+
|`server.logging.format`| String | The format of the log messages as described here: https://docs.python.org/3/library/logging.html#logrecord-attributes|
105
+
|`server.logging.logLevel`| String | Defines the maximum level of severity to log to std out. Possible values are `DEBUG`, `INFO`, `WARN` and `ERROR`. |
106
+
|`registers`| Object | Configuration parameters to predefine registers. |
107
+
|`registers.description`| String | No configuration option, just a description of the parameters. |
108
+
|`registers.zeroMode`| Boolean | By default the modbus registers starts at 1 (`false`) but some implementation requires to start at 0 (`true`). |
109
+
|`registers.initializeUndefinedRegisters`| Boolean | If `true` the server will initialize all not defined registers with a default value of `0`. |
110
+
|`registers.discreteInput`| Object | The pre-defined registers of the register type "Discrete Input". |
111
+
|`registers.coils`| Object | The pre-defined registers of the register type "Coils". |
112
+
|`registers.holdingRegister`| Object | The pre-defined registers of the register type "Holding Registers". |
113
+
|`registers.inputRegister`| Object | The pre-defined registers of the register type "Input Registers". |
114
+
115
+
### Pre-define Registers within the configuration file
116
+
117
+
Pre-define registers always starts with the register number. We use a json format as configuration file, so the "key" needs to be a string. So, the register number needs also to be a string. During server initialization, the json key that represents the register number will be converted to an integer.
118
+
119
+
As by the modbus spec, the "Discrete Input" and "Coils" registers contains a single bit. In the json configuration file, we use `true` or `false` as register values.
120
+
121
+
Example configuration of pre-defined registers from type "Discrete Input" or "Coils":
122
+
```
123
+
[..]
124
+
"<register_type>": {
125
+
"0": true,
126
+
"1": true,
127
+
"42": true,
128
+
"166": false
129
+
}
130
+
[..]
131
+
```
75
132
76
-
```json
77
-
{
78
-
"server": {
79
-
"listenerAddress": "0.0.0.0",
80
-
"listenerPort": 5020,
81
-
"tlsParams": {
82
-
"description": "path to certificate and private key to enable tls",
"description": "initial values for the register types",
93
-
"zeroMode": false,
94
-
"initializeUndefinedRegisters": true,
95
-
"discreteInput": {},
96
-
"coils": {},
97
-
"holdingRegister": {
98
-
"123": "0xAABB",
99
-
"246": "0x0101"
100
-
},
101
-
"inputRegister": {}
133
+
As by the modbus spec, the "Holding Registers" and "Input Registers" tables contains a 16-bit word. In the json configuration file, we use a hexadecimal notation, starting with `0x`, as register values.
134
+
135
+
Example configuration of pre-defined registers from type "Holding Registers" or "Input Registers":
0 commit comments