8devices Korlan USB2CAN User Manual - Page 9

Browse online or download pdf User Manual for USB Interfaces 8devices Korlan USB2CAN. 8devices Korlan USB2CAN 15 pages. High quality isolated usb to can interface
Also for 8devices Korlan USB2CAN: User Manual (17 pages)

8devices Korlan USB2CAN User Manual
sudo apt-get install can-utils
Send byte of information (1122334455667788) to can device with id = "1f334455":
cansend can0 1f334455#1122334455667788
Receive everything on the can1 interface:
candump can1

3.3 Python programming examples for Linux

Python programming examples rely on the python-can module and socket can drivers.  Before running
code examples, you shall bring the CAN interface to the UP state using the command:
sudo ip link set can0 up type can bitrate 125000 sample-point 0.875
Example receive_all.py - receives and prints all messages on the screen until Ctr-C is pressed.
import can
bus = can.Bus(channel='can0', interface='socketcan', bitrate=1000000)
for i in range(10):
msg = can.Message(arbitration_id=0xc0ffee, data=[i,2,3,4,5,6,7,8],
is_extended_id=True)
bus.send(msg)
Example send.py - sends 10 CAN messages to the bus.
import can
bus = can.Bus(channel='can0', interface='socketcan', bitrate=1000000)
for i in range(10):
msg = can.Message(arbitration_id=0xc0ffee, data=[i,2,3,4,5,6,7,8],
is_extended_id=True)
bus.send(msg)
KORLAN USB2CAN
USER GUIDE
9