133
46.
end
47.
48.
if
type
(
request.params
)
==
'table'
then
49.
table.insert
(
request.params, 1, mb
)
50.
res
=
{
mb
[
fn
](
unpack
(
request.params
))
}
51.
else
52.
res
=
{
mb
[
fn
](
mb
)
}
53.
end
54.
55.
return
res
56.
end
57.
58.
server
=
rpc.server
(
'127.0.0.1'
,
28002
,
'mbproxy'
, handler, 0.01
)
59.
end
60.
61.
mb:handleslave
()
62.
server:step
()
Example: event script which changes modbus slave coil (address 0)
Must be mapped to a group address with binary value.
1.
value
=
event.getvalue
()
2.
mb
=
mbproxy.new
()
3.
mb:setcoils
(
0
, value
)
Example: event script which changes modbus slave register (address 5)
Must be mapped to a group address with scaling (0..100) value
1.
value
=
event.getvalue
()
2.
mb
=
mbproxy.new
()
3.
mb:setregisters
(
5
, value
)
7.6.
Modbus working with several slaves on the same RS485 connection
The example was designed to interconnect with 16 VRF system in one line through 1 Logic
Machine2.
Resident script
-- modbus init
if not mb then
require('luamodbus')
mb = luamodbus.rtu()
mb:open('/dev/ttyS2', 9600, 'E', 8, 1, 'H')
mb:connect()
mb:setslave(1)
-- a/c list
aclist = {
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...