Thread (8 messages) 8 messages, 2 authors, 2021-02-18

Re: New USB driver, looking for advice

From: Christian Gagneraud <hidden>
Date: 2021-02-18 02:15:55

On Fri, 11 Dec 2020 at 21:39, Marc Kleine-Budde [off-list ref] wrote:
On 12/10/20 11:26 PM, Christian Gagneraud wrote:
quoted
quoted
quoted
quoted
Yes, your device is quite special :)
[...]
quoted
quoted
I think you have to implement the polling yourself. Start a transfer on
ndo_open(). In the completion handler handle the received data. In case you have
recieved a CAN frame, submit a new transfer in case you haven't received data
yet, schedule delayed work with a delay, e.g. 1ms. Once you have that running
you have fine tune the number of running transfers and delays.
Thanks Marc for the hints.
I'll look into that, this will certainly take time, I'm not in a rush.
Full disclosure: I am actually an employee of Navico (the manufacturer
of the device),
Nice! There are several CAN devices which have mainline Linux spport by their
manufacturers. Is there any driver for other operating systems like Windows,
etc? You might talk to the developers to find out, how they solve the problem of
polling.
quoted
I'm currently waiting for approval to publish code
related to that device. This shouldn't be an issue, I just need the
administrative work done.
Fingers crossed!
I have 3 code base to share:

1. https://github.com/NavicoOS/pegasus-python-can/blob/main/python-can-pegasus/pegasus_iface.py
This code show how to talk to the USB device, it is quite compact and simple
The workhorse are_usb_bulk(), _write_usb_packet() and _read_usb_packet()
There are different types of packet, with a straight mapping with
open, close, bus on, bus off, read, write, ...

2. https://github.com/NavicoOS/pegasus-linux-can/tree/main/pegasus_usb
This is a simple char device driver on top of the Linux USB stack
You can manually write command, and read answer to/from this device,
the README [1], show how to handle the '
get_descriptor' and compare the binary answer with what the above
python based project

3. https://github.com/NavicoOS/pegasus-linux-can/tree/main/pegasus_can
I thought i had an initial PoC based on some linux-can driver, but
obviously not, this is the same as above, so let's ignore it for now,
unless i find a more up to date source tree.

[1] https://github.com/NavicoOS/pegasus-linux-can/blob/main/README.md

Chris
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help