128
description on error
mb:reportslaveid()
Reads slave internal data. Returns values on success and nil, error description on error.
7.2.
Visualizing Modbus objects
Use
grp.write
to assign Modbus object to KNX object and then use this new KNX object in the
visualization.
7.3.
Usage example (Modbus TCP)
Task: read three registers from Modbus TCP device and write the result in Alerts.
1.
-- initmodbus on first script execution
2.
ifnot
mb
then
3.
require
(
'luamodbus'
)
4.
mb
=
luamodbus.tcp
()
5.
end
6.
7.
-- prepare connection to given ip and port
8.
mb:open
(
'192.168.1.100'
,
1502
)
9.
10.
-- open connection and check the result
11.
if
mb:connect
()
then
12.
-- read 3 input registers, function returns 3 variables
13.
local
x, y, z
=
mb:readinputregisters
(
1
,
3
)
14.
15.
-- first variable will be nill if read failed
16.
if
x
then
17.
local
message
=
string.format
(
'1: %d; 2: %d; 3: %d'
, x, y, z
)
18.
alert
(
message
)
19.
end
20.
21.
-- end session
22.
mb:close
()
23.
else
24.
alert
(
'connection failed'
)
25.
end
Содержание LogicMachine3 Re:actor
Страница 10: ...10 Terminal connection schemes KNX TP...
Страница 12: ...12 24V power supply...
Страница 13: ...13 Analog inputs e g reed contact...
Страница 14: ...14 Analog inputs 0 10V...
Страница 15: ...15 Digital output...
Страница 16: ...16 Resistive sensor input...
Страница 17: ...17 Analog output...
Страница 26: ...26 Make sure that bus status is Online press button in ETS...
Страница 35: ...35 o Then minimize side bar by pressing on left arrow icon to make the map more visible...
Страница 83: ...83 66 if err then 67 alert FTP upload failed s err 68 end...
Страница 107: ...107...
Страница 108: ...108 1 14 Help Documentation for scripting syntaxes is displayed in Help tab...
Страница 122: ...122 4 16 Running processes System running processes can be seen in Status Running processes window...
Страница 126: ...126 Datapoints can be shown also in a way of table which can be later exported as CSV file...
Страница 141: ...141...