16. cc_vector_can

16.1. CAN Communication Channel using Vector hardware

module:

cc_vector_can

synopsis:

CChannel implementation for CAN(fd) using Vector API from python-can

class pykiso.lib.connectors.cc_vector_can.CCVectorCan(bustype='vector', poll_interval=0.01, rx_queue_size=524288, serial=None, channel=3, bitrate=500000, data_bitrate=2000000, fd=True, enable_brs=False, app_name=None, can_filters=None, is_extended_id=False, **kwargs)[source]

CAN FD channel-adapter.

Initialize can channel settings.

Parameters:
  • bustype (str) – python-can interface modules used

  • poll_interval (float) – Poll interval in seconds.

  • rx_queue_size (int) – Number of messages in receive queue

  • serial (int) – Vector Box’s serial number. Can be replaced by the “AUTO” flag to trigger the Vector Box automatic detection.

  • channel (int) – The channel indexes to create this bus with

  • bitrate (int) – Bitrate in bits/s.

  • app_name (str) – Name of application in Hardware Config. If set to None, the channel should be a global channel index.

  • data_bitrate (int) – Which bitrate to use for data phase in CAN FD.

  • fd (bool) – If CAN-FD frames should be supported.

  • enable_brs (bool) – sets the bitrate_switch flag to use higher transmission speed

  • can_filters (list) – A iterable of dictionaries each containing a “can_id”, a “can_mask”, and an optional “extended” key.

  • is_extended_id (bool) – This flag controls the size of the arbitration_id field.

_cc_close()[source]

Close the current can bus channel.

Return type:

None

_cc_open()[source]

Open a can bus channel and set filters for reception.

Return type:

None

_cc_receive(timeout=0.0001)[source]

Receive a can message using configured filters.

Parameters:

timeout – timeout applied on reception

Return type:

Dict[str, Union[Message, bytes, int]]

Returns:

the received data and the source can id

_cc_send(msg, remote_id=None, **kwargs)[source]

Send a CAN message at the configured id.

If remote_id parameter is not given take configured ones.

Parameters:
  • msg – data to send

  • remote_id (Optional[int]) – destination can id used

  • kwargs – named arguments

Return type:

None

pykiso.lib.connectors.cc_vector_can.detect_serial_number()[source]

Provide the serial number of the currently available Vector Box to be used.

If several Vector Boxes are detected, the one with the lowest serial number is selected. If no Vector Box is connected, a ConnectionRefused error is thrown.

Return type:

int

Returns:

the Vector Box serial number

Raises:

ConnectionRefusedError – raised if no Vector box is currently available