for the CAN0 CAN1 is tx2 can , if I have a Kvaser usb can, what device name should be?
such as ip link can3 type can bitrate 250000? Thanks.
Hi,
We don’t have experience of using the device. The device name should be set in driver by calling dev_set_name(). You may check if kvaser has the driver code open source and try to grep dev_set_name in the code.
Other users may know about it and share the information.
Assuming you want to use the SocketCAN modules with your Kvaser USB interface, the modules have to get built and installed.
So, cretae a MakeFile with the following content:
.PHONY: all clean install uninstall
KERNEL_PATH ?= /lib/modules/`uname -r`
KDIR ?= $(KERNEL_PATH)/build
MODULE_NAME = kvaser_usb
SRC_REPO_URL = https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/
SRC_DRIVERS_DIR = drivers
SRC_MODULE_DIR = $(SRC_DRIVERS_DIR)/net/can/usb/$(MODULE_NAME)
SRC_FILES = kvaser_usb.h kvaser_usb_core.c kvaser_usb_hydra.c kvaser_usb_leaf.c Makefile
KVASER_SRC_DIR = `pwd`/$(SRC_MODULE_DIR)
all: $(addprefix $(SRC_MODULE_DIR)/, $(SRC_FILES))
make CONFIG_CAN_KVASER_USB=m -C $(KDIR) M=$(KVASER_SRC_DIR)
$(addprefix $(SRC_MODULE_DIR)/, $(SRC_FILES)):
wget --directory-prefix=$(SRC_MODULE_DIR) $(SRC_REPO_URL)/$@
install:
make -C $(KDIR) M=$(KVASER_SRC_DIR) modules_install
depmod -a
uninstall:
rm $(addprefix $(KERNEL_PATH)/extra/$(MODULE_NAME), .ko .ko.gz .ko.xz) 2>/dev/null || true
rmmod $(MODULE_NAME) 2>/dev/null || true
depmod -a
clean:
rm -rf $(SRC_DRIVERS_DIR)
To build the module run:
$ make -f MakeFile
To install the module run:
$ sudo make -f MakeFile install
To uninstall (and unload) the module, execute:
$ sudo make -f MakeFile uninstall
You may contact the Kvaser’s support team (support@kvaser.com) if you encountered any issues…
Then, by running ‘ip a’, a list of the installed “network” devices will be returned.
A CAN interface is being listed like:
10: can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN group default qlen 10
link/can
meaning that I may run
$ sudo ip link set can0 type can bitrate 250000
to set the bitrate of my can0 interface to 250Kb/s