The idea behind the Node Discovery service is that nodes are allowed to use the bus only if they meet certain requirements. A central instance detects all nodes and checks if they fit to the intended system. Nodes passing the check get an explicit "invitation" to join the system.
The application provides the two callback functions of the Node Discovery service.
See also Getting Started, section Initialization. |
The application maintains at least two lists:
Contains the signatures of the nodes the system shall contain.
For debuggting purposes it may be useful to have a third list:
Signatures of the nodes which are detected but are not part of the set_list.
After startup all nodes are initialized and not part of the system. The application starts the Node Discovery service by calling Ucs_Nd_Start(). It asks every node for its signature (Ucs_Signature_t). Each detected node will be presented to the application via the callback function App_OnNodeDiscoveryEval(). In this function the application decides how the Node Discovery service shall proceed with the node.
The evaluation has to follow these rules:
The result of the evaluation is passed as the return value of App_OnNodeDiscoveryEval() (for possible values see Ucs_Nd_CheckResult_t).
When the Node Discovery process for a certain node is finished, the callback function App_OnNodeDiscoveryResult() is called. Its parameter code informs the application about the result of the node (for possible values see Ucs_Nd_ResCode_t).
The Node Discovery service asks periodically for new nodes. So it will detect nodes which start up slowly and nodes which experienced a reset.
App_OnNodeDiscoveryResult() informs also about general events like NetOff, unexpected error and stop of the Node Discovery service by application command. In these cases the parameter signature will be NULL.
If a Netoff event happens, the Node Discovery service stops. It restarts automatically if it detects a NetOn event.
The application can stop the Node Discovery service via Ucs_Nd_Stop().
It is possible to reset all nodes to the initial state they had after startup by calling Ucs_Nd_InitAll().