SocketCAN is a Linux socket based implementation for Controller Area Network (CAN) protocol.
Questions tagged [socketcan]
155 questions
12
votes
1 answer
write: no buffer space available socket-can/linux-can
I'm running a program with two CAN channels (using TowerTech CAN Cape TT3201).
The two channels are can0 (500k) and can1 (125k). The can0 channels works perfectly but can1 runs a write:No buffer space available error.
I'm using…

avelampudi
- 316
- 2
- 6
- 16
11
votes
2 answers
Heavily confused by candump (SocketCAN) ID filtering feature
In a nutshell, I want candump to show me ONLY frames with IDs 0x00200200 or 0x255.
So I do this:
candump can0,00200200:0,255:0
But this gives ALL frames, and each frame is shown twice. i.e. the output of:
cansend can0 256#112233
would be…

Erik Nyquist
- 1,267
- 2
- 12
- 26
8
votes
1 answer
Socket-CAN virtual bus
How can I create several virtual sockets and link them together to create a virtual bus?
I want to simulate an application in which many nodes communicate to each other via CAN.

Shabbir Hussain
- 2,600
- 2
- 17
- 25
8
votes
3 answers
Canplayer won't replay candump files
I'm trying to use canplayer to replay some candump files, with no success. When I try to run the canplayer it just executes and returns, giving me no clue of what is happening.
What I've tried up to now:
Setup 1
Set up a vcan interface
Sent…

Arthur Nunes
- 6,718
- 7
- 33
- 46
6
votes
2 answers
SocketCAN: Filtering of frames with certain CAN IDs not working
I'm trying to filter CAN frames with certain IDs as described here: https://landlock.io/linux-doc/landlock-v8/networking/can.html#raw-protocol-sockets-with-can-filters-sock-raw
Part of my code:
struct can_filter rfilter[4];
if ((s = socket(PF_CAN,…

ci7i2en4
- 834
- 1
- 13
- 27
5
votes
2 answers
How to connect two VCAN ports in Linux?
I have set up two vcan devices and I want to treat them as if they were connected together. I want to be able to use can-utils candump to listen on one line, and send can messages from the other. How can I do that without a physical device?
For…

viduwoy
- 113
- 12
5
votes
1 answer
How check bus state in socketcan
I am using flexcan driver on an embedded linux and I have C program controling can messages. In my C program I need to check the state of the can bus e.g. buss-off or error-active. I can use linux command like
ip -details -statistics link show can0…

PHA
- 1,588
- 5
- 18
- 37
5
votes
2 answers
Get CAN bitrate
I want to read the currently configured CAN bitrate of my socketcan socket in C++.
I can see the bitrate with ip -det link show can0:
9: can0: mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
link/can …

Laurenz
- 1,810
- 12
- 25
5
votes
2 answers
CAN FD support for Virtual CAN (vcan) on SocketCAN
I have been using SocketCAN and especially the Virtual CAN vcan for quite a while now. However, I never used CAN FD (Flexible Datarate) so far.
Well, I tried it this morning using the can-utils:
cansend vcan0 123##122
However, I got the response…

MAW
- 121
- 1
- 5
4
votes
0 answers
How to remove a CAN message filter from a CAN_RAW socket?
SocketCAN's description says about adding some filters to a socket:
struct can_filter rfilter[2];
rfilter[0].can_id = 0x123;
rfilter[0].can_mask = CAN_SFF_MASK;
rfilter[1].can_id = 0x200;
rfilter[1].can_mask = 0x700;
setsockopt(s, SOL_CAN_RAW,…

Greenberet
- 490
- 1
- 5
- 18
4
votes
2 answers
Send one-shot message using SocketCAN
Is it possible to send a "one-shot" CAN message using SocketCAN? This is basically a message that does not expect an acknowledgement back from the receiver. The protocol allows this ACK bit not to be set.

ilya1725
- 4,496
- 7
- 43
- 68
4
votes
1 answer
Writing custom CAN protocol with SocketCAN
I'm trying to write a slightly modified CAN protocol for SocketCAN. The SocketCAN documentation has a short section about this:
5.3 writing own CAN protocol modules
To implement a new protocol in the protocol family PF_CAN a new
protocol has to be…

RuthSB
- 49
- 3
3
votes
2 answers
Detecting CAN bus errors under socketCAN linux driver
Our products are using a well known CANopen stack, which uses socketCAN, on an embedded Beaglebone Black based system running under Ubuntu 14.04 LTS. But for some reason, even though the stack we're using will detect when the CAN bus goes into a…

Chris Galas
- 43
- 1
- 6
3
votes
2 answers
Setting SocketCAN bitrate programmatically
I'm using SocketCAN on my system. Is there a way to set the CAN interface bitrate programmatically and not from the command line. An example would be helpful.
Thank you.

ilya1725
- 4,496
- 7
- 43
- 68
3
votes
2 answers
No active virtual can messages when using candump (SocketCAN)
I am playing with can-utils package, trying to run a virtual can device. Everything seems to work fine except there is no active messages. Candump and cansniffer works, because I send a message manually and it shows up.
Am I doing something…

stardust
- 343
- 3
- 17