Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setting can interface to can fd mode does not work #63

Open
poeschel opened this issue Apr 3, 2024 · 1 comment
Open

setting can interface to can fd mode does not work #63

poeschel opened this issue Apr 3, 2024 · 1 comment

Comments

@poeschel
Copy link
Contributor

poeschel commented Apr 3, 2024

I tried setting a can interface to can fd mode using socketcan-rs and set_ctrlmodes. I have something like this:

let nl_if = CanInterface::open("can0")?;
nl_if.set_ctrlmodes(CanCtrlModes::from_mode(CanCtrlMode::Fd, true))?;

It fails with Error response received from netlink: Operation not supported (os error 95).
Hmm, lets try official rcan program?

sudo ./target/debug/rcan can0 iface fd on
Error response received from netlink: Operation not supported (os error 95)

Ok, at least the provided example/reference program has the same problem. What else can I do?

sudo ip link set can0 type can fd on
RTNETLINK answers: Operation not supported

Is ip-utils also wrong or is it just me?
After fiddling around with different parameter combinations I got this to work:

sudo ip link set can0 type can bitrate 500000 dbitrate 500000 fd on

It answers with silence, but it worked:

ip -details link show can0
79: can0: <NOARP,ECHO> mtu 72 qdisc noop state DOWN mode DEFAULT group default qlen 10
    link/can  promiscuity 0 minmtu 0 maxmtu 0 
    can <FD> state STOPPED (berr-counter tx 0 rx 0) restart-ms 0 
          bitrate 500000 sample-point 0.875 
          tq 12 prop-seg 69 phase-seg1 70 phase-seg2 20 sjw 1
          pcan_usb_fd: tseg1 1..256 tseg2 1..128 sjw 1..128 brp 1..1024 brp-inc 1
          dbitrate 500000 dsample-point 0.875 
          dtq 62 dprop-seg 13 dphase-seg1 14 dphase-seg2 4 dsjw 1
          pcan_usb_fd: dtseg1 1..32 dtseg2 1..16 dsjw 1..16 dbrp 1..1024 dbrp-inc 1
          clock 80000000 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 parentbus usb parentdev 1-12.2:1.0

Notice the <FD>! It is a can fd capable interface that supports fd mode on linux.
During fiddling around, i noticed, that setting to fd mode alone does not work(as seen above). When setting to fd mode, it also wants a dbitrate and bitrate at the same time. With knowing that, lets move back to rcan:

sudo ./target/debug/rcan can0 iface bitrate 500000 fd on
error: unexpected argument 'fd' found

Usage: rcan iface bitrate <bitrate>

No. It does not work. rcan only supports one parameter at a time. And so does the netlink api of socketcan-rs. Looking at CanInterface I do not see a way to set multiple parameters at the same time.
So my questions are:

  1. Am I missing something or am I doing something wrong?
  2. Is there a way using public socketcan-rs api for doing what I need?
  3. If not, how can we best resolve this?
    I do see InterfaceCanParams as part of InterfaceDetails as a candidate that would allow setting all fields as needed, but it is not ideal. It has much more fields, even fields, that can only be query'd and there is also no set_details or the like on CanInterface. That needs to be implemented then.

What do you think?

Thanks,
Lars

@Urist-McGit
Copy link

I have the same problem with my PCAN-USB FD adapter. This seems to be happening on some devices. I have a working solution here #66, which should fix the issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants