You are on page 1of 3

frSetMode Page 1 of 3

Topic search

frSetMode
CAPL Functions » FlexRay » frSetMode

Syntax frSetMode( int channel, int channelMask, dword mode );


Function 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:

Mode Meaning
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 —
Availability Since Version Restricted To Measurement Setup Simulation / Test Setup
6.0 FlexRay — •
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):

mk:@MSITStore:C:\Program%20Files\Vector%20CANoe%2011.0\Help01\CANoeCANal... 2/16/2023
frSetMode Page 2 of 3

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 ()
{

mk:@MSITStore:C:\Program%20Files\Vector%20CANoe%2011.0\Help01\CANoeCANal... 2/16/2023
frSetMode Page 3 of 3

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++;
}

Version 11.0 SP3
© Vector Informatik GmbH

mk:@MSITStore:C:\Program%20Files\Vector%20CANoe%2011.0\Help01\CANoeCANal... 2/16/2023

You might also like