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.

KNX 19.001 datatype
#1
Hi
I`m trying to write time and date to a group adress with datatype 19.001. Have been looking in the example: http://openrb.com/example-write-lm2-data...addresses/
but can`t really see there how I`m supposed to Write the actually value to the Group adress. (I`m really new at this Undecided )

Can you help me?

-Kristian
Reply
#2
(19.04.2019, 19:58)KristianSl Wrote: Hi
I`m trying to write time and date to a group adress with datatype 19.001. Have been looking in the example: http://openrb.com/example-write-lm2-data...addresses/
but can`t really see there how I`m supposed to Write the actually value to the Group adress. (I`m really new at this Undecided )

Can you help me?

-Kristian

Use the code below and modify as needed

Code:
-- 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

-- 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('Date', date, dt.date)
grp.write('Time', time, dt.time)
grp.write('DateTime', date_time)
Reply
#3
(19.04.2019, 21:36)gtsamis Wrote:
(19.04.2019, 19:58)KristianSl Wrote: Hi
I`m trying to write time and date to a group adress with datatype 19.001. Have been looking in the example: http://openrb.com/example-write-lm2-data...addresses/
but can`t really see there how I`m supposed to Write the actually value to the Group adress. (I`m really new at this Undecided )

Can you help me?

-Kristian

Use the code below and modify as needed

Code:
-- 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

-- 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('Date', date, dt.date)
grp.write('Time', time, dt.time)
grp.write('DateTime', date_time)

Smile thanks
Reply
#4
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
Reply
#5
Hi
I used your script without the function and it works.

Code:
  -- 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('date test2', date_time)

Attached Files Thumbnail(s)
   
------------------------------
Ctrl+F5
Reply
#6
Can it be a problem because my language-settings Swedish?
Reply
#7
Try specifying datatype explicitly:
grp.write(obj, date_time, dt.string)
Reply
#8
(19.12.2019, 14:55)admin Wrote: Try specifying datatype explicitly:
grp.write(obj, date_time, dt.string)

When I specify with dt.string, the result been type of
16.001 Character String (ISO 8859-1)

And nothing saves/writes into '2/0/0'

Log:

Loggad vid 19.12.2019 16:18:04
* arg: 1
  * number: 119
* arg: 2
  * number: 12
* arg: 3
  * number: 19
* arg: 4
  * number: 144
* arg: 5
  * number: 18
* arg: 6
  * number: 4
* arg: 7
  * number: 0
* arg: 8
  * number: 0


 

Reply
#9
Hi,

You should use the 250 byte object for this..

BR,

Erwin
Reply
#10
(19.12.2019, 15:34)Erwin van der Zwart Wrote: Hi,

You should use the 250 byte object for this..

BR,

Erwin


Yes, but how?

BR Alex
Reply
#11
(19.12.2019, 15:50)zuuper Wrote:
(19.12.2019, 15:34)Erwin van der Zwart Wrote: Hi,

You should use the 250 byte object for this..

BR,

Erwin


Yes, but how?

BR Alex
The object you writing to must be 250 byte string.  The real values you will see only in ETS group monitor
------------------------------
Ctrl+F5
Reply
#12
(19.12.2019, 15:53)Daniel. Wrote:
(19.12.2019, 15:50)zuuper Wrote:
(19.12.2019, 15:34)Erwin van der Zwart Wrote: Hi,

You should use the 250 byte object for this..

BR,

Erwin


Yes, but how?

BR Alex
The object you writing to must be 250 byte string.  The real values you will see only in ETS group monitor


I trying to write to this:

Attached Files Thumbnail(s)
   
Reply
#13
Like this, with script I posted

Attached Files Thumbnail(s)
           
------------------------------
Ctrl+F5
Reply
#14
(19.12.2019, 16:09)Daniel. Wrote: Like this, with script I posted


Thank you SmileSmile
Now its works Smile
Reply


Forum Jump: