hardbyte / python-can

The can package provides controller area network support for Python developers
https://python-can.readthedocs.io
GNU Lesser General Public License v3.0
1.29k stars 602 forks source link

CAN FD - serial line? #1305

Closed jagauthier closed 2 years ago

jagauthier commented 2 years ago

I'm sorry to open a "bug" report for a support issue. I've been reading through the documentation, and I know that CAN FD support is present. But I can't seem to find out of it's supported via serial over CAN (slcan)

I know this is an ASCII protocol for traditional CAN: http://www.can232.com/docs/can232_v3.pdf

But I am having a hard time finding definitive information about this protocol and CAN FD.

Edit: I think I found the answer https://github.com/hardbyte/python-can/blob/develop/can/interfaces/slcan.py This code doesn't support CAN FD messages, so I guess it's not supported directly.

hartkopp commented 2 years ago

But I can't seem to find out of it's supported via serial over CAN (slcan)

It is not. I'm maintaining the slcan driver in the Linux kernel ;-)

I know this is an ASCII protocol for traditional CAN: http://www.can232.com/docs/can232_v3.pdf

The ASCII protocol has originally been invented by LAWICEL AB http://www.can232.com/?page_id=8

And then different projects adopted this protocol: https://github.com/linux-can/can-doc/blob/master/slcan/SLCAN-API.pdf

Based on the serial line discipline for IP in the Linux kernel (SLIP) I implemented a serial line discipline for CAN (SLCAN).

But I am having a hard time finding definitive information about this protocol and CAN FD.

IIRC we had a request for a CAN FD extension in the past. https://github.com/linux-can/can-utils/issues/110 The SLCAN protocol can be fine for home-brew projects with low 'Classical CAN' busload and running CAN FD traffic with 4Mbit/s data bitrate at high bus load likely does not scale over a serial line.

If you are searching for Open Source CAN USB hardware supporting CAN FD then https://github.com/candle-usb/candleLight_fw is probably something for you (excellent performance with binary USB protocol). Or you get a CAN FD Hat for Raspberry Pi which also works fine. Or you buy some professional adapters ...

Edit: I think I found the answer https://github.com/hardbyte/python-can/blob/develop/can/interfaces/slcan.py This code doesn't support CAN FD messages, so I guess it's not supported directly.

If you check out the original LAWICEL website http://www.can232.com/?page_id=8 and the news archive http://www.can232.com/?m=201710 (latest entry October 19, 2017). I would not assume LAWICEL to create a CAN FD version (also due to the outlines protocol performance issues). And creating a SLCANFD ASCII protocol without LAWICEL feels wrong too ;-)

jagauthier commented 2 years ago

Thanks for your elaborate response! I actually have custom built hardware and I am trying to figure out the best method to use for both Windows and Linux functionality. Fortunately, this will not be used for high speed communications. Mostly status and commands, but I am using CAN FD because the network will absolutely support higher speeds. candlelight firmware with binary USB seems promising, but I am not very familiar with gs_usb at this point either.

hartkopp commented 2 years ago

The candlelight firmware implements the GS_USB protocol which either works on Linux/SocketCAN out of the box and obviously also directly which python-can:

https://github.com/hardbyte/python-can/blob/develop/can/interfaces/gs_usb.py

The CAN FD support is pretty new (in the firmware and in the Linux kernel). But IMHO this could be the most promising way for your custom built hardware to follow.

jagauthier commented 2 years ago

It also looks like the firmware "also implements WCID USB descriptors" so it can be used on Windows. I'm not sure if I can get away with Python-can, which I already use, but I think I can use some other gs-usb based modules.

thestumbler commented 2 years ago

I would like to second this request. I have three different models serial-CAN devices that support FD: Grid Connect CAN232 FD, Canable 2.0, and Mjbots FdCanUsb.