1restmbmaster(8)             Rest API Modbus master             restmbmaster(8)
2
3
4

NAME

6       restmbmaster — Rest API gateway to Modbus slaves
7

SYNOPSIS

9       restmbmaster -c CONNECT_URI -p PORT
10       restmbmaster -f FILE
11       restmbmaster -h|-v
12

DESCRIPTION

14       restmbmaster  is  a  simple  daemon  that  allows user to access Modbus
15       slaves over Rest API. The slaves could be either connected over  serial
16       line (Modbus RTU protocol), or over TCP (Modbus TCP protocol).
17

OPTIONS

19       -h, --help
20              Print help text to console and exit.
21
22       -v, --version
23              Print version information to console and exit.
24
25       -g, --debug
26              Turns on debugging messages. Repeating the option increases ver‐
27              bosity.
28
29       -c CONNECT_URI, --connect CONNECT_URI
30              Specifies the target Modbus bus to connect  to.  Supported  for‐
31              mats:
32
33              tcp://HOSTNAME[:PORT]
34
35                     Example: tcp://test.abc:1000
36
37                     Default PORT: 502
38
39              rtu:DEVICEPATH[?baud=BAUDRATE]
40
41                     Example: rtu:/dev/ttyS0?baud=9600
42
43                     Default BAUDRATE: 115200
44
45       -p PORT, --port PORT
46              Specifies TCP port on which the webserver is listening and where
47              the Rest API is exposed.
48
49       -K, --dontkeep
50              Don't keep the connection open, connect only for the  time  when
51              command is processed.
52
53       -f FILE, --config FILE
54              Load the specified configuration file.
55

REST API

57       The  API  is  quite simple. Only "GET" (read) and "PUT" (write) methods
58       are supported. The "Content-Type" is always "text/plain" for both "GET"
59       and "PUT". The path in the URL has following format:
60
61       http://HOSTNAME:PORT/slaves/SLAVE_ADDRESS/OBJECT_FAMILY/OBJECT_AD‐
62       DRESS[?count=OBJECT_COUNT]
63
64              SLAVE_ADDRESS — Address of the slave to communitate with, number
65              in range from 0 to 255.
66
67              OBJECT_FAMILY  —  Is  a string to identify the family of the ob‐
68              jects. It is one of:
69
70                     coils — To access coils (RW).
71
72                     discrete-inputs — To access discrete inputs (RO).
73
74                     input-registers — To access input registers (RO).
75
76                     holding-registers — To access holding registers (RW).
77
78              OBJECT_ADDRESS — Address of the object according to the  family.
79              It is an integer number, starting from 0.
80
81              OBJECT_COUNT  —  Number of objects to read or write, starting at
82              OBJECT_ADDRESS. It is an integer number, starting from 0. If not
83              specified, defaults to 1.
84
85       The  content being returned by "GET" method is a value of the object as
86       a plain integer number in the text. If values of multiple  objects  are
87       requested,  they  are  separated by a single space. Same format applies
88       for the "PUT" method.
89

EXAMPLES

91       To run connecting to Modbus TCP:
92
93       $ restmbmaster -c tcp://test.abc:1000 -p 8080
94
95       To run connecting to Modbus RTU:
96
97       $ restmbmaster -c rtu:/dev/ttyS0?baud=9600 -p 8080
98
99       To run according to the configuration from file:
100
101       $ restmbmaster -f myconfig.conf
102
103       When restmbmaster is running, one can use for example curl to communicate with Modbus slaves.
104       In the following example, slave with address 55 is queried for the value of input register with address 10:
105
106       $ curl http://127.0.0.1:8080/slaves/55/input-registers/10
107       34
108
109       It is possible to query multiple registers (in sequence) at once:
110
111       $ curl http://127.0.0.1:8080/slaves/55/input-registers/10?count=4
112       34 78 234 2
113
114       To write new value (434) to holding register 20 the "PUT" method has to
115       be used:
116
117       $ curl http://127.0.0.1:8080/slaves/55/holding-registers/20 -d "434" -H "Content-Type: text/plain" -X PUT
118
119       It is also possible to write to a sequence of registers (20-26):
120
121       $ curl http://127.0.0.1:8080/slaves/55/holding-registers/20 -d "434 48 32 92 1 0 3" -H "Content-Type: text/plain" -X PUT
122

SEE ALSO

124       restmbmaster.conf(5),
125

AUTHOR

127       Jiri  Pirko is the original author and current maintainer of restmbmas‐
128       ter.
129
130
131
132restmbmaster                   26 December 2019                restmbmaster(8)
Impressum