python-can icon indicating copy to clipboard operation
python-can copied to clipboard

add FD support to slcan according to CANable 2.0 impementation

Open ssj71 opened this issue 10 months ago • 8 comments

The canable 2.0 project has extended the slcan interface to add support for CAN-FD frames and bitrate switching (see https://github.com/normaldotcom/canable2-fw). I needed this support for my work so I've implemented it in the library. If this work is useable I'd love to have it merged in. Happy to make tweaks or whatever, just need some direction.

Thank you for maintaining this project. It's immensely useful.

ssj71 avatar Feb 18 '25 17:02 ssj71

fixed the black and ruff failings.

ssj71 avatar Feb 18 '25 21:02 ssj71

Hi Bro, I have modify the code as your commit, send message is ok, but seems can not received message (windows platform), do you have this issue?

CallmeLins avatar Mar 17 '25 04:03 CallmeLins

Hello,

Thank you for submitting this pull request. This update will be very useful for me.

However, I noticed an issue regarding compatibility with classical devices that do not support CAN FD. In the latest release, a device can be initialized as follows:

bus = can.interface.Bus(interface="slcan", channel="COM9", bitrate=500000)

When using your branch, the initialization fails with the following exception:

Invalid data bitrate, choose one of 2000000, 5000000.

In my opinion, the initialization should still work to support classical slcan devices.

By the way, I tested the CAN FD capability with a 500k/2Mbps bus. I had no issue with sending/receiving on a Windows PC.

Thank you.

Nakakiyo092 avatar Mar 23 '25 09:03 Nakakiyo092

When using your branch, the initialization fails

I agree my changes should not have that effect. I will update and check that useage.

ssj71 avatar Mar 24 '25 15:03 ssj71

Hi Bro, I have modify the code as your commit, send message is ok, but seems can not received message (windows platform), do you have this issue?

I send and receive without issue. I have found that ListenOnly mode doesn't work properly. I believe it is a canable firmware issue.

ssj71 avatar Mar 24 '25 15:03 ssj71

Apologies for the delays. That fix is in to allow non-FD rates again and I believe this to be ready to merge.

ssj71 avatar Apr 22 '25 20:04 ssj71

Apologies for the delays. That fix is in to allow non-FD rates again and I believe this to be ready to merge.

I confirmed that my issue has been resolved. Thank you for the update.

Nakakiyo092 avatar Apr 25 '25 09:04 Nakakiyo092

Overall this looks fine except for a lack of tests. What happens if a user tries to open an FD bus on a device, that does not support it? Will there be some exception or just silent failure?

zariiii9003 avatar May 31 '25 20:05 zariiii9003

I added some tests and they made it clear to me I had an error in the DLC handling in the initial implementation. That's resolved and I hope this makes the PR a bit more compelling. Let me know if there's anything else needed. Thanks!

ssj71 avatar Jul 19 '25 04:07 ssj71

What happens if a user tries to open an FD bus on a device, that does not support it? Will there be some exception or just silent failure?

Looking at the original CANable firmware source it just silently fails. I'm not sure about other HW devices that use slcan.

ssj71 avatar Jul 19 '25 04:07 ssj71

ok, I think this one is ready (finally)!

ssj71 avatar Jul 22 '25 04:07 ssj71

Happy to help out. Tag me in any issues that look related. Thanks!

ssj71 avatar Jul 22 '25 19:07 ssj71