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.

Error during export objectlogs
#1
I am logging several values in the objectlogs tab. When I try to export them I get the following error in a new safari-tab:
Error: /lib/genohm-scada/web/objectlogs/csv.lua:10: unexpected symbol near '='
Any ideas how to resolve this?
Thanks, Bart
Reply
#2
Hi Bart,

Not sure, but it looks like you are using special sign in you object names and that might cause a error in the CSV notation.. are you using ' or '' signs or , in your object names?

BR,

Erwin
Reply
#3
It's a bug in the FW, we will fix it in the next release.
Reply
#4
(11.03.2017, 22:51)Erwin van der Zwart Wrote: Hi Bart,

Not sure, but it looks like you are using special sign in you object names and that might cause a error in the CSV notation.. are you using ' or '' signs or , in your object names?

BR,

Erwin

Hi Erwin,
Only minus-sign nothing else.
I have attached a screendump.
Mvg, Bart

Attached Files Thumbnail(s)
   
Reply
#5
(12.03.2017, 10:22)admin Wrote: It's a bug in the FW, we will fix it in the next release.

Hi Admin,
Any ideas how to get a logfile (csv) for a set of grpadresses?
I would need a 2 day logging of the weatherstation since it is giving wrong values (it is currently more than 50 degrees C in Belgium according to the station Smile ) - need to send it to the supplier.
Best regards,
Bart
Reply
#6
Hi Bart,

This script creates a csv of the object logs on your ftp folder:

Code:
-- get past year data
logtime = os.time() - 60 * 60 * 24 * 365

-- list of objects by id
objects = {}

-- objects with logging enabled
query = 'SELECT address, datatype, name FROM objects WHERE disablelog=0'
for _, object in ipairs(db:getall(query)) do
 objects[ tonumber(object.address) ] = {
   datatype = tonumber(object.datatype),
   name = tostring(object.name or ''),
 }
end

-- csv buffer
buffer = { '"date","address","name","value"' }

-- get object logs
query = 'SELECT src, address, datahex, logtime, eventtype FROM objectlog WHERE logtime >= ? ORDER BY id DESC'
for _, row in ipairs(db:getall(query, logtime)) do
 object = objects[ tonumber(row.address) ]

 -- found matching object and event type is group write
 if object and row.eventtype == 'write' then
   datatype = object.datatype

   -- check that object datatype is set
   if datatype then
     -- decode data
     data = knxdatatype.decode(row.datahex, datatype)

     -- remove null chars from char/string datatype
     if datatype == dt.char or datatype == dt.string then
       data = data:gsub('%z+', '')
     -- date to DD.MM.YYYY
     elseif datatype == dt.date then
       data = string.format('%.2d.%.2d.%.2d', data.day, data.month, data.year)
     -- time to HH:MM:SS
     elseif datatype == dt.time then
       data = string.format('%.2d:%.2d:%.2d', data.hour, data.minute, data.second)
     end
   else
     data = ''
   end

   -- format csv row
   logdate = os.date('%Y.%m.%d %H:%M:%S', row.logtime)
   csv = string.format('%q,%q,%q,%q', logdate, knxlib.decodega(row.address), object.name, tostring(data))

   -- add to buffer
   table.insert(buffer, csv)
 end
end

dst = '/home/ftp/logs.csv'
io.writefile(dst, table.concat(buffer, '\r\n'))

BR,

Erwin
Reply
#7
(13.03.2017, 22:46)Erwin van der Zwart Wrote: Hi Bart,

This script creates a csv of the object logs on your ftp folder:

Code:
-- get past year data
logtime = os.time() - 60 * 60 * 24 * 365

-- list of objects by id
objects = {}

-- objects with logging enabled
query = 'SELECT address, datatype, name FROM objects WHERE disablelog=0'
for _, object in ipairs(db:getall(query)) do
 objects[ tonumber(object.address) ] = {
   datatype = tonumber(object.datatype),
   name = tostring(object.name or ''),
 }
end

-- csv buffer
buffer = { '"date","address","name","value"' }

-- get object logs
query = 'SELECT src, address, datahex, logtime, eventtype FROM objectlog WHERE logtime >= ? ORDER BY id DESC'
for _, row in ipairs(db:getall(query, logtime)) do
 object = objects[ tonumber(row.address) ]

 -- found matching object and event type is group write
 if object and row.eventtype == 'write' then
   datatype = object.datatype

   -- check that object datatype is set
   if datatype then
     -- decode data
     data = knxdatatype.decode(row.datahex, datatype)

     -- remove null chars from char/string datatype
     if datatype == dt.char or datatype == dt.string then
       data = data:gsub('%z+', '')
     -- date to DD.MM.YYYY
     elseif datatype == dt.date then
       data = string.format('%.2d.%.2d.%.2d', data.day, data.month, data.year)
     -- time to HH:MM:SS
     elseif datatype == dt.time then
       data = string.format('%.2d:%.2d:%.2d', data.hour, data.minute, data.second)
     end
   else
     data = ''
   end

   -- format csv row
   logdate = os.date('%Y.%m.%d %H:%M:%S', row.logtime)
   csv = string.format('%q,%q,%q,%q', logdate, knxlib.decodega(row.address), object.name, tostring(data))

   -- add to buffer
   table.insert(buffer, csv)
 end
end

dst = '/home/ftp/logs.csv'
io.writefile(dst, table.concat(buffer, '\r\n'))

BR,

Erwin

Thanks Erwin!
Reply
#8
This only work if I have objects, and if objects are mark as log.

If I want to get all traffic in knx without mark the log field, because there is some knx device that i have not control over it, and it send me each time some unknown data, that I have not in the object table.

I just want to send all trafic on KNX bus each 1 hour, even if I have not objects created in my LM5. Could it be posible???
Reply
#9
Hi,

You could try to enable auto object creation in the general settings and set the log policy to all objects.

This way there will be a object created when the telegram holds a valid KNX structure and the logging will be activated already because you log all objects including the new ones..

BR,

Erwin
Reply


Forum Jump: