Capture Info Tutorial

Capture Info Definition

Capture Info is the hardware information of the gateway from which the current message was received.
Each message has its capture info object as msg.capture_info, this object is read-only and will have a value only when the parent message is decoded with get_layer function, or received via an adapter, otherwise it returns None.
Information about this object are in capture info.

Note

If a gateway layer is not found, then only capture_info.timestamp will have a value, the other attributes will all return None.

Note

The supported gateways and their ether types are:
  • BR-SPY ETH Wrapper (0x2082)

  • BR-SPY ETH Mini Wrapper (0x2182)

  • BR-SPY ETH Mini Wrapper Legacy (0x2183)

  • BR-SPY ETH 1000T Mini Wrapper (0x2282)

  • BR-SPY CAN Wrapper (0x2085)

  • PLP (0x2090)

  • TECMP (0x99FE)

Note

For PLP the CRC value depends on the msg type, only logging messages of type LIN, raw CAN FD and Ethernet have CRC value, otherwise CRC returns None.
For more information on PLP messages check the PLP Tutorial.

Getting Capture Info on Packet reception

When a msg is received, its Capture Info object is automatically created and filled with information about the gateway.

Example script:

# Import sleep
from time import sleep
# Create Message
received_msg = message_builder.create_ethernet_message("Receiver", "Receiver")
# Method used when receiving a message
def on_message_received(msg):
        print("message received")
        print(msg.capture_info)
        # This will output the value of the capture_info for the received message
        # Example output:
        # <CaptureInfo gateway_type=BrSpyEth(0x2082) timestamp=2 crc=0xA2633EEF gateway_timestamp=6386.609074160 gateway_address=00:50:C2:E4:30:4A gateway_port=12 >
# script to capture incoming messages
received_msg.on_message_received += on_message_received
received_msg.start_capture()
print("capture started")
sleep(20)
print("capture stop")
received_msg.stop_capture()
received_msg.on_message_received -= on_message_received

Getting Capture Info after decoding a packet

When getting a layer of a message, the entire payload gets decoded, and if a gateway layer is found, the Capture Info object of the resulting message gets created.

Note

object.capture_info.timestamp will have the same value as the parent message timestamp

Example script:

# Create message.
received_msg = message_builder.create_ethernet_message("Receiver", "Receiver")
DATA = tuple(bytearray.fromhex('ff ff ff ff ff ff 00 50 c2 e4 30 4a 20 82 01 00 25 2c ca 04 66 \
0c 00 05 8e 91 e0 f0 00 01 00 02 00 00 00 00 02 81 00 40 04 22 f0 03 80 93 01 04 71 02 6f 01 00 \
00 13 00 00 00 00 02 01 00 00 05 60 00 00 00 00 00 00 7c 05 0c 60 1e 62 38 2d 67 ff ef e6 5f e1 \
8c 07 60 d1 33 de ff ff 3f e1 8c 04 80 03 60 0a 3a 5a bd cf fb de ef bd ff'))
# Setting the bytes of the message.
received_msg.set_bytes(DATA)
# Decode the message with get_layer to generate capture info.
msg = received_msg.get_layer(PROTOCOL_TYPE.ETHERNET_FRAME)
print(msg.capture_info)
# The output of this script will be
# <CaptureInfo gateway_type=BrSpyEth(0x2082) timestamp=2 crc=0xA2633EEF gateway_timestamp=6386.609074160 gateway_address=00:50:C2:E4:30:4A gateway_port=12 >