Kvaser’s CANLib SDK for Windows (also available on Linux).
KvaserBus(channel, can_filters=None, **config)¶
The CAN Bus implemented for the Kvaser interface.
- bitrate (int) – Bitrate of channel in bit/s
- accept_virtual (bool) – If virtual channels should be accepted.
- tseg1 (int) – Time segment 1, that is, the number of quanta from (but not including) the Sync Segment to the sampling point. If this parameter is not given, the Kvaser driver will try to choose all bit timing parameters from a set of defaults.
- tseg2 (int) – Time segment 2, that is, the number of quanta from the sampling point to the end of the bit.
- sjw (int) – The Synchronization Jump Width. Decides the maximum number of time quanta that the controller can resynchronize every bit.
- no_samp (int) – Either 1 or 3. Some CAN controllers can also sample each bit three times. In this case, the bit will be sampled three quanta in a row, with the last sample being taken in the edge between TSEG1 and TSEG2. Three samples should only be used for relatively slow baudrates.
- driver_mode (bool) – Silent or normal.
- single_handle (bool) – Use one Kvaser CANLIB bus handle for both reading and writing. This can be set if reading and/or writing is done from one thread.
- receive_own_messages (bool) – If messages transmitted should also be received back. Only works if single_handle is also False. If you want to receive messages from other applications on the same computer, set this to True or set single_handle to True.
- 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.
Turn on or off flashing of the device’s LED for physical identification purposes.
Wipeout the transmit buffer on the Kvaser.
Transmit a message to the CAN bus.
Override this method to enable the transmit path.
- msg (can.Message) – A message object.
- timeout (float or None) – 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. None blocks indefinitly.
can.CanError – if the message could not be sent
Called to carry out any interface specific cleanup required in shutting down a bus.
Bus object with a physical CAN Bus can be operated in two
single_handle mode with one shared bus handle used for both reading and
writing to the CAN bus, or with two separate bus handles.
Two separate handles are needed if receiving and sending messages are done in
different threads (see Kvaser documentation).
Any objects inheriting from Bus should not directly use the interface handle(/s).
The Kvaser driver and hardware only supports setting one filter per handle.
If one filter is requested, this is will be handled by the Kvaser driver.
If more than one filter is needed, these will be handled in Python code
recv method. If a message does not match any of the filters,
recv() will return None.
This section contains Kvaser driver specific methods.
Retrieves the bus statistics.
Use like so:
>>> stats = bus.get_stats() >>> print(stats) std_data: 0, std_remote: 0, ext_data: 0, ext_remote: 0, err_frame: 0, bus_load: 0.0%, overruns: 0
Returns: bus statistics. Return type: can.interfaces.kvaser.structures.BusStatistics