vector.com|Contact
Search tips

apple banana
Find rows that contain at least one of the two words.

+apple +juice
Find rows that contain both words.

+apple macintosh
Find rows that contain the word 'apple', but rank rows higher if they also contain 'macintosh'.

+apple -macintosh
Find rows that contain the word 'apple' but not 'macintosh'.

+apple ~macintosh
Find rows that contain the word 'apple', but if the row also contains the word 'macintosh', rate it lower than if row does not. This is "softer" than a search for '+apple -macintosh', for which the presence of 'macintosh' causes the row not to be returned at all.

+apple +(>turnover >strudel)
Find rows that contain the words 'apple' and 'turnover', or 'apple' and 'strudel' (in any order), but rank 'apple turnover' higher than 'apple strudel'.

apple*
Find rows that contain words such as 'apple', 'apples', 'applesauce', or 'applet'.

"some words"
Find rows that contain the exact phrase 'some words' (for example, rows that contain 'some words of wisdom' but not "some noise words").

By continuing to use this site you agree to the use of cookies. For more information and to find out how to change this click here. Accept Cookies
Please enable cookies in your browser for this website.
Search:
Advanced search

Creating a CAPL PDU Gateway Between Two CAN Networks (AUTOSAR Version ≥ 4.2.1)

Last updated: 2020-05-13
Question:

How can I set up a CAPL gateway between two CAN bus systems using AUTOSAR databases ≥ 4.2.1?

Answer:

The gateway can be realized by routing the PDUs and works similarly to a frame-based approach. Key to the gateway is the CAPL function TriggerPDU2(), which uses the following syntax:

long TriggerPDU2 ( PDU * obj, dword dstBusContext, char DBName[], char TXNode[], char PDUName[], dword ShortHeaderID, dword LongHeaderID, dword Flags, dword PduLength);

Parameters:

  • obj: PDU object (or keyword this of on PDU event handler)
  • dstBusContext: bus context of destination bus in simulation setup
  • DBName: Name of database (optional, e.g. empty string "")
  • TXNode: Name of TX node in database (optional, e.g. empty string "")
  • PDUName: Name of the PDU in the database to be used in order to identify PDU on destination bus (prio 3)
  • ShortHeaderID: Short header ID to be used in order to identify PDU on destination bus (prio 2)
  • LongHeaderID: Long header ID to be used in order to identify PDU on destination bus (prio 1)
  • Flags: reserved, should be set to 0 (0x10 allows payload length manipulation)
  • PduLength: reserved; should be set to payload length of PDU in [Byte]

Return values:

  •  0: successful
  • -1: any name parameter invalid (null)
  • -2: PDU obj invalid (null)
  • -3: destination channel is invalid
  • -4: measurement is not running
  • -5: PDU server of TX node is not present (TX node not present on destination bus in simulation setup)
Example:

Here is a working sample configuration.

The sample configuration was made with CANoe 11.0.55 and uses an AUTOSAR 4.2 sample database. No OEM packages have been used in this sample. PDUs are routed from the first CAN network CAN_Powertrain to the second network CAN_Second via the GW network node, which has to be present on both networks (Gateway). Add a CAPL file to the GW node with the following source code:

variables
{
  dword srcBusContext;
  dword dstBusContext;
}

on preStart
{
  //Get the appropriate bus context
  srcBusContext = GetBusNameContext("CAN_Powertrain");
  dstBusContext = GetBusNameContext("CAN_Second");
}

on PDU *
{
  // Route all PDUs received on first CAN network to the second network
  long result; 
  if((this.MsgChannel == 1) && (this.BusType == eCAN))
  {
    result=TriggerPDU2(this, dstBusContext, "PowerTrain" /* DBName */, "" /* TXNode */, this.Name /* PDUName */, this.ShortHeaderID, this.LongHeaderID, 0, this.PduLength);
    if(result != 0)
    {
      Write("Return value of TriggerPDU2: %d", result);
    }
  }
}

on pdu msgchannel1.EngineData
{
   pdu msgchannel2.EngineData gwPDU;
   if((this.MsgChannel == 1) && (this.BusType == eCAN))
   {
      // Change signal value before routing to CAN_Second
      memcpy(gwPDU.Payload, this.Payload, this.PduLength);
      gwPDU.EngSpeed = 100;

      TriggerPDU(gwPDU);
   }

}

on PDU msgchannel1.Ignition_Info
{
   // do nothing --> PDU will not be routed to CAN_Second
}

Using this code, all PDUs that are received on CAN_Powertrain will be routed to CAN_Second via the function TriggerPDU2(), except for EngineData and Ignition_Info. Both PDUs are processed in separate even handlers, which take priority over the on PDU * event, to ensure that the messages are not being sent twice. Although this sample does not use any PDU Containers, it can be used with their Contained PDUs as well.

 
Article Options
2020-05-13
Views: 289