Determine if you need to use the CANable's onboard termination. CAN bus requires a 120 Ohm terminating resistor on each end of the bus for proper operation, and a completely unterminated bus will not function at all. The CANable has a built in terminator you can use, but if your bus is already terminated make sure to disable onboard termination.
The CANable Pro has one jumper to control termination and a button to enter boot mode
The original CANable has two jumpers: "Boot" and "Term".
Connect the CANH, CANL, and GND pins of your CANable to your target CAN bus. You must connect ground for the CAN bus to function properly.
Do not connect the 5v output of the original CANable unless you need to power a target with 5v: this is an output only!
Make sure the Boot jumper is not in the "Boot" position, and then connect your CANable to your computer's USB port with a micro USB cable. Make sure you're using a good USB data cable and not a charge-only cable.
Linux and Mac
Drivers are not required on Linux and Mac. The CANable will appear as a USB CDC device: /dev/ttyACMX or /dev/ttyUSBX on Linux or /dev/cu.usbmodemXXXX on on Mac.
Windows Windows users need to install an .inf file. You can download a zip of the driver, right-click on the .inf file, and click install. You may need to open your device manager, find the unknown cantact device, choose Update Driver and select the .inf file.1
The CANable provides a socketCAN-compatible interface that can be brought up with slcand. This allows you to use all standard Linux CAN utilities like candump, cansniffer, and even wireshark. Bus speed is specified with the "-s" parameter where:
Just run slcand with the proper arguments for your bus speed, and a new CAN device should show up on your system. Don't forget to bring the interface up with ifconfig after running slcand! Now you can use any of the standard Linux CAN utilities to interact with the bus. Make sure that you specify the right TTY port, which you can check with the dmesg command after plugging in your CANable.
sudo slcand -o -c -s0 /dev/ttyACM0 can0 sudo ifconfig can0 up cansend can0 999#DEADBEEF # Send a frame to 0x999 with payload 0xdeadbeef candump can0 # Show all traffic received by can0 canbusload can0 500000 # Calculate bus loading percentage on can0 cansniffer can0 # Display top-style view of can traffic cangen can0 -D 11223344DEADBEEF -L 8 # Generate fixed-data CAN messages
cantact-app is the easiest way to get up and running with your CANable on Windows and Mac.
cantact-app is a Java program for viewing real-time CAN bus traffic and sending CAN packets. This tool connects directly to the virtual serial port of the CANable (or CANtact) device, and doesn't require any other drivers. Just download the latest release, connect to your CANable, and traffic should show up shortly.
Note: cantact-app runs on Linux but currently isn't able to discover serial ports.
On Windows you can use the Cangaroo application to talk with your CANable running the alternative candlelight firmware. It supports receive and transmit of both standard and extended CAN. DBC file parsing is supported as well, but is still in beta. Cangaroo is also available for Linux if you compile it yourself.
CANard is a python library that allows you to easily communicate on the CAN bus from Python. The library supports connecting to CANable/CANtact devices directly with PySerial, so it works well on both Windows and Linux systems without a kernel CAN module.
I have a fork of CANard available that fixes a couple of issues and is compatible with both Python 2 and Python 3.
CANard also supports native socketcan devices such as a CANtact/CANable initialized with slcand.
Getting started is quite simple:
"""Connect to CANable; print and echo any received frames""" from canard import can from canard.hw import cantact dev = cantact.CantactDev("/dev/ttyACM0") # Connect to CANable that enumerated as ttyACM0 dev.set_bitrate(1000000) # Set the bitrate to a 1Mbaud dev.start() # Go on the bus count = 0 while True: count += 1 frame = dev.recv() # Receive a CAN frame dev.send(frame) # Echo the CAN frame back out on the bus print(str(count) + ": " + str(frame)) # Print out the received frame
There is a port of the candleLight USB to CAN firmware for CANable. The port works very well under Linux using the gs_usb driver. This firmware does not use slcan, so it is not interchangable with the stock firmware. However, the CANable appears as a CAN interface natively in Linux, works with the Cangaroo app (below) on Windows, and performs very well under high bus load conditions.
Note that Linux kernels <=4.9 had a bug in the gs_usb driver. I created a patch which is now in the mainline kernel, but if you need to compile the standalone module, you can use this custom version.
With the candlelight firmware, simply plug in the CANable and the device will enumerate as can0. Set the baud rate and bring the interface up with the following command, and you're good to go!
ip link set can0 up type can bitrate 500000
The as-shipped build of the slcan and candleLight firmware are available for download here.
Reprogramming your CANable is fairly easy. First, move the "boot" jumper into the boot position as labelled on the PCB and then plug it into your computer.
You can easily update your CANable by browsing to the CANable updater site with Google Chrome. Follow the instructions to easily reflash your CANable.
ST DFU Tool
dfu-util on Linux and Mac
If you're on Linux or Mac, install dfu-util from your distro's package manager or from brew on OSX. Run the following command to flash your device:
sudo dfu-util -d 0483:df11 -c 1 -i 0 -a 0 -s 0x08000000 -D canable-firmware.bin
After flashing the firmware, return the boot jumper to its original position and plug/unplug your device. You are now running new firmware!
If you have any problems getting your CANable up and running or if you have any questions, feel free to send me an email.