ZUNO2 system Handler(s)

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
yves
Posts: 52
Joined: 17 Sep 2021 18:05

ZUNO2 system Handler(s)

Post by yves »

Hi,
I found another one, Maybe it is already in your //TODO list...

I am unable to attach an handler to CFGParam. ZUNO_SETUP_CFGPARAMETER_HANDLER() does not seem to work.
(Param are effectively changed, you see it after reboot but my config_parameter_changed() is never called.

Previously today I use also ZUNO_SETUP_SYSEVENT_HANDLER(sys_event); to detect potential bugs in my code and I was happy/proud to detect none. Now I am not so sure ….

One point: if you modify the defines (one at a time) in ZUNO_StaticData.h to add a bug:

Code: Select all

Line 129:#define ZUNO_SETUP_CFGPARAMETER_HANDLER(H) \
      GENERIC_POINTER ___zunoCFGHandler = DUMMY ((void*)H)
OR
Line192:#define ZUNO_SETUP_CFGPARAMETER_HANDLER(H) DUMMY
The bug in the first definition does not prevent compilation but in line 192 it does!

Thanks for your work!
p0lyg0n1
Posts: 242
Joined: 04 Aug 2016 07:14

Re: ZUNO2 system Handler(s)

Post by p0lyg0n1 »

Hi,
It is not necessary to change this header, it is used by our preprocessor. How exactly the preprocessor converts the data can be seen in the build directory zunopreproc/ZUNO_AutoSetup.c. The handler specified by ZUNO_SETUP_CFGPARAMETER_HANDLER will work ONLY with static channel creation. When dynamically setting channels, use zunoAttachSysHandle.

Here are 2 examples.
1. Static definition:

Code: Select all

ZUNO_ENABLE(LOGGING_DBG);
ZUNO_SETUP_CFGPARAMETER_HANDLER(onNewCfgParamValue);
void onNewCfgParamValue(byte param_number, dword value){
    Serial0.print("CFG Param#");
    Serial0.print(param_number);
    Serial0.print(" value:");
    Serial0.println(value);
}
void setup(){
    Serial0.begin(115200);
}
void loop(){
    Serial0.print("loop millis:");
    Serial0.println(millis());
    delay(10000);
}
2. Dynamic definition:

Code: Select all

ZUNO_ENABLE(LOGGING_DBG  WITH_CC_CONFIGURATION);
void onNewCfgParamValue(byte param_number, dword value){
    Serial0.print("CFG Param#");
    Serial0.print(param_number);
    Serial0.print(" value:");
    Serial0.println(value);
}
void setup(){
    Serial0.begin(115200);
    zunoAttachSysHandler(ZUNO_HANDLER_ZW_CFG, 0,  (void*)&onNewCfgParamValue);
}
void loop(){
    Serial0.print("loop millis:");
    Serial0.println(millis());
    delay(10000);
}
It seems that you like to explore everything deeply. It's wonderful! You can try, as I already wrote, to enable logging on TX0 (see LOGGING_DBG, https://z-uno.z-wave.me/Reference/ZUNO_ENABLE/)-there you can see incoming packets and understand whether the parameter values are coming to the device.
I also advise you to try our Razberry board as a controller, you can even add it as a second controller to your existing network. It will give you much more information about what is happening on the Z-Wave network.

With respect,
Alex.
yves
Posts: 52
Joined: 17 Sep 2021 18:05

Re: ZUNO2 system Handler(s)

Post by yves »

Hi Alex,

You were right (for sure), zunoAttachSysHandler works well (even without ENABLE(WITH_CC_CONFIGURATION) ?) Thanks!

But then there is something I am missing:
I had modified your header to try to understand where the preprocessor was fetching information. And, now, the answer is 'it depends on what you are talking about.

You say :
The handler specified by ZUNO_SETUP_CFGPARAMETER_HANDLER will work ONLY with static channel creation. When dynamically setting channels, use zunoAttachSysHandle
With my code(s) it seems that channel are inserted statically and that (sys) handler are attached dynamically.
It does not 'seem': it is! The code that 'validates' zunoAttachSysHandler includes channels statically and I have no znuoAttachChannelHandler.
Adding local bugs (after #ifdef) in ZUNO_StaticData.h shows that very well.

Questions are
  • what trigs dynamic/static inclusion?
  • is it normal that some parts are dynamic and other are not?
Best regards,
Yves
p0lyg0n1
Posts: 242
Joined: 04 Aug 2016 07:14

Re: ZUNO2 system Handler(s)

Post by p0lyg0n1 »

Hi Yves,
I will try to explain as simply as possible. The preprocessor extracts code from top-level (global-level) macros. The preprocessor generates the code for you and it can be seen in the build directory (arduino_build_<number>/zuno_preproc/ZUNO_AutoSetup.c). If you start the device configuration yourself using zone zunoStartDeviceConfiguration(), then you should not use
device configuration macros such as ZUNO_SETUP_CHANNELS(), ZUNO_SETUP_CFGPARAMETER_HANDLER(), ZUNO_SETUP_S2 ACCESS(),
ZUNO_SETUP_SLEEPING_MODE()
.
For a deeper understanding, look at the zuno_preproc subdirectory in the build directory.

With respect,
Alex.
yves
Posts: 52
Joined: 17 Sep 2021 18:05

Re: ZUNO2 system Handler(s)

Post by yves »

Hi p0lyg0n1,
Thank you for your answe. I just have to point 2 issues: (I did not had time to have a deep look in the zuno_preproc subdirectory )

* If you start the device configuration yourself using zone zunoStartDeviceConfiguration(), then you should not use
device configuration macros such as ZUNO_SETUP_CHANNELS(), ZUNO_SETUP_CFGPARAMETER_HANDLER(), ZUNO_SETUP_S2 ACCESS(),

If I do so then I am not able to include something into my HC2 network (this was where I start from...)

* Today my channel are included Statically And I need to' include' 'handler dynamically wjich does not make sense

Regards,
Yves
helendam
Posts: 1
Joined: 19 Apr 2023 05:27

Re: ZUNO2 system Handler(s)

Post by helendam »

p0lyg0n1 wrote:
23 Mar 2022 11:04
Hi,
It is not necessary to change this header, it is used by our preprocessor. How exactly the preprocessor converts the data can be seen in the build directory zunopreproc/ZUNO_AutoSetup.c. The handler specified by ZUNO_SETUP_CFGPARAMETER_HANDLER will work ONLY with static channel creation. When dynamically setting channels, use zunoAttachSysHandle.

Here are 2 examples.
1. Static definition:

Code: Select all

ZUNO_ENABLE(LOGGING_DBG);
ZUNO_SETUP_CFGPARAMETER_HANDLER(onNewCfgParamValue);
void onNewCfgParamValue(byte param_number, dword value){
    Serial0.print("CFG Param#");
    Serial0.print(param_number);
    Serial0.print(" value:");
    Serial0.println(value);
}
void setup(){
    Serial0.begin(115200);
}
void loop(){
    Serial0.print("loop millis:");
    Serial0.println(millis());
    delay(10000);
}
2. Dynamic definition:

Code: Select all

ZUNO_ENABLE(LOGGING_DBG  WITH_CC_CONFIGURATION);
void onNewCfgParamValue(byte param_number, dword value){
    Serial0.print("CFG Param#");
    Serial0.print(param_number);
    Serial0.print(" value:");
    Serial0.println(value);
}
void setup(){
    Serial0.begin(115200);
    zunoAttachSysHandler(ZUNO_HANDLER_ZW_CFG, 0,  (void*)&onNewCfgParamValue);
}
void loop(){
    Serial0.print("loop millis:");
    Serial0.println(millis());
    delay(10000);
}
It seems that you like to explore everything deeply. It's wonderful! You can try, as I already wrote, to enable logging on TX0 (see LOGGING_DBG, https://z-uno.z-wave.me/Reference/ZUNO_ENABLE/squidward)-there you can see incoming packets and understand whether the parameter values are coming to the device.
I also advise you to try our Razberry board as a controller, you can even add it as a second controller to your existing network. It will give you much more information about what is happening on the Z-Wave network.

With respect,
Alex.
thanks share
Post Reply