This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Modbus mappings automation
#3
Hello admin,
thank you for your fast response. This code is part of a larger solution, in which in the first step I add group addresses, in the second I create a modbus device and attach a status object to it, and in the third I map selected points. It's a kind of "wizard" for my customers.


1. Ok, perfect. I changed it to:

Code:
(...)
  if valueBitmask ~= nil then
    sql = string.format(
      "SELECT id FROM modbus_mapping WHERE type='%s' AND address=%d AND value_bitmask='%s'",
      regType, regNum, valueBitmask
    )
  else
    sql = string.format(
      "SELECT id FROM modbus_mapping WHERE type='%s' AND address=%d",
      regType, regNum
    )
  end
(...)
local rows = db:getall(sql)
and it works smootly.

2. In fact I tried it as a hex. Now I have conversions, so both versions are OK Wink

3. I know, it was temporary. It's a kind of note that shows me where changes in the database have been saved and where they haven't.

4. Unfortunately I know. For now 1 device is enough, but in the future I'l have to rebuild the code to support more modbus devices. I assume I'll use the device column somehow.

Lastly...
5. Is there any simple way to clear modbus_mapping table? Smile I have some rubbish left there.
6. As I can see modbus doesn't start on its own. For now my solution was to automatically reboot it, but maybe there is other way?
Reply


Messages In This Thread
Modbus mappings automation - by pawel200388 - 21.07.2025, 09:54
RE: Modbus mappings automation - by admin - 21.07.2025, 10:04
RE: Modbus mappings automation - by pawel200388 - 21.07.2025, 12:46
RE: Modbus mappings automation - by admin - 21.07.2025, 12:54

Forum Jump: