Skip to main content
Open topic with navigation

ethernetPacket Selectors: <protocol>.byteLength

CAPL Functions » Ethernet » Function Overview » ethernetPacket » Selector <protocol>.byteLength Valid for: CANoe DE • CANoe4SW DE

Selectors

dword ethernetPacket.<protocol>.byteLength;

Description

Returns the length of the payload of the protocol. The selector is read only. If <protocol> is not contained in the packet, the selector returns 0. ethernetPacket::protocol::IsAvailable can be used to find out if the protocol is available.

Parameters

Return Values

Length of the protocol payload in bytes.

Example

ethernetPacket pkt;
word           offset, length, i;

// initialize packet with IPv4 and UDP protocols
pkt.udp.Init();
pkt.udp.ResizeData(10);

offset = pkt.udp.byteOffset;
length = pkt.udp.byteLength;

write( "Protocol udp is at byte %d:%d", offset, length );

for( i = 0; i < length; i++ )
{
    pkt.byte( offset+i ) = i;
}

// calculate UDP and IPv4 checksum and send Ethernet packet
pkt.CompletePacket();
output( pkt );