Re: ip link valid options checking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed. 7 Jul 2021 at 19:45, Joshua Quesenberry <engnfrc@xxxxxxxxx> wrote:
> Good Afternoon,
>
> Do any of you know a way to check what options are valid when setting up a
> CAN device with the ip link commands, either from bash or through C++? I'm
> working on a piece of code that will get used on systems with varying CAN
> drivers and for instance one of them doesn't support CAN-FD, so how would I
> be able to know that setting the fd flag or dbitrate value would fail before
> calling the setup command and seeing it fail?

I would suggest to use:
| ip --details link show can0

You can then parse the results to check if the data bitrate
information is present. If so, it means that FD is supported.
Also, the output might be easier to parse if formatted in json:
| ip --details --json --pretty link show can0

Alternatively, instead of using the command line, you might
prefer to directly use the kernel netlink interface to directly
retrieve the different modes supported by the controller.
You can refer to iproute2 source code for the how-to:
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/ip/iplink_can.c#n282


Yours sincerely,
Vincent



[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux