Skip to main content
Open topic with navigation CAPL Functions » Ethernet » Function Overview » ethernetPacket::SetData

ethernetPacket::SetData

Valid for: CANoe DE • CANoe4SW DE

Method Syntax

  • word ethernetPacket.SetData(word offset, char source[], word length); // form 1
  • word ethernetPacket.SetData(word offset, byte source[], word length); // form 2
  • word ethernetPacket.SetData(word offset, struct * source); // form 3
  • word ethernetPacket.SetData(word offset, sysvarStruct source); // form 4
  • word ethernetPacket.SetData(char protocol[], char field[], char data[], word length); // form 5
  • word ethernetPacket.SetData(char protocol[], char field[], byte data[], word length); // form 6

Description

Copies bytes from a char array, byte array, CAPL struct or system variable struct to the data of an Ethernet packet.

Parameters

  • offset: Byte offset of the data in the ethernetPacket. Offset 0 is the byte directly after the Ethertype.
  • source: Source where the data is copied from.
  • length: Number of bytes to copy.
  • protocol: Name of the protocol.
  • field: Name of the field.

Return Values

Number of bytes copied to the ethernetPacket.

Example

on key '1'
{
  _align(1) struct MyMsgLayout
  {
    word  valueA;
    dword valueB;
  };

  ethernetPacket pkt;
  struct MyMsgLayout myData;

  myData.valueA = 1;
  myData.valueB = 2;

  pkt.source      = ethGetMacAddressAsNumber( "20:00:00:00:00:01" );
  pkt.destination = ethGetMacAddressAsNumber( "FF:FF:FF:FF:FF:FF" );
  pkt.type        = 0xF123; // proprietary Ethertype
  pkt.Length      = __size_of(struct MyMsgLayout);
  pkt.SetData( 0, myData );

  output( pkt );
}
See Also