130
7.5.
Modbus Slave examples
Add the following code to
Common functions
1.
-- modbus proxy
2.
mbproxy
=
{
3.
-- supported function list
4.
functions
=
{
5.
'readdo'
,
6.
'readcoils'
,
7.
'readdi'
,
8.
'readdiscreteinputs'
,
9.
'readao'
,
10.
'readregisters'
,
11.
'readai'
,
12.
'readinputregisters'
,
13.
'writebits'
,
14.
'writemultiplebits'
,
15.
'writeregisters'
,
16.
'writemultipleregisters'
,
17.
'reportslaveid'
,
18.
'getcoils'
,
19.
'getdiscreteinputs'
,
20.
'getinputregisters'
,
21.
'getregisters'
,
22.
'setcoils'
,
23.
'setdiscreteinputs'
,
24.
'setinputregisters'
,
25.
'setregisters'
,
26.
}
,
27.
-- new connecton init
28.
new
=
function
()
29.
require
(
'rpc'
)
30.
local
mb
=
setmetatable
({}
,
{
__index
=
mbproxy
})
31.
32.
mb.slaveid
=
0
33.
mb.rpc
=
rpc.client
(
'127.0.0.1'
,
28002
,
'mbproxy'
)
34.
35.
for
_, fn
in
ipairs
(
mbproxy.functions
)
do
36.
mb
[
fn
]
=
function
(
self, ...
)
37.
return
mb:request
(
fn, ...
)
38.
end
39.
end
40.
41.
return
mb
42.
end
43.
}
44.
45.
-- set local slave id
Summary of Contents for LogicMachine3 Re:actor
Page 10: ...10 Terminal connection schemes KNX TP...
Page 12: ...12 24V power supply...
Page 13: ...13 Analog inputs e g reed contact...
Page 14: ...14 Analog inputs 0 10V...
Page 15: ...15 Digital output...
Page 16: ...16 Resistive sensor input...
Page 17: ...17 Analog output...
Page 26: ...26 Make sure that bus status is Online press button in ETS...
Page 35: ...35 o Then minimize side bar by pressing on left arrow icon to make the map more visible...
Page 83: ...83 66 if err then 67 alert FTP upload failed s err 68 end...
Page 107: ...107...
Page 108: ...108 1 14 Help Documentation for scripting syntaxes is displayed in Help tab...
Page 126: ...126 Datapoints can be shown also in a way of table which can be later exported as CSV file...
Page 141: ...141...