CAN Link¶
A CAN link is used to send/recv raw CAN frames to a CAN bus. Combine a CanLink and CanCodec to interact with named messages and signals on a CAN bus.
See CanCodec.
Example - virtual¶
from zeloscloud.links.can_link import CanLink
config = {
"channel": "vcan0",
"interface": "virtual",
}
with CanLink(name="can-link", config=config) as link:
message = can.Message()
link.send(message)
Example - socketcan¶
from zeloscloud.links.can_link import CanLink
config = {
"channel": "can0",
"interface": "socketcan",
}
with CanLink(name="can-link", config=config) as link:
message = can.Message()
link.send(message)
Example - pcan¶
from zeloscloud.links.can_link import CanLink
config = {
"channel": "PCAN_USBBUS1",
"interface": "pcan",
"bitrate": 500000,
}
with CanLink(name="can-link", config=config) as link:
message = can.Message()
link.send(message)
PCAN Driver Install¶
To use a PCAN dongle on Windows a PEAK provided driver *.dll is required.
Ensure that all PCAN Basic drivers are selected.
Download the installer here: PCAN-Basic API Download


Example - gs_usb¶
from gsu_usb.gs_usb import GsUsb
from zeloscloud.links.can_link import CanLink
config = {
"channel": GsUsb.scan()[0],
"interface": "gs_usb",
"bitrate": 500000,
"index": 0,
}
with CanLink(name="can-link", config=config) as link:
message = can.Message()
link.send(message)
Example - virtual - loop¶
from zeloscloud.links.can_link import CanLink
config = {
"channel": "vcan0",
"interface": "virtual",
}
with Task(name="task") as task, \
CanLink(name="can-link", config=config, loop=task.loop) as link:
message = can.Message()
link.send(message)
API Reference¶
See zeloscloud.links.can_link.CanLink in the API Reference.