ello,
It doesn't work for me when I have to write down a datetime (DPT 19.001).
I only get the result:
RawDpValue
00 00 00 00 00 00 00 00
Can anyone try to help me please?
My code is,
function setDateTime(obj)
-- get current data as table
now = os.date('*t')
-- system week day starts from sunday, convert it to knx format
wday = now.wday == 1 and 7 or now.wday - 1
-- time table
time = {
day = wday,
hour = now.hour,
minute = now.min,
second = now.sec,
}
-- date table
date = {
day = now.day,
month = now.month,
year = now.year,
}
--- full date bits
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
log (OCT08,OCT07,OCT06,OCT05,OCT04,OCT03,OCT02,OCT01)
-- write to bus
date_time = 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(obj, date_time)
end
It doesn't work for me when I have to write down a datetime (DPT 19.001).
I only get the result:
RawDpValue
00 00 00 00 00 00 00 00
Can anyone try to help me please?
My code is,
function setDateTime(obj)
-- get current data as table
now = os.date('*t')
-- system week day starts from sunday, convert it to knx format
wday = now.wday == 1 and 7 or now.wday - 1
-- time table
time = {
day = wday,
hour = now.hour,
minute = now.min,
second = now.sec,
}
-- date table
date = {
day = now.day,
month = now.month,
year = now.year,
}
--- full date bits
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
log (OCT08,OCT07,OCT06,OCT05,OCT04,OCT03,OCT02,OCT01)
-- write to bus
date_time = 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(obj, date_time)
end