Search code examples
capl

How-to Stop sending out PDU in FlexRay with capl


I have a FlexRay PDU called TEMP in our case, which is getting filled in every cycle, and i would like to simulate a timeout on this PDU, but it has no updatebit.

I have a panel where i check the enable button to decide if it should be sent out or not.

frPdu FR::TEMP_Pdu;

on preStart {
  if (@FR_namespace::TEMP_Enablebutton)
  {
     FRSetSendPDU(TEMP_Pdu); 
  }
}

on frStartCycle * {
   if (@FR_namespace::TEMP_Enablebutton)
      FrUpdatePDU(TEMP_Pdu, 1, 1));
}

Whatever I set my button to, the PDU gets transmitted every loop.


Solution

  • FRUpdatePDU() is not sending another instance of PDU, it is just updating the next iteration with data from the frPDU object, since we are talking about PDU of a static frame, once the VN starts sending it, you cannot stop it individually by PDU control. enter image description here

    Frame vs. PDU A frame is physical Flexray Frame on the network. a PDU, is a virtualization of a part (or of the entire) of the frame payload. Analogy: The postal truck is the FlexRay Frame, and the boxes in it are PDUs. For the Postal service (Flexray Protocol - OSI layer 1) the important unit is the truck itself, and for you (the client), the boxes in it. You will never be interested in what kind of truck delivered your goodies in a box, you are interested only in the content itself.

    When you call the FrUpdatePDU(), you not only start sending the PDU, but you activate (send non-null frames) its slot also. By setting the frame underneath to non-null frame, you ensured (in a case of static frame) that it will be sent cyclically from that point, automatically, regardless what you want to do with the PDU (the trucks are going anyway, even if you don't want to send boxes in them).

    Solution: I presume you do not have IL DLLs to aid you, therefore you are limited to the functions CANoe environment provides as General FlexRay IL functions.

    1. You need to identify the frame carrying the PDU.
    2. You need to manipulate the frame also with frUpdateStatFrame().

    frframe FramefromDBCofTEMPPDU InstanceofFrameTemp;

    on frStartCycle * {

    if (@FR_namespace::TEMP_Enablebutton==1)
    
    {
    
    mframe.fr_flags=0x0;
    
    frUpdateStatFrame(mframe);
    
    TEMP_Pdu.byte(0xAA);
    
    FrUpdatePDU(TEMP_Pdu, 1, 1));
    
    }
    
    else 
    
    {
    
    mframe.fr_flags=0x80;
    
    frUpdateStatFrame(mframe);
    
    }
    
    }
    

    So, in fact you need to modify the frame also. About the frame flags, check out the definition of the frframe in Help.

    enter image description here