Axis Customer Forum
https://custforum.axis.com/

axevent.h and subscription to the event
https://custforum.axis.com/viewtopic.php?f=42&t=4170
Page 1 of 1

Author:  Andrey Vladimirskiy 597100 [ Tue Nov 03, 2015 12:53 pm ]
Post subject:  axevent.h and subscription to the event

Hello, all.

Help me understand how can subscribe to the event use axsdk/axevent.h

For example:
How can I access to the IO ports from within the app? I try to use example ax_event_subscription_example.c from axis/emb-app-sdk_2_0_2/apps/axevent/

Code:
static guint subscribe_to_manual_trigger_port(AXEventHandler *event_handler,  gint port, guint *token)
{
  AXEventKeyValueSet *key_value_set;
  guint subscription;

  key_value_set = ax_event_key_value_set_new();

  gboolean res =  ax_event_key_value_set_add_key_values(key_value_set,
        NULL,
        "topic0", "tns1", "Device", AX_VALUE_TYPE_STRING,
        "topic1", "tnsaxis", "IO", AX_VALUE_TYPE_STRING,
        "topic2", "tnsaxis", "Port", AX_VALUE_TYPE_STRING,
        "port", NULL, &port, AX_VALUE_TYPE_INT,
        "state", NULL, NULL, AX_VALUE_TYPE_BOOL,
        NULL);
  g_message("ax_event_key_value_set_add_key_values: %d", res);

  res = ax_event_handler_subscribe(event_handler, key_value_set,
        &subscription, (AXSubscriptionCallback)subscription_callback, token,
        NULL);
  g_message("ax_event_handler_subscribe: %d", res);


  ax_event_key_value_set_free(key_value_set);

  return subscription;
}

I close curcuit between 1 and 3 pins on camera IO port but subscription_callback() not running again.

Author:  Pandos Me 490277 [ Mon Nov 09, 2015 12:54 pm ]
Post subject:  Re: axevent.h and subscription to the event

Can you get your callback to be executed upon e.g. manual trigger but fails on IO/Port/state?

If the later, try removing the following lines

Code:

"port", NULL, &port, AX_VALUE_TYPE_INT,
"state", NULL, NULL, AX_VALUE_TYPE_BOOL,


This will capture all events for all IO ports at any state. If this works, add additional filters such as port and state.

I recommend to validate the electrical circuits by toggling the ports and read out the values on the cameras interface for IO ports.

Author:  Andrey Vladimirskiy 597100 [ Tue Nov 10, 2015 6:27 am ]
Post subject:  Re: axevent.h and subscription to the event

Pandos Me wrote:

If the later, try removing the following lines

Code:

"port", NULL, &port, AX_VALUE_TYPE_INT,
"state", NULL, NULL, AX_VALUE_TYPE_BOOL,


It helped me, tanks.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/