Documentation Index
Fetch the complete documentation index at: https://notevil.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Open topic with navigation
frSetMode
CAPL Functions » FlexRay » frSetMode
Valid for: CANoe DE
Function Syntax
frSetMode( int channel, int channelMask, dword mode );
Description
This function initializes the FlexRay bus drivers. Essentially, it defines whether the drivers are set to normal mode or sleep mode.
Note: If the transceivers had been disabled (sleep mode), and a wake-up pattern is received (see on frPocState), then the transceivers must explicitly be activated again!
Parameters
- channel: FlexRay channel (cluster number).
- channelMask: Determines which bus driver is being programmed.
Value:
1: Channel A
2: Channel B
3: Channel A+B
- mode: Defines the bus driver state:
0x0000: Normal mode, when starting the Communication Controller a Wakeup will be sent if this is defined in the hardware configuration dialog.
0x0001: Sleep mode
0x0002: Normal mode, when starting the Communication Controller no Wakeup will be sent.
Return Values
—
Example
Example 1: The following CAPL program deactivates or activates the physical drivers according to key presses.
on key 'd'
{
// suspend physical layers:
frSetMode(%CHANNEL%, 3, 1);
Write("FlexRay physical layers of channel %d are offline (sleep mode).", %CHANNEL%);
}
on key 'a'
{
// activate physical layers (with optional wake-up):
frSetMode(%CHANNEL%, 3, 0);
Write("FlexRay physical layers of channel %d are going online (with optional wakeup to send).", %CHANNEL%);
}
on key 'q'
{
// activate physical layers without any wake-up:
frSetMode(%CHANNEL%, 3, 2);
Write("FlexRay physical layers of channel %d are going online.", %CHANNEL%);
}
Example 2: The following CAPL program deactivates or activates the physical drivers according to the clusters synchronisation state and reception of a wake-up symbol.
variables
{
const int cFrChanMask = 3; // for channel A+B
const int cFrModeGoSleep = 1;
const int cFrModeGoNormal = 2;
int gClusterSync = -1;
int gCntWakeups = 0;
}
on FRPocState
{
if (this.MsgChannel != %CHANNEL%) return;
if (((gClusterSync == -1) || (gClusterSync == 1)) && ((this.FR_POCState == 4) || (this.FR_PocState == -2))) // FlexRay interface is async
{
// resetFlexRayCC(%CHANNEL%);
gClusterSync = 0;
write("FR: Lost Sync Time: %.6f", timenowns()/1000000000.0);
gotoSleep();
}
else if (((gClusterSync == -1) || (gClusterSync == 0)) && (this.FR_POCState == 2)) // Synchronous again
{
gClusterSync = 1;
write("FR: Get Sync Time: %.6f", timenowns()/1000000000.0);
write("FR: received %d Wakeup Symbols", gCntWakeups);
gCntWakeups = 0;
}
if (this.FR_Info2 == 7)
{ // generated by VN interface
receiveWakeup();
}
}
on start
{
gotoNormal();
}
on frSymbol
{
if (this.MsgChannel != %CHANNEL%) return;
if (this.FR_Symbol == 3) // Wakeup symbol
{ // generated by FlexCard Cyclone II interface
receiveWakeup();
}
}
void gotoSleep ()
{
frSetMode( %CHANNEL%, cFrChanMask, cFrModeGoSleep);
write("FR: Sleep Time: %.6f", timenowns()/1000000000.0);
}
void gotoNormal ()
{
frSetMode( %CHANNEL%, cFrChanMask, cFrModeGoNormal);
write("FR: Wakeup Time: %.6f", timenowns()/1000000000.0);
}
void receiveWakeup ()
{
gotoNormal();
gCntWakeups++;
}