# null

[Open topic with navigation](../../../../../CANoeDEFamily.htm#Topics/CAPLFunctions/FlexRay/Functions/CAPLfunctionFRUpdateStatFrame.md)

**CAPL Functions** » **FlexRay** » **frUpdateStatFrame**

# frUpdateStatFrame

[Valid for](../../../Shared/FeatureAvailability.md): CANoe DE

**Note**

Instead of giving the parameters in brackets the message object can be declared by using a symbolic name from the FIBEX database. In this case those parameters are taken from the database and you can directly access the signals of the frame by its symbolic name instead of accessing its bytes.

Is the frame located in a slot of the dynamic segment, you must use the function [frOutputDynFrame](CAPLfunctionFROutputDynFrame.md) instead of `frUpdateStatFrame`. A dynamic frame must not be a startup or sync frame. A dynamic frame must also not be sent redundantly on both channels A + B with a channel mask 3.

When the appropriate Tx buffer is declared by the Tx buffer list of the hardware configuration dialog, then the function [frSetSendFrame](CAPLfunctionFrSetSendFrame.md) in `on preStart` is deprecated. It can still be used for overriding settings in the Tx buffer list.

Is the update time close to the sending slot (e.g. update of slot 2 just after the start of a cycle), then with high probability the update will be too late for the current cycle and the frame is sent in the next possible cycle! Thus, updates should be made early enough before the sending slot.

## Function Syntax

```plaintext
int ret = frUpdateStatFrame( <frame var> );
```

## Description

This function updates the FlexRay **C**ommunication **C**ontroller's (CC) send buffer with the current data from the send object. This corresponds to a request to send.

Only frames in the static segment can be sent using this function!

## Parameters

* `<frame var>`: Name of the variable referenced by the frame object. The variable name was defined when the object was created using [frFrame](../Objects/CAPLfunctionFRFrame.md).

## Return Values

* `0`: Ok, the request to send the frame is forwarded to the interface. This does not guarantee that the frame is really been sent. Refer to the FlexRay protocol rules.
* `-1`: Error, either the channel is not available or the slot ID is not in the static segment.

## Example

The following CAPL program sends a start-up/sync frame in slot 60 in every cycle. The calculation of the payload and the Tx buffer update is synchronously executed to every start of a cycle.

```plaintext
variables
{
  // The gMsg1 message is a start-up/sync message for the static segment
  // that is sent on both channels.

  frFrame ( 20, 0, 1) gMsg1;
  const LONG gMsg1Channel  = %CHANNEL%; // send on network the CAPL node is assigned to
  const LONG gMsg1ChanMask = 3;  // send on FlexRay channel A+B
  const long gMsg1KeySlotIndex = 1; // use key slot 1
  const LONG gMsg1KeySlotID = 20; // send in key slot 20 (static segment)
  const LONG gMsg1KeySlotUsg = 3; // sync and startup
  BYTE gMsg1Len; // Payload length
  BYTE gCycle; // remember current FlexRay cycle
  frConfiguration gFRParams;
}

on preStart
{
  // Calculation of Payload length
  frGetConfiguration(%CHANNEL%, gFRParams);
  gMsg1Len = gFRParams.gPayloadLengthStatic * 2;
  // Optionally prepare buffer for message gMsg1:
  gMsg1.MsgChannel = gMsg1Channel;
  gMsg1.FR_ChannelMask = gMsg1ChanMask;
  frSetPayloadLengthInByte(gMsg1, gMsg1Len);
  frSetKeySlot(gMsg1Channel, gMsg1ChanMask, gMsg1KeySlotIndex, gMsg1KeySlotID, gMsg1KeySlotUsg);
}

DoFRCalc ()
{
  int i;
  gMsg1.byte(0) = gCycle;
  // or gMsg1.signame = value; if frame is symbolically declared
  for (i = 1; i < gMsg1.FR_PayloadLength * 2; ++i)
  {
    gMsg1.byte(i) = i;
  }
}

DoFRSend ()
{
  // Update the message buffer:
  frUpdateStatFrame(gMsg1); // or FROutputDynFrame(gMsg1);
}

on frStartCycle *
{
  gCycle = this.FR_Cycle;
  DoFRCalc(); // calculate and set message contents
  DoFRSend(); // commit buffer for sending
}
```
