Posts: 8
Threads: 4
Joined: Jan 2016
Reputation:
0
Hi,
I need a resident script that ping an IP , and if does not receive any reply to open a actuator.
Please help
Thanks a lot!
Posts: 940
Threads: 161
Joined: Jul 2015
Reputation:
33
(09.10.2017, 14:06)sorin Wrote: Hi,
I need a resident script that ping an IP , and if does not receive any reply to open a actuator.
Please help
Thanks a lot!
Here you are:
Code: function socketping(ip, port, timeout)
port = port or 80
local sock = require('socket').tcp()
sock:settimeout(timeout or 2)
local res, err = sock:connect(ip, port)
sock:close()
return res, err
end
ip = '192.168.2.1'
if not socketping(ip) then grp.write('1/2/3', true) end
Posts: 8
Threads: 4
Joined: Jan 2016
Reputation:
0
Thanks for quick reply.
I'll check and come back with a feedback.
Posts: 20
Threads: 5
Joined: Feb 2017
Reputation:
1
Hi
I have tried using this script to ping an Iphone but I always get back the same result regardless of it's presence in the network or not. The Iphone have a static IP.
Any ideas?
/K
Posts: 8
Threads: 4
Joined: Jan 2016
Reputation:
0
(17.12.2017, 08:08)kenjirosama Wrote: Hi
I have tried using this script to ping an Iphone but I always get back the same result regardless of it's presence in the network or not. The Iphone have a static IP.
Any ideas?
/K
Hi, The script is good, working.
Here mine looks:
Code: function socketping(ip, port, timeout)
port = 80
local sock = require('socket').tcp()
sock:settimeout(2)
local res, err = sock:connect(ip, port)
sock:close()
return res, err
end
ip1 = '192.168.10.151'
ip2 = '192.168.10.152'
ip3 = '192.168.10.153'
ip4 = '192.168.10.154'
ip5 = '192.168.10.155'
ip6 = '192.168.10.156'
ip7 = '192.168.10.157'
if not socketping(ip1) then grp.write('10/5/1', true)
end
if not socketping(ip2) then grp.write('10/5/2', true)
end
if not socketping(ip3) then grp.write('10/5/3', true)
end
if not socketping(ip4) then grp.write('10/5/4', true)
end
if not socketping(ip5) then grp.write('10/5/5', true)
end
if not socketping(ip6) then grp.write('10/5/6', true)
end
if not socketping(ip7) then grp.write('10/5/7', true)
end
I have an IPAD an I have tried to ping from windows. If it is looked, doesn't reply to ping, if I unlocked start to reply.
Maybe it is a issue of replying to ping of the Iphone.
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
Hi,
This will never work as the iOS device is not reachable when lock is enabled, also for power saving the wifi is not always available.
There is a script from admin on this forum that seeks the iOS devices by multiple trigger on a port, but this script is also facing issues with unreachable state of iOS devices.
Maybe IFTTT with geofencing can give you more trustfull input for your task..
BR,
Erwin
Posts: 400
Threads: 88
Joined: Jul 2016
Reputation:
3
Hi,
I use LM as supervisor for a Wago PLC in modbus TCP-IP.
I would like to establish a modbus watchdog connection as security. From LM side what do you suggest?
Thanks
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
You can use socketping function but with port set to 502 (default ModBus TCP port):
Code: function socketping(ip, port, timeout)
port = port or 80
local sock = require('socket').tcp()
sock:settimeout(timeout or 2)
local res, err = sock:connect(ip, port)
sock:close()
return res, err
end
ip = '192.168.10.150'
if not socketping(ip, 502) then
alert('device is offline')
end
Posts: 176
Threads: 42
Joined: Jul 2015
Reputation:
2
Hi. Nice feature. Works perfect as always.
Is it possible to make the same watchdog for RTU modbus connection?
Posts: 4638
Threads: 24
Joined: Aug 2017
Reputation:
207
It can also be checked like this
Code: function checkrtu(slave)
local res = db:getone('SELECT active FROM modbus_devices WHERE proto="rtu" AND slave=?', slave)
return toboolean(res)
end
function checktcp(ip, port)
local settings, res settings = tostring(ip) .. ':' .. tostring(port) res = db:getone('SELECT active FROM modbus_devices WHERE proto="tcp" AND settings=?', settings)
return toboolean(res)
end
------------------------------
Ctrl+F5
Posts: 176
Threads: 42
Joined: Jul 2015
Reputation:
2
07.11.2019, 18:56
(This post was last modified: 08.11.2019, 06:47 by PassivPluss.)
I have two json modbus profiles on a LM5 lite. One rtu 9600 baud and one tcp. Tcp working great but rtu sometimes failing. (Red in modbus window)
I am using pts cable. About 30 meters.
Has the LM built in eol resistors?
Will try to put in this tommorow and not sure if i have to have in both ends.
Does the new rc of firmware have improvements in modbus rtu?
And the scripts above to check TCP and RTU status. Can they make the RTU connection go bad.
Posts: 4638
Threads: 24
Joined: Aug 2017
Reputation:
207
My script is just checking internal LM state of connection, when it becomes red. Do you have any errors in modbus tab?
GND connected?
------------------------------
Ctrl+F5
Posts: 176
Threads: 42
Joined: Jul 2015
Reputation:
2
08.11.2019, 09:24
(This post was last modified: 08.11.2019, 09:27 by PassivPluss.)
Yes. I have error/red color in modbus tab from time to tine. But not sure why. I think it is better when the script is not running but only had a day to test.
Gnd connected. But slow connection with modbus40 from nibe. 3 sek read delay and 3 sek timeout in script
Should I have a resistor at the eol with the equipment and by the LM? Or just in end?
I can see that the error reason is operation timed out and there have been no change when disabling script.
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
Do you have a script running together with the mapper sharing the same RS485 port? This will cause a lot of errors. If you want to use script then you should switch to modbus proxy: https://forum.logicmachine.net/showthrea...53#pid1953
Which LM model do you have? Some of them have EOL on-board though it's higher than 120ohm. EOL should be placed on both line ends.
Posts: 176
Threads: 42
Joined: Jul 2015
Reputation:
2
08.11.2019, 09:45
(This post was last modified: 08.11.2019, 10:04 by PassivPluss.)
Lm5 lite
No script. I had the ip ping from the posts on this page pinging ip modbut earlier but no difference in disabling it
Lm5Lp2
Should i use resistors in both ends or just at the slave?
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
LM5 don't have EOL resistors, so you need to put 120ohm at both ends of your RS485 line. Do you have GND connected between LM and slave device?
Posts: 176
Threads: 42
Joined: Jul 2015
Reputation:
2
Ok. Then I will connect the 150 ohm resistors at both ends.
The gnd is connected at both ends. To increase mm2 i doubled the pair. Is this ok? I thought it didnt go any data on this? Or can that make problem?
|