PCAN Basic API

Interface to Peak-System’s PCAN-Basic API.

Windows driver: https://www.peak-system.com/Downloads.76.0.html?&L=1

Linux driver: https://www.peak-system.com/fileadmin/media/linux/index.htm#download and https://www.peak-system.com/Downloads.76.0.html?&L=1 (PCAN-Basic API (Linux))

Mac driver: http://www.mac-can.com

Configuration

Here is an example configuration file for using PCAN-USB:

[default]
interface = pcan
channel = PCAN_USBBUS1
state = can.bus.BusState.PASSIVE
bitrate = 500000

channel: (default PCAN_USBBUS1) CAN interface name

state: (default can.bus.BusState.ACTIVE) BusState of the channel

bitrate: (default 500000) Channel bitrate

Valid channel values:

PCAN_ISABUSx
PCAN_DNGBUSx
PCAN_PCIBUSx
PCAN_USBBUSx
PCAN_PCCBUSx
PCAN_LANBUSx

Where x should be replaced with the desired channel number starting at 1.

Linux installation

Kernels >= 3.4 supports the PCAN adapters natively via SocketCAN, refer to: PCAN.

Bus

class can.interfaces.pcan.PcanBus(channel='PCAN_USBBUS1', state=<property object>, bitrate=500000, *args, **kwargs)[source]

Bases: can.bus.BusABC

A PCAN USB interface to CAN.

On top of the usual Bus methods provided, the PCAN interface includes the flash() and status() methods.

Parameters:
  • channel (str) – The can interface name. An example would be ‘PCAN_USBBUS1’ Default is ‘PCAN_USBBUS1’
  • state (can.bus.BusState) – BusState of the channel. Default is ACTIVE
  • bitrate (int) – Bitrate of channel in bit/s. Default is 500 kbit/s.
flash(flash)[source]

Turn on or off flashing of the device’s LED for physical identification purposes.

reset()[source]

Command the PCAN driver to reset the bus after an error.

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 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.
Raises:

can.CanError – if the message could not be sent

shutdown()[source]

Called to carry out any interface specific cleanup required in shutting down a bus.

state

Return the current state of the hardware

Returns:ACTIVE, PASSIVE or ERROR
Return type:NamedTuple
status()[source]

Query the PCAN bus status.

Return type:int
Returns:The status code. See values in basic.PCAN_ERROR_
status_is_ok()[source]

Convenience method to check that the bus status is OK