Kvaser Leaf Light v2 HS USB to CAN Bus Interface
Method 1: Set up to use CANLIB (library from Kvaser, if you want to use socketcan, skip to method 2)
- The download page for all necessary files can be accessed here: https://www.kvaser.com/downloads-kvaser/
- Install drivers according to this tutorial after download the Kvaser LINUX Driver and SDK file. I tested it on Ubuntu 16.04, and it’s still working.
3. To use Kvaser with Python, you need canlib library. To install canlib for python on linux, follow the instruction here after download the latest Python Module from the Download page.
4. More detail on canlib codes: https://github.com/Kvaser/canlib-samples
Method 2: Setup to use with Socketcan
This method is a lot more simple, there is no need for any driver set up.
- Install can-ultils (for socketcan):
sudo apt-get install can-utils
- Connect Kvaser to PC
- Enable CAN, in this example, I use 500000. Change this bitrate to your required speed:
sudo modprobe can
sudo modprobe can_raw
sudo ip link set can0 type can bitrate 5000000
sudo ip link set up can0
- Your Kvaser can port is enable with name
ifconfig -aand can0 should show up. Connect Kvaser to another CAN device that is sending out data, then on terminal enter
Note: After PC restarts, you will have to re-run these commands if you want to enable Socketcan for Kvaser device again. To save time, you can save these in a bash script and load from the bash script.
- To use Socketcan in Python codes, check out Python-can
Refer to the resource below to use can-ultils on termial to test send and receive can messages on terminal. If you don’t have another CAN device to test send and receive, you can also create
virtual can channel to do the work.
My first time working on CAN bus. Your instruction would work for mhydra device as well?
I’m not quite sure. My set up was on Kvaser Leaf device.
If mhydra is CAN hardware, you need to verify Ubuntu installs the drivers from them or you have to build and install the drivers manually.