147
2.
ifnot
modem
then
3.
-- allowed numbers, SMS message from other number will be ignored
4.
numbers
={
'1234567890'
,
'0123456789'
}
5.
-- replace 0000 with SIM pin number, or remove the line below if PIN check is disabled
6.
pincode
=
'0000'
7.
-- modem communication port, ttyUSB2 for Huawei E173
8.
comport
=
'ttyUSB2'
9.
-- open serial port
10.
modem
=
AT:init
(
'/dev/'
.. comport
)
11.
-- command parser
12.
parser
=
function
(
cmd, sender
)
13.
local
find, pos, name, mode, offset, value, jvalue, obj
14.
cmd
=
cmd:trim
()
15.
mode
=
cmd:sub
(
1, 1
)
:upper
()
16.
if
mode
==
'W'
or
mode
==
'R'
then
17.
cmd
=
cmd:sub
(
3
)
:trim
()
18.
-- parse object name/address
19.
find
=
cmd:sub
(
1
,
1
)==
'"'
and
'"'
or
' '
20.
offset
=
find
==
'"'
and
1
or
0
21.
-- pad with space when in read mode
22.
if
mode
==
'R'
and
find
==
' '
then
23.
cmd
=
cmd ..
' '
24.
end
25.
-- find name
26.
pos
=
cmd:find
(
find, 1 + offset,
true
)
27.
-- name end not found, stop
28.
ifnot
pos
then
29.
returnfalse
30.
end
31.
-- get name part
32.
name
=
cmd:sub
(
1 + offset, pos - offset
)
:trim
()
33.
if
mode
==
'W'
then
34.
value
=
cmd:sub
(
pos + offset
)
:trim
()
35.
ifnot
value
then
36.
returnfalse
37.
end
38.
-- try decoding value
39.
jvalue
=
json.pdecode
(
value
)
40.
value
=
jvalue ~
=
niland
jvalue
or
value
41.
-- send to bus
42.
grp.
write
(
name, value
)
43.
-- read request
44.
else
45.
obj
=
grp.find
(
name
)
46.
-- send read request and wait for update
47.
if
obj
then
48.
obj:
read
()
49.
os
.sleep
(
1
)
50.
-- read new value
51.
value
=
grp.getvalue
(
name
)
Содержание 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...