PCAN Basic API

Warning

This PCAN documentation is a work in progress. Feedback and revisions are most welcome!

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

Configuration

An example can.ini file for windows 7:

[default]
interface = pcan
channel = PCAN_USBBUS1

Bus

class can.interfaces.pcan.PcanBus(channel, state=<property object>, *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’
  • state (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) – 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.

shutdown()[source]

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

status()[source]

Query the PCAN bus status.

Returns:The status code. See values in pcan_constants.py
status_is_ok()[source]

Convenience method to check that the bus status is OK