Setting up the host for CANopen
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
The connector reads and writes the bus through a SocketCAN interface of the device. You prepare this interface on the host (the device), outside logiccloud. The connector never changes the bit rate or the link state, because that needs the capability CAP_NET_ADMIN.
Which devices support CANopen
Section titled “Which devices support CANopen”| Package type | What the connector needs | CANopen |
|---|---|---|
| Linux installation script (docker or podman) | Host network, no extra capability | Yes, with linux-setup.sh --network host. With the default bridge network the container does not see can0. |
| Plain Linux (no container) | Host network namespace, no capability | Yes. Unconfirmed: bind and send on a real interface, until the hardware test (LC-2307). |
| FLECS | Host network for the instance | Unconfirmed |
| PLCnext | Host network namespace of the controller | Unconfirmed on a device |
| uc-addon (u-OS) | Host network option of the add-on | Unconfirmed |
| Standard LXC | can0 as a phys interface, or the host namespace | Unconfirmed. The operator changes the LXC configuration. |
| insys LXC | The shipped configuration uses veth on br0 | No, until the configuration uses a phys interface |
| periMICA | arm/v7 | No. There is no arm/v7 binary. |
| ctrlX snap | Strict confinement | Unconfirmed. Access to the CAN socket is not tested. |
Cloud vPLC (vPlcType) | No CAN interface | No. The installer skips the connector and logs a WARNING. |
| Kubernetes vPLC | No CAN interface | No. Same as the cloud vPLC. |
Steps on the host
Section titled “Steps on the host”Goal: a SocketCAN interface that is UP, runs at the bit rate of the bus and is visible to the connector.
Why a person is needed: the kernel configuration needs root, and only you know the bit rate of your bus.
Prerequisites:
- Root access (or
sudo) on the device. - A CAN adapter with a SocketCAN driver in the kernel.
- The bit rate of the bus in bit/s, for example 250000. It must equal the Bit rate of the connection (250 kbit/s is 250000 bit/s).
- Check:
ip -details link show type canlists your interface, for examplecan0.
Steps:
-
Load the kernel modules:
sudo modprobe can && sudo modprobe can_raw. Expected: no output. Check withlsmod | grep '^can': the linescan_rawandcanappear. -
Set the bit rate:
sudo ip link set can0 down; sudo ip link set can0 type can bitrate 250000. Expected: no output. -
Bring the link up:
sudo ip link set can0 up. Expected: no output. -
Check:
ip -details link show can0. Expected: the output containsstate UPandbitrate 250000. -
Make it permanent, so that the link is up after a reboot. Use one of these ways:
-
systemd-networkd: create
/etc/systemd/network/80-can0.networkwith this content, then runsudo systemctl enable --now systemd-networkd.[Match]Name=can0[CAN]BitRate=250K -
ifupdown: add this to
/etc/network/interfaces:auto can0iface can0 inet manualpre-up ip link set can0 type can bitrate 250000up ip link set can0 updown ip link set can0 down
Also load the modules at boot: write the two lines
canandcan_rawto/etc/modules-load.d/can.conf. -
-
Containers and LXC:
- Linux installation script: run
sudo bash linux-setup.sh --network host reinstall-container. The container keeps its data. Expected:Container reinstalled and running. Then check that the container sees the interface:sudo docker exec logiccloud ls /sys/class/net(with podman:sudo podman exec logiccloud ls /sys/class/net). Expected:can0is in the list. See Layer 2 on a device installed with the Linux script for the effects of the host network (ports 8080, 42010 and 42011 are used directly; only one logiccloud container per device). - LXC: set
lxc.net.0.type = physandlxc.net.0.link = can0in the container configuration, then restart the container.
- Linux installation script: run
If a step fails:
RTNETLINK answers: Operation not supported: the kernel has no driver for the adapter. Install the driver or use another adapter.RTNETLINK answers: Device or resource busy: the link is already up. Runsudo ip link set can0 downfirst, then repeat step 2.- The interface is missing in
ip link: the adapter is not detected. Checkdmesg | tail -n 30for the driver messages.
Final check: after you deploy a runtime with a CANopen connection, ps aux | grep canopen-connector on the device shows a process with canopen-connector --config .../canopen.json. Without a runtime, check that ip -details link show can0 shows state UP and the bit rate.
What to report if you ask for help: the output of ip -details link show can0, the package type, and the log of the canopen-connector process.
Virtual interface for tests
Section titled “Virtual interface for tests”You can test a connection without hardware on a virtual CAN interface:
sudo modprobe vcansudo ip link add dev vcan0 type vcansudo ip link set vcan0 up
Enter vcan0 as CAN interface. A vcan interface has no bit rate, and the connector accepts it for any Bit rate.