CAPL Functions » AFDX » AfdxInitPacket
Function Syntax
long AfdxInitPacket( long msgID, char msgName[], long initSignals ); // form 1long AfdxInitPacket( long srcIP, long dstIP, long srcUdpPort, long dstUdpPort, long virtualLinkId, long payloadSize ); // form 2long AfdxInitPacket( long copyFromPacket ); // form 3long AfdxInitPacket( ); // form 4long AfdxInitPacket( long rawDataLength, byte rawData[] ); // form 5long AfdxInitPacket( long rawDataLength, char rawData[] ); // form 6long AfdxInitPacket( long rawDataLength, struct * rawData ); // form 7
Description
Any access to an AFDX message requires a valid handle. This function returns such a handle and enables the user to manipulate or transmit the message in subsequent calls to AFDX CAPL functions. This function allocates internal buffer memory and initializes the corresponding protocol fields. The level of initialization depends on the selected function signature.- Form 1: When an AFDX DBC is used, this function may be called for a message in this DBC with either the message ID or the message name. Note that the message attributes from the DBC file are used for initialization too.
- Form 2: When the complete addressing information is available, this function signature provides a convenient way to create the handle.
- Form 3: If you want to create another instance of an existing AFDX message (either previously created with
AfdxInitPacketor signaled with the callback<OnAfdxPacket>), this function signature should be used. Addressing information, attributes, and payload contents are duplicated for the new handle. - Form 4: This function signature returns a handle to an “empty” message (all fields are set to “0”).
- Form 5-7: With these function signatures, it is possible to create a message based on either a raw byte stream or an initialized structure. The specified initialization data is copied to the target message “as is”.
Parameters
-
msgID
0: Instead ofmsgID, the parametermsgNameis used for referencing the message in the assigned AFDX DBC file.!0: This value references a message ID in the assigned AFDX DBC file. The corresponding message is used for initialization.
-
msgName
0: Instead ofmsgName, the parametermsgIDis used for referencing the message in the assigned AFDX DBC file.<Message Name>: This value references a message name in the assigned AFDX DBC file. The corresponding message is used for initialization.
-
initSignals
0: The signal area of the message is initialized with 0.!0: The value of an already initialized signal is used.
- srcIP: Source IP address.
- dstIP: Destination IP address. The IP address is given as an integer value (hexadecimal address notation 0xwwxxyyzz corresponds to WW.XX.YY.ZZ with decimal notation). For this function, the value of the source IP address has to start with 10.XX.YY.ZZ. For the destination IP address, the value has to start with either 10.XX.YY.ZZ or 224.XX.YY.ZZ. Note that you may enter the IP addresses later on with the function AfdxSetTokenInt.
-
srcUdpPort:
1..65535: source UDP port -
dstUdpPort:
1..65535: destination UDP port -
virtualLinkId:
1..65535: Virtual Link Identifier -
payloadSize:
0..8192: payload size of AFDX message -
copyFromPacket: The protocol header and the data of a message identified via
copyFromPacketis used for initializing a new message. - rawDataLength: This is the number of bytes in an initialization array or structure. Note that the size may be gathered with elCount (for byte rawData[]), strlen (for char rawData[]) or __size_of (for struct * rawData).
- rawData: Raw initialization data.
Return Values
- 0: Could not initialize the message. The error code may be retrieved with AfdxGetLastError.
- !0: Handle of the message.