From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Marc Kleine-Budde <mkl@pengutronix.de>, David Boles <me@davidbol.es>
Cc: Tom Evans <thomasaevans@optusnet.com.au>,
linux-can@vger.kernel.org, s.grosjean@peak-system.com
Subject: Re: PCAN and SocketCAN Questions
Date: Fri, 12 Aug 2022 15:00:58 +0200 [thread overview]
Message-ID: <86dffcf2-e79d-e32a-bdcf-404ee8f7dd22@hartkopp.net> (raw)
In-Reply-To: <20220812123749.zqqn4kico5zai5ql@pengutronix.de>
Hello David,
On 12.08.22 14:37, Marc Kleine-Budde wrote:
> On 11.08.2022 13:17:47, David Boles wrote:
>> Unfortunately it seems like this is happening at the layer of
>> individual sockets. Candump was already printing out messages that I
>> was "losing", and adding the -d flag doesn't affect its printout
>> (presumably since from its perspective, they haven't been dropped).
>
> See the code that the "-d" command line options activates :)
>
> | https://github.com/linux-can/can-utils/blob/master/candump.c#L650
>
> ... and add this to your app.
>
>>> Run your program at a lower NICE value
>
> You can try to receive several CAN frames with recvmmsg().
>
>> Good idea!
>>
>>> Make the queue as big as you can.
>
> I the socket drops CAN frames, this means there's not enough CPU time
> for your app to receive them all. You should look at your system and
> find out where the CPU time is lost.
All these measures seem to be the last solution when nothing else helped.
Can you probably tell me more about your use-case?
1. e.g. when you are using the CAN_RAW socket: Do you set CAN filters to
pass only needed content into userspace?
When you drop 50% of the CAN IDs in userspace you still have to transfer
them from kernelspace to userspace and check if you should drop them.
2. when you need to filter for updates in specific content in the CAN
frames data[] section the CAN_BCM socket is your friend. Especially for
cyclic sent CAN messages e.g. in automotive use-cases.
3. When you need to forward and/or modify CAN frames between CAN
interfaces there is a special netlink-based in-kernel CAN-Gateway which
can be controlled by the 'cangw' tool.
The last time I had your described issues, I was routing CAN frames via
userspace - which finally led to the implementation of the can-gw module ;-)
Best regards,
Oliver
next prev parent reply other threads:[~2022-08-12 13:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-10 2:35 PCAN and SocketCAN Questions David Boles
2022-08-10 7:45 ` Marc Kleine-Budde
2022-08-11 20:17 ` David Boles
2022-08-12 12:37 ` Marc Kleine-Budde
2022-08-12 13:00 ` Oliver Hartkopp [this message]
2022-08-12 19:00 ` David Boles
2022-08-12 18:49 ` David Boles
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86dffcf2-e79d-e32a-bdcf-404ee8f7dd22@hartkopp.net \
--to=socketcan@hartkopp.net \
--cc=linux-can@vger.kernel.org \
--cc=me@davidbol.es \
--cc=mkl@pengutronix.de \
--cc=s.grosjean@peak-system.com \
--cc=thomasaevans@optusnet.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox