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.

Saving a date
#1
Hi all,

what is the best way of saving a date within the LM? Saving it in a group address?

I could check this myself tonight, but will ask this now anyway: Is the required data type 11.001 and/or 19.001 (date with time) available in the LM3?

Best regards,
Robin
Reply
#2
Depends on your task, you can use group address (both date and time types are supported) or save to storage (you can save either a formatted string or Lua table).

This example might be useful:
http://openrb.com/example-write-lm2-data...addresses/
Reply
#3
Perfect, thank you. Will use group address as in your example.
Reply
#4
(03.09.2015, 09:11)admin Wrote: Depends on your task, you can use group address (both date and time types are supported) or save to storage (you can save either a formatted string or Lua table).

This example might be useful:
http://openrb.com/example-write-lm2-data...addresses/

Can you please provide the grp.write function for DPT 19.001 to use with the above script
Reply
#5
Hi,

DPT 19 is not available in the controller, only way to do it is to use the 250 byte object (raw dpt) and build the telegram yourself.

You can try this sample, it's not 100% filled according the standard but for time and date it should work, if you want it 100% correct you need to complete OCT2 and OCT1
Code:
now = os.date('*t')
wday = now.wday == 1 and 7 or now.wday - 1
OCT08 = now.year - 1900 
OCT07 = now.month
OCT06 = now.day
OCT05 = bit.bor(bit.lshift(wday, 5), now.hour)
OCT04 = now.min
OCT03 = now.sec
OCT02 = 0 -- subfields like working day and dst not specified in this sample
OCT01 = 0 -- subfields like quality of clock not specified in this sample

knx_raw_dpt = string.char(OCT08) .. string.char(OCT07) .. string.char(OCT06) .. string.char(OCT05) .. string.char(OCT04) .. string.char(OCT03)  .. string.char(OCT02)  .. string.char(OCT01)
grp.write('1/1/1', knx_raw_dpt)
BR,

Erwin
Reply
#6
You should use bit operations Smile
Code:
OCT05 = bit.bor(bit.lshift(now.wday, 5), now.hour)
Reply
#7
(12.06.2018, 07:08)admin Wrote: You should use bit operations Smile
Code:
OCT05 = bit.bor(bit.lshift(now.wday, 5), now.hour)

I was looking for this but could not figure it out so soon, the solution with functions works but your solution is cleaner (:

I updated the sample

Thanks!

BR,

Erwin
Reply


Forum Jump: