src.dualinventive.com/jjacobs/dinetrpcll-sniffer/libdi/doc/can/net_discover.md

1.7 KiB

DI-CAN Net discover and redundancy

Application usage of the Net subsystem

The application needs to configure and execute the Net subsystem in a defined way to use the discover and redundancy functionality.

@image html images/di_can_net_app_interaction.svg

In the list below the important parts necessary for the application are summed:

  • @ref can_net_callbacks
  • @ref can_net_node_events
  • Set the self node role to [FOLLOWER](@ref DI_CAN_NET_NODE_ROLE_FOLLOWER) when ready with @ref di_can_net_self_set_node_role.
  • Periodic execute @ref di_can_net_execute must be called periodicly from the application
    • Discovers the network (@ref di/can/net/discover.h)
    • Executes the follower/leader statemachine
    • @ref di_can_net_discover_fsm_follower
    • @ref di_can_net_discover_fsm_leader

Message callbacks

The application needs to register a few @ref di_can_callback message callbacks or else they are not processed by the Net subsystem. As depicted in the list below:

  • @ref DI_CAN_NET_CALLBACK_HEARTBEAT_PUBLISH_ITEM
  • @ref DI_CAN_NET_DISCOVER_CALLBACK_REQUEST_ITEM
  • @ref DI_CAN_NET_DISCOVER_CALLBACK_REPLY_ITEM

Register for all node events

The application is able to register a callback for all events triggered from all nodes with @ref di_can_net_node_set_event_callback.

@warning The application should be aware in the callback the Net context is locked! And only certian functions may be used or else a deadlock will occur.

All the available events are decribed in the @ref di_can_net_node_events enum.

Some functions can be used inside the application defined callback:

  • @ref di_can_net_node_is_self
  • @ref di_can_net_node_is_same_type_as_self