Connect your CANable to your computer's USB port and make sure the Boot jumper is not in the "Boot" position. Drivers are not required on Linux and Mac, but Windows users will need to install an .inf file.
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.
sudo slcand -o -c -s0 /dev/serial/by-id/*CANtact*-if00 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.
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.
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 compatible with Windows or Mac (as far as I know). However, the CANable appears as a CAN interface natively in Linux and performs very well under high bus load conditions.
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.
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.