can-utils | Linux-CAN / SocketCAN user space applications | Automation library
kandi X-RAY | can-utils Summary
kandi X-RAY | can-utils Summary
Linux-CAN / SocketCAN user space applications
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of can-utils
can-utils Key Features
can-utils Examples and Code Snippets
Community Discussions
Trending Discussions on can-utils
QUESTION
I'm writing a CAN logger program. The way I log the data is similar to the way the candump
-tool is doing it when invoking candump
like candump any
:
https://github.com/linux-can/can-utils/blob/master/candump.c
candump any
makes candump
bind to any device, i.e. addr.can_ifindex = 0;
then it uses recvmsg
to obtain a CAN frame, then it gets the on the struct msghdr msg;
attached timestamp to write it into the log file or onto the screen.
My question here is, does the kernel ensures that the following assert
is always valid?
ANSWER
Answered 2020-Oct-23 at 18:14The short answer is yes, unless your driver does something very weird. CAN uses the same netif subsystem that other network devices use. There are a few ways that the SKB gets a timestamp.
HW Timestamps:
If your driver uses hardware time stamps, then time stamps are based on whatever the hardware provides.
SW Timestamps:
If netdev_tstamp_prequeue is enabled then a timestamp is soon after your driver submits the skb to netif_receive_skb
https://elixir.bootlin.com/linux/v4.14.202/source/net/core/dev.c#L4554
If netdev_tstamp_prequeue is not enabled then the timestamp is applied after a bit more processing but still in the same NAPI receive thread.
https://elixir.bootlin.com/linux/v4.14.202/source/net/core/dev.c#L4352
Here is the fuzzy part:
There are special modes (RSP/RFP) that allow the kernel to load balance skb processing with SMP. Instead of processing the skb in the napi receive thread, the kernel puts the skb in a per cpu queue. Now if netdev_tstamp_prequeue is not enabled, the timestamp is added when it comes off the per cpu queue some time later. However, the documentation says the receive ordering is not modified so time stamps should remain in order as well.
QUESTION
I am trying to use CAN J1939 standard on an embedded Linux system running Ubuntu 18.04, kernel 5.4.0-52-generic.
This elinux page indicates that j1939.h "got in the mainline kernel since v5.4". And kernel.org's documentation for j1939 implies that it is in the main kernel.
Lastly, I do have can-utils installed.
When I compile a cpp file with #include
, I get a no such file or directory
error.
I've gone through linux/can
directory to confirm and j1939.h
is not there. Is there any reason why my v5.4 kernel wouldn't have j1939.h
? How can I best use j1939.h
in my program?
ANSWER
Answered 2020-Oct-28 at 21:55You need development packages for these headers. You can search for which package you need on the Ubuntu Packages site. I.e. in this case packages containing j1939.h. You're probably looking for linux-libc-dev
or linux-headers-5.4.0-26
.
QUESTION
Operating System: Rasbian
I am trying to follow this https://www.npmjs.com/package/@canboat/canboatjsto to use the following command : candump can0 | candumpanalyzer.
However, after trying all these commands:
ANSWER
Answered 2020-Aug-15 at 10:35If you go to your node_modules directory and run the following command:
find -name "candump*"
You will get the following result:
QUESTION
I'm trying to build an application using the Yocto SDK. The compilation worked well, but when it comes to linking, following linker errors occurs:
...ANSWER
Answered 2020-Jul-15 at 16:39This is an issue in the upstream glibc sources: The ARM assembler version of setcontext
assumes that all PIC code is dynamic linked, which means that static linking fails if glibc was built in static PIE mode (because that actives PIC without providing the dynamic linker code).
You either need to build glibc without static PIE support (I did not even know this was a supported configuration for 32-bit ARM), or replace the PIC
macro with SHARED
in sysdeps/unix/sysv/linux/arm/setcontext.S
.
QUESTION
I'm writing a CAN driver and want to set up some tests for it. I have a simple echo program (accepts a can frame and echoes it back). I'm using can-utils
for this and would use cangen
to generate random data, log it, then make sure the frames were received and echoed back.
Everything seems to be working but there is some annoying behavior from candump. When sending non-FD frames, it does not print a leading zero for the DLC. See here (messages are sent, and then the echoed message - yes I'm aware it shouldn't use the same node id to echo back this is just for testing purposes):
...ANSWER
Answered 2019-Aug-26 at 08:11No this is intentional to distinguish Classic CAN [x] from CAN FD [xx] frames in the human readable output. It is not the question whether the DLC (4 bit on the physical layer) to be the same, as we always operate with the real length information and not with the DLC on socket level. And when both are 5 bytes you wont be able to distinguish them.
Btw. your CAN driver seems to have an issue, when the echo'ed frame is always a CAN FD type - no matter what has been sent (Classic CAN / CAN FD) ...
QUESTION
I am having trouble getting CAN working on my beaglebone green using can-utils. I have a bitscope hooked up to the CAN pins but I'm not seeing any output..
Beaglebone version: ...ANSWER
Answered 2019-Aug-05 at 01:40Thanks to Benoît for the suggestion:
I had to terminate pins p9.24 and p9.26 with a 120 Ohm resistor In order to get any messages to display on my bitscope.
If the canbus is not terminated, the can interface will fail and any messages transmits will not work. The can interface will need to be set down and up again to be able to try sending another message.
QUESTION
I have two nodes connected to one CAN bus. The first node is a black-box, controlled by some real-time hardware. The second node is a Linux machine with attached PEAK-USB CAN controller:
...ANSWER
Answered 2019-Jul-19 at 08:32From the documentation subsection 4.1.2 RAW socket option CAN_RAW_ERR_FILTER, it says that the errors are by default not activated which is why the lost arbitration field in ip
was not increasing.
In order to toggle on all the errors, you need to add those two lines :
QUESTION
I am trying to send 29bit EFF CAN messages over socket can, but for some reason it sends them with 11bit identifier cutting off 5 bytes from ID. Using loopback mode, through candump i can see that messages are received as 11bit.
I get no errors, nothing, thats why i am confused
I am using raspberry pi 3b+ if that makes any difference. And Can-utils library.
...ANSWER
Answered 2019-Apr-03 at 16:11You need to add correct flag after setting can_id:
QUESTION
I am making a can-bus network that will survey some sensors to gather data in order to have better understanding of an environment that we want to analyse and control. In order to do so we use candump to monitor traffic and can send to sen information (from CAN-BUS files that can be find in this address: https://github.com/linux-can/can-utils.git). I modified some of the codes and they compile well, now what I want to do is to make a parent code that can orchestrate this C programs in order to control the environment. I want to use python or c++ to do this.
Example Algorithm
...ANSWER
Answered 2019-Jan-25 at 13:01You can use std::system
to run the other programs.
Something like:
QUESTION
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 clarification, I am writing software to communicate over CAN which I am already capable of, but to facilitate the actual data gathering and further development, I need two can enabled devices to communicate with each other. While a simple solution in the real world, solved by physically connecting devices together, I need a programmatic solution that will work on the computer.
...ANSWER
Answered 2019-Jan-22 at 08:58Add the can gateway kernel module:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install can-utils
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page