EasyManuals Logo

Embedded Systems LogicMachine5 User Manual

Default Icon
291 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #209 background imageLoading...
Page #209 background image
209
61.
-- request ok
62.
else
63.
-- reply with an error
64.
if res[ 1 ]==nil then
65.
return nil, res[2]
66.
-- normal reply
67.
else
68.
return unpack(res)
69.
end
70.
end
71.
end
Handler (resident script with 0 delay) configuration
1. mb:open()
Open Modbus TCP connection
2. mb:setslave(10)
set slave device id
3. mb:setmapping(10, 10, 10, 10)
set number coils, discrete inputs, holding registers and input registers
4.mb:setwritecoilcb(function(coil, value)...
callback function which is executed for each coil write
5. mb:setwriteregistercb(function(coil, value)...
callback function which is executed for each register write
Handler script example
1.
-- modbus init
2.
if not mb then
3.
require('luamodbus')
4.
mb = luamodbus.tcp()
5.
mb:open()
6.
7.
-- init slave storage for coils, discrete inputs, holding registers and input registers
8.
mb:setmapping(10, 10, 10, 10)
9.
10.
-- coil write callback
11.
mb:setwritecoilcb(function(coil, value)
12.
if coil == 0 then
13.
grp.write('1/1/1', value, dt.bool)
14.
else
15.
alert('coil: %d = %s', coil, tostring(value))

Table of Contents

Other manuals for Embedded Systems LogicMachine5

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Embedded Systems LogicMachine5 and is the answer not in the manual?

Embedded Systems LogicMachine5 Specifications

General IconGeneral
BrandEmbedded Systems
ModelLogicMachine5
CategoryDimmer
LanguageEnglish

Related product manuals