MessageCAN

Summary

Represents a CAN message object.

Methods
Properties
Events

Structure

class MessageCAN
capture(filter: Filter = None) MessageCAN

Matches any message with the same protocol.

Parameters

filter (Filter) – Filter to use to narrow down packets to capture

Returns

Listens to the bus until a message is received and returns this first message

Return type

MessageCAN

capture(timeout: int32, filter: Filter = None) MessageCAN

Waits for the first message having the same protocol that the sent message without verify the IP address and the port between send and respond message and return it. A timeout is specified to guarantee that the script can continue if no message is captured in a certain time interval.

Parameters
  • timeout (int32) – Max time in milliseconds to wait for the response.

  • filter (Filter) – Filter to use to narrow down packets to capture

Returns

First message captured from the bus or None in case no message is received.

Return type

MessageCAN

capture_list(timeout: int32, filter: Filter = None) IReadOnlyList[MessageCAN]

Waits for any response having the same protocol that the sent message without verify the IP address and the port between send and respond message and return them all as a list. A timeout is specified to guarantee that the script can continue if no message is received in a certain time interval.

Parameters
  • timeout (int32) – Max time in milliseconds to wait for the response.

  • filter (Filter) – Filter to use to narrow down packets to capture

Returns

List of messages captured from the bus during a given period of time.

Return type

IReadOnlyList[MessageCAN]

close_writer()

Closes the file previously created with open_writer(file).

get_all_signals_interpretations() Dictionary[str, object]

Gets a dictionary of all the signal interpretations of the Message.

Returns

dictionary of signal interpretations.

Return type

Dictionary[str, object]

get_all_signals_values() Dictionary[str, int]

Gets a dictionary of all the signal values (name, value).

Returns

Dictionary of all signals values

Return type

Dictionary[str, int]

get_signal_interpretation(name: str) object

Gets the interpretation of the frame of the corresponding signal given in parameter.

Parameters

name (str) – Desired signal's name

Returns

return the interpretation as an object.

Return type

object

get_signal_value(name: str) int or None

Gets a value of a specific signal given its name.

Parameters

name (str) – Desired signal's name

Returns

Signal's value.

Return type

int or None

open_writer(file: str, fileFormat: FILEFORMAT or None = None)

Creates a PCAP or PCAPNG file for writing the received messages. If the file already exists, it will be overwritten (old file data will be lost). Use the store() method to record received messages into the file.

Parameters
  • file (str) – Absolute path of the file where the messages will be stored

  • fileFormat (FILEFORMAT or None) – Obsolete, you don't need to specify this argument anymore

receive() MessageCAN

Matches a response for the used message.

Returns

Listens to the bus until a message is received and returns this first message

Return type

MessageCAN

receive(timeout: int32) MessageCAN

Waits for the first response having the IP address destination equals to the IP address source of the sent message and return it. A timeout is specified to guarantee that the script can continue if no message is received in a certain time interval.

Parameters

timeout (int32) – Max time in milliseconds to wait for the response.

Returns

First message received from the bus or None in case no message is received.

Return type

MessageCAN

receive_list(timeout: int32) IReadOnlyList[MessageCAN]

Waits for any response having the IP address destination equals to the IP address source of sent message and return them all as a list. A timeout is specified to guarantee that the script can continue if no message is received in a certain time interval.

Parameters

timeout (int32) – Max time in milliseconds to wait for the response.

Returns

List of messages received from the bus during a given period of time.

Return type

IReadOnlyList[MessageCAN]

reset_signal_value(signalName: str = None)

Resets the signal value to its default value. If no signalName is specified, reset all signals.

Parameters

signalName (str) – the name of the signal to reset

send() bool

Sends the message (the one used to call the method) through the Ethernet bus.

Returns

Returns True if the message is sent successfully. Otherwise, an exception will be thrown.

Return type

bool

set_signal_value(name: str, value: uint64 or None)

Sets the value of a specific signal to a specific value.

Parameters
  • name (str) – Desired signal's name

  • value (uint64 or None) – Desired signal's value

signal(name: str) SignalValue

Gets a signal by its name.

Parameters

name (str) – Desired signal's name

Returns

Signal's value.

Return type

SignalValue

start_capture(filter: Filter = None)

Used for online capture(capturing network traffic from an adapter). Used with callback function(on_message_received()) and stop_capture() method.

Parameters

filter (Filter) – Filter to use to narrow down packets to capture

start_capture(file: str, wait_eof: bool, filter: Filter = None)

Used for offline capture(reading packets from pcap or asc file). Used with callback function(on_message_received()) and stop_capture() method.

Parameters
  • file (str) – The trace file from where the messages will be read.

  • wait_eof (bool) – If True the function would block until all frames in the file are read. If False the function would read the frames in the background.

  • filter (Filter) – Filter to use to narrow down packets to capture

stop_capture()

Stops capturing Ethernet messages, either directly from the bus or from a trace file (depending on the version used to start the capture).

store()

Writes the message into the trace file opened with open_writer(file).

@on_capture_start

The event is triggered when the capture of Ethernet messages is started. See start_capture .

@on_capture_stop

The event is triggered when the capture of Ethernet messages is stopped. See stop_capture .

@on_message_received(message: MessageCAN)

Event is triggered every time a message is read from the Ethernet bus or a trace file. See start_capture.

Parameters

message (MessageCAN) – The message object being handled.

auto_calculate

Determines which signals are auto calculated.

Type

AutoCalculate

can_header

Object containing the information from the can header like the identifier and length of the message.

Type

ICANHeader

capture_info

General information about the context in which the message was captured from. None if the message was not captured

Type

CaptureInfo

data_base

Takes the database object.

Type

Database

direction

The Data Direction of the message, INPUT or OUTPUT.

Type

DataDirection or None

fd

Boolean to indicate whether the message is CAN or CAN-FD. When set to True, the BRS property will be set to True automatically.

Type

bool

frame

The frame received, in the context of all the Ethernet captured traffic.

Type

IFrameInstance

frame_number

Number of the frame received, in the context of all the ethernet traffic captured.

Type

int64

payload

Content, in bytes, of the payload of the message.

Type

Array[uint8]

timestamp

Timestamp of the message.

Type

decimal