Hi!
I have a script for reading Mbus, i works for å while then the LM is "stuck".
When it happen i cant log into it. If i take the power off, it works fine after that.
Then it works for somewhile and then the same thing happens.
I tried to deactivate the script for some days, and then the LM works fine.
I am using Tecbase Mbus 10 RS-232 Mbus gateway.
its a Sheduled script that runs every day at 07.30.
Is there something wrong in my script?
Is there someway to close the Mbus reading, so it only reads Mbus when the script runs?
Someone who has had the same experiance?
Here is my script:
-------------------------------Step 1: LM script (search for Mbus ID):
--[[
-- load mbus library
require('mbus')
-- use /dev/ttyUSB0 serial port with 2400 baud rate
mbus.init('/dev/RS232', 2400)
-- scan from range 0 to 5 (inclusive)
res = mbus.scan(0, 100)
-- save result to Logs tab
log(res)
]]--
--------------------------------Step 2: LM script (read values):(Deactivate step 1 before going to step 2)
--load mbus library
require('mbus')
-- use /dev/ttyUSB0 serial port with 2400 baud rate
mbus.init('/dev/RS232', 2400)
-- new address to write
addr = 71
-- read all data
res, err = mbus.getdata(addr)
-- read ok
if res then
--log(res)----------------reading all the Mbus data, sort afterwards the values you want
--log(res.data[0].value)
value1 = res.data[1].value
value2 = res.data[4].value
value3 = res.data[5].value
value10 = value1:sub(1, -3) -------remove decimal
value20 = value2:sub(1, -3) -------remove decimal
value30 = value3:sub(1, -3) -------remove decimal
num1 = tonumber(value10)
num2 = tonumber(value20)
num3 = tonumber(value30)
log(num1)
grp.update('32/1/19', num1)----write value to grp.
grp.update('32/1/20', num2)----write value to grp.
grp.update('32/1/21', num3)----write value to grp.
-- read failed
else
alert('[mbus] failed to read data from short address ' .. addr .. ' ' .. tostring(err))
end
I have a script for reading Mbus, i works for å while then the LM is "stuck".
When it happen i cant log into it. If i take the power off, it works fine after that.
Then it works for somewhile and then the same thing happens.
I tried to deactivate the script for some days, and then the LM works fine.
I am using Tecbase Mbus 10 RS-232 Mbus gateway.
its a Sheduled script that runs every day at 07.30.
Is there something wrong in my script?
Is there someway to close the Mbus reading, so it only reads Mbus when the script runs?
Someone who has had the same experiance?
Here is my script:
-------------------------------Step 1: LM script (search for Mbus ID):
--[[
-- load mbus library
require('mbus')
-- use /dev/ttyUSB0 serial port with 2400 baud rate
mbus.init('/dev/RS232', 2400)
-- scan from range 0 to 5 (inclusive)
res = mbus.scan(0, 100)
-- save result to Logs tab
log(res)
]]--
--------------------------------Step 2: LM script (read values):(Deactivate step 1 before going to step 2)
--load mbus library
require('mbus')
-- use /dev/ttyUSB0 serial port with 2400 baud rate
mbus.init('/dev/RS232', 2400)
-- new address to write
addr = 71
-- read all data
res, err = mbus.getdata(addr)
-- read ok
if res then
--log(res)----------------reading all the Mbus data, sort afterwards the values you want
--log(res.data[0].value)
value1 = res.data[1].value
value2 = res.data[4].value
value3 = res.data[5].value
value10 = value1:sub(1, -3) -------remove decimal
value20 = value2:sub(1, -3) -------remove decimal
value30 = value3:sub(1, -3) -------remove decimal
num1 = tonumber(value10)
num2 = tonumber(value20)
num3 = tonumber(value30)
log(num1)
grp.update('32/1/19', num1)----write value to grp.
grp.update('32/1/20', num2)----write value to grp.
grp.update('32/1/21', num3)----write value to grp.
-- read failed
else
alert('[mbus] failed to read data from short address ' .. addr .. ' ' .. tostring(err))
end