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.

Vigilohm JSON Modbus file
#15
Hi
2. Looks OK, I would contact SE and ask them for function they use to read this value.
3. You already have product identification in register 100 only in numeric format. Product identifier 17032 = IFL12H

If you really need script for this then try this.
Code:
mbproxy = require('mbproxy')
mb = mbproxy.new()
mb:setslave(1)

function readstring(mb, address, length)
  local data = { mb:readregisters(address, length) }
  local bytes = {}

  for _, reg in ipairs(data) do
    if type(reg) == 'number' then
      -- high 8 bits
      local b1 = bit.band(bit.rshift(reg, 8), 0xFF)
      if b1 > 0 then
        bytes[ #bytes + 1 ] = b1
      end

      -- low 8 bits
      local b2 = bit.band(reg, 0xFF)
      if b2 > 0 then
        bytes[ #bytes + 1 ] = b2
      end
    end
  end

  -- convert table of byte values to string
  return string.char(unpack(bytes))
end

result = readstring(mb, 160, 9)
log(result)
------------------------------
Ctrl+F5
Reply


Messages In This Thread
Vigilohm JSON Modbus file - by SigmaTec - 31.03.2020, 16:02
RE: Vigilohm JSON Modbus file - by Daniel - 31.03.2020, 16:06
RE: Vigilohm JSON Modbus file - by SigmaTec - 31.03.2020, 16:15
RE: Vigilohm JSON Modbus file - by SigmaTec - 01.04.2020, 08:15
RE: Vigilohm JSON Modbus file - by Daniel - 01.04.2020, 11:01
RE: Vigilohm JSON Modbus file - by SigmaTec - 01.04.2020, 11:24
RE: Vigilohm JSON Modbus file - by Daniel - 01.04.2020, 11:51
RE: Vigilohm JSON Modbus file - by SigmaTec - 01.04.2020, 12:02
RE: Vigilohm JSON Modbus file - by Daniel - 01.04.2020, 13:17
RE: Vigilohm JSON Modbus file - by SigmaTec - 01.04.2020, 13:43
RE: Vigilohm JSON Modbus file - by Daniel - 01.04.2020, 13:46
RE: Vigilohm JSON Modbus file - by SigmaTec - 01.04.2020, 16:29
RE: Vigilohm JSON Modbus file - by admin - 02.04.2020, 06:14
RE: Vigilohm JSON Modbus file - by SigmaTec - 02.04.2020, 07:09
RE: Vigilohm JSON Modbus file - by Daniel - 02.04.2020, 08:43
RE: Vigilohm JSON Modbus file - by SigmaTec - 02.04.2020, 10:20

Forum Jump: