Download presentation
Presentation is loading. Please wait.
1
A quick look at SocketCAN
Piotr Nikiel, ATLAS Central DCS 25 Feb 2014
2
CANopen Readout Chain OPC UA Server CAN Bus File System
SocketCAN Configurable hardware interface OPC UA Server Vendor SocketCAN driver module UNIX Sockets CAN Hardware Interface Vendor-specific Win64/Linux Driver Vendor API CANOpen XML OPC UA TCP/IP XML Configuration File File System WinCC OA System OPC UA Client fwElmb CAN Bus WCCOA XML
3
User’s perspective You plug a SocketCAN device into a computer
Kernel loads a corresponding device driver Standard Linux kernel has ~10 CAN device drivers (e.g. Kvaser) ATLAS DCS provides production RPM for SysTec CAN network interface shows up (e.g. can0) Interface can be opened by any application e.g. OPC UA CANopen server Standard Linux tools: ifconfig, tcpdump, ip, … CAN utils: candump, cansend, cangen, …
4
Operating System’s perspective
SocketCAN is a subclass of standard Network Interface, like Ethernet or Wi-Fi So it inherits abundance of features and tools ifconfig: ip link set can0 type can bitrate tcpdump can0 Queues & buffers configuration sysfs, udev, … everything -bash-4.1$ ifconfig can Link encap:UNSPEC HWaddr 0E-58-F UP RUNNING NOARP MTU:16 Metric:1
5
Programmer’s perspective
The traditional Sockets API – stable, mature, reliable and proven for 40+ years No specific libraries, headers, frameworks needed 100% compatibility among various vendors/products Natural richness of Unix Sockets comes at no expense: Blocking/nonblocking calls select(), poll(), … Native error support (strerror(), perror(), …) Convenience library for interface setup: libsocketcan
6
Programming example – Query State of an ELMB
Send NodeGuard request CAN frame can_frame f; f.can_id = (0x700 + elmbId) | CAN_RTR_FRAME; f.can_dlc = 0; write (sock, (void*) &f, sizeof f); Receive CAN frame containing the ELMB’s response read (sock, (void*) &f, sizeof f); printf (“ELMB state: %u\n”, f.data[0]);
7
SysTec RPM Our branch of SysTec Driver: Has some local fixes
Has some improvements for configuration Has nice status tools: Is packaged in a production ready RPM ~]$ /opt/systec_can/systec_status.py Port State | [green led] [red led] | can0 OK(certain) | can1 OK(certain) | can2 BAD(UNCERTAIN) | ?blink? blink can3 OK(certain) | can4 BAD(UNCERTAIN) | ?blink? blink can5 BAD(UNCERTAIN) | ?blink? blink can6 Port closed(no info) | ? can7 Port closed(no info) | ?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.