Vector¶
This interface adds support for CAN controllers by Vector.
By default this library uses the channel configuration for CANalyzer.
To use a different application, open Vector Hardware Config program and create
a new application and assign the channels you may want to use.
Specify the application name as app_name='Your app name'
when constructing
the bus or in a config file.
Channel should be given as a list of channels starting at 0.
Here is an example configuration file connecting to CAN 1 and CAN 2 for an application named “python-can”:
[default]
interface = vector
channel = 0, 1
app_name = python-can
If you are using Python 2.7 it is recommended to install pywin32, otherwise a slow and CPU intensive polling will be used when waiting for new messages.
Bus¶
-
class
can.interfaces.vector.
VectorBus
(channel, can_filters=None, poll_interval=0.01, receive_own_messages=False, bitrate=None, rx_queue_size=16384, app_name='CANalyzer', fd=False, data_bitrate=None, sjwAbr=2, tseg1Abr=6, tseg2Abr=3, sjwDbr=2, tseg1Dbr=6, tseg2Dbr=3, **config)[source]¶ Bases:
can.bus.BusABC
The CAN Bus implemented for the Vector interface.
Parameters: - channel (list) – The channel indexes to create this bus with. Can also be a single integer or a comma separated string.
- poll_interval (float) – Poll interval in seconds.
- bitrate (int) – Bitrate in bits/s.
- rx_queue_size (int) – Number of messages in receive queue (power of 2). CAN: range 16…32768 CAN-FD: range 8192…524288
- app_name (str) – Name of application in Hardware Config.
- fd (bool) – If CAN-FD frames should be supported.
- data_bitrate (int) – Which bitrate to use for data phase in CAN FD. Defaults to arbitration bitrate.
-
send
(msg, timeout=None)[source]¶ Transmit a message to the CAN bus.
Override this method to enable the transmit path.
Parameters: - msg (can.Message) – A message object.
- timeout (float) – If > 0, wait up to this many seconds for message to be ACK:ed or for transmit queue to be ready depending on driver implementation. If timeout is exceeded, an exception will be raised. Might not be supported by all interfaces.
Raises: can.CanError – if the message could not be written.
-
exception
can.interfaces.vector.
VectorError
(error_code, error_string, function)[source]¶ Bases:
can.CanError