GetBusContext
Note The bus context plays a role in modeling gateways and in tests of control units with severalbus connections. In this case, a series of CAPL functions such ascanOnlineandcanOfflinemay have more than one meaning in terms of the bus interface (channel) to be used. A similar type of problem occurs when identical node layer modules are used simultaneously within a CAPL block. A distinction must be made between the instances of the node layer, both for calls to CAPL functions that are implemented in the node layers and for implementing callbacks. To facilitate this distinction, a bus context is placed in the CAPL program by the runtime environment while a callback is being executed by the node layer. This context unambiguously identifies the node layer that is making the call. In a similar manner, the call of a CAPL function that is implemented in a node layer is forwarded on to the appropriate node layer, depending on the current bus context. This also applies to the CAPL functions mentioned above,canOnlineandcanOffline, as well as to manywait pointsof theTest Feature Set. You should use the functionsGetBusNameContext,GetBusContextandSetBusContextto determine the context of a bus, to query or to change the current bus context.
Syntax
dword GetBusContext()
Function
Returns the current bus context of the CAPL block.
Parameters
—
Return Values
The current bus context.
This is an example for asimulation node.Test nodes should copy the bus context to a CAPL variable in theMain()function because all global variables are cleared when the test module is started. variables{dword ibus_context = 0;dword motbus_context = 0;}on preStart{ibus_context = GetBusNameContext( "ibus");motbus_context = GetBusNameContext( "motbus");}void apCanOn(){dword context;// activate the CAN channel on the "current" contextCanOnline();// determine the "other" contextcontext = ibus_context == GetBusContext() ? motbus_context : ibus_context;// set the context to the "other" bus...SetBusContext( context);// ...and activate its CAN chip as wellCanOnline();}
GetBusNameContext | SetBusContext