SocketCAN
SocketCAN is the Linux kernel’s way of exposing a CAN bus, and this transport is a client of it. It is one of the two concrete CAN transports; the other is the in-memory Virtual CAN.
Because it goes through the kernel, PLC4X does not handle bus access, arbitration or timing - the
CAN layer below does. It has been used successfully with the vcan and gs_usb drivers.
| Linux only. SocketCAN has its own frame representation - fixed-length frames (a CAN 2.0A frame always takes 16 bytes) and a 29-bit identifier field where a standard CAN frame uses 11, with the remaining 3 bits carrying flags. |
Transport syntax
{name of the CAN interface}
canopen:can-socketcan://can0
canopen:can-socketcan://vcan0?can-socketcan.read-timeout-ms=500
The interface can also be named with the can-socketcan.interface-name option instead; the
address segment wins if both name one. One of the two has to be given.
Name |
Type |
Default Value |
Required |
Description |
Name |
SocketCAN |
|||
Code |
|
|||
Maven Dependency |
<dependency> <groupId>org.apache.plc4x</groupId> <artifactId>plc4j-transports-can-socketcan</artifactId> <version>1.0.0</version> </dependency> |
|||
Config options: |
||||
|
STRING |
Linux CAN interface name (e.g., "can0", "vcan0"). Alternative to naming the interface in the address segment of the connection string, which takes precedence. |
||
|
BOOLEAN |
false |
Share CAN socket across multiple transport instances on the same interface |
|
|
INT |
1000 |
Read timeout in milliseconds for blocking reads on the CAN socket |
|
|
STRING |
Comma-separated list of accepted CAN IDs (decimal or 0x hex). Empty means accept all. |
||
|
INT |
-1 |
Start of accepted CAN ID range (inclusive). -1 means no range filtering. |
|
|
INT |
-1 |
End of accepted CAN ID range (inclusive). -1 means no range filtering. |
|