Logic Machine Forum
Modbus TCP/IP slaves and unique Widgets association in visualization or mosaic - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Visualization (https://forum.logicmachine.net/forumdisplay.php?fid=9)
+--- Thread: Modbus TCP/IP slaves and unique Widgets association in visualization or mosaic (/showthread.php?tid=1987)



Modbus TCP/IP slaves and unique Widgets association in visualization or mosaic - CHOUAIBOU - 24.03.2019

Hi,
I would like to make a link between each modbus TCP slave and a unique page or widget of my visualization (one widget per modbus TCP slave). Please is it possible to get slave's IP address  or mac address automatically (by script/.lp file ?) and make the assocation with a unique page or widget ? If yes, how can it be done ? 

I was thinking to the mosaic as i could use a device with embeded webpage and replace its optional remote display interface with my LM's for modbus TCP/IP communication, display user interface menus from webpages and settings features. Any idea for feasibility ?

Many thanks in advance.

B.R,
Chouaibou.


RE: Modbus TCP/IP slaves and unique Widgets association in visualization or mosaic - admin - 25.03.2019

What kind of widget do you need? Do you want the end user to be able to set mapping or only display current object values?


RE: Modbus TCP/IP slaves and unique Widgets association in visualization or mosaic - admin - 26.03.2019

Displaying values only is not too hard to implement by .lp. You just need a couple of db queries: one for a list of modbus devices and second one to get mapped object values.

If you want to allow users to modify mapping then you basically need to write it from scratch, at least the UI part.


RE: Modbus TCP/IP slaves and unique Widgets association in visualization or mosaic - admin - 28.03.2019

DB functions are documented here: http://openrb.com/docs/db.htm

As for DB structure you can extract db file from the backup and use any SQLite tool to examine the database contents.


RE: Modbus TCP/IP slaves and unique Widgets association in visualization or mosaic - admin - 29.03.2019

You are missing function return value assignment to a variable. And the modbus TCP connect part seems wrong there.

Code:
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

--Test the DB info of the modbus TCP
res = checktcp('192.168.0.10','502')
log(res)



RE: Modbus TCP/IP slaves and unique Widgets association in visualization or mosaic - admin - 30.03.2019

If you don't have a profile assigned then querying the database won't do anything because the device is not there. The same thing goes for devices with no object mapping - connection is established only when at least one object is mapped.

Random client port is how TCP client-server works in general - server has a pre-defined port, clients use a random port. As for TCP states you can read about them here: https://benohead.com/tcp-about-fin_wait_2-time_wait-and-close_wait/

local port 4304 is used by 1-wire server.