linux-can / socketcand

Server to access CAN sockets over ASCII protocol
168 stars 43 forks source link

CAN FD support #12

Open mocle opened 4 years ago

mocle commented 4 years ago

Is it correct that socketcand does not support the data-communication protocol CAN FD (CAN Flexible Data Rate)? Or did I miss something?

CAN FD frames created with can-utils are not displayed in raw mode.

hartkopp commented 4 years ago

Yes. So far socketcand does not support CAN FD. No user requests :-)

mocle commented 4 years ago

Thanks for the confirmation @hartkopp .

Then this issue should be the first official request for CAN FD.

I would see the support of CAN FD as a great added value for this great project.

hartkopp commented 4 years ago

Would the < rawmode > support be sufficient for you?

E.g. by receiving something like < fdframe 03B 1589476062.377071 7D1FDF312DD0DE1CAABBCCDD > ?

Or do you need BCM support too?

mocle commented 4 years ago

In my specific case, I would have to be able to receive CAN FD Frames, as well as send them.

As this is currently possible in < rawmode > with the "normal" CAN frames, this would be sufficient for me and probably for most applications.

Like in your example, receiving an FD frame with something like < fdframe 03B 1589476062.377071 7D1FDF312DD0DE1CAABBCCDD >. And an equivalent for sending FD Frames, like < sendfd 03B 1589476062.377071 7D1FDF312DD0DE1CAABBCCDD >. This would be awesome!

hartkopp commented 4 years ago

Hey @mocle , I created a branch https://github.com/linux-can/socketcand/tree/rawmode-canfd which contains a simple extension, which is not really optimized but implements the discussed approach. You are invited to take a test drive :-)

mocle commented 4 years ago

Thanks @hartkopp for your effort and the super fast implementation. I will test your implementation and give feedback on the weekend. Thanks a lot already!

hartkopp commented 4 years ago

Hi @mocle, just pulled some other code and was wondering why I was on a different branch ... Did you test the branch?

Lukasz-Juranek commented 3 years ago

I've tested this works well, only wondering how to transfer additional CAN_FD flags like BSR and ERR in raw mode, but for now seems ok.

hartkopp commented 3 years ago

The ESI bit is not really a hot topic in CAN FD - I've never seen a real-world use-case for it, did you?

And the BRS bit is not provided on this abstraction level also. The setting of BRS is done in the CAN interface configuration (if you enable two data rates) and transparent on the CAN frame data representation.

AndyHuska commented 2 years ago

Up vote for merging this branch to master, or at least have a conversation about how to finish this branch off so it is ready. I'm willing to help!

hartkopp commented 2 years ago

Hi @AndyHuska ,

looking at the patch and my comment at https://github.com/linux-can/socketcand/issues/12#issuecomment-897093817 I'm finally not that sure whether ignoring BRS & ESI bits was that good idea ;-)

I was thinking about adding the flags as a single ASCII hex value (here '3') behind the timestamp: Current patch: < fdframe 03B 1589476062.377071 7D1FDF312DD0DE1CAABBCCDD > With FD flags: < fdframe 03B 1589476062.377071 3 7D1FDF312DD0DE1CAABBCCDD >

So when there's still demand, would you like to do some testing of the upgraded patch before getting this to the main branch?

@mocle @Lukasz-Juranek : Are you working with the original PoC patch in a production environment or would if be fine for you to enhance the protocol as described above?