On Wed, 9 Dec 2020 at 03:59, Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx> wrote: > > On 12/7/20 3:57 AM, Christian Gagneraud wrote: > > I'm looking at creating a new CAN driver for a USB device [1]. This device > > has a custom protocol over bulk endpoints. I was able to create a simple > > driver, based on usb-skeleton.c that allows to speak this protocol by opening > > a custom har device. > > Do you already have code available somewhere? No, not yet. This driver is really a slightly modified usb-skeleton where you read/write bulk packets one by one on a char device. I have as well a python version that was used as a proof of concept (using pyusb). > > > I've been looking at the current implementation in [2], I think my device is > > a bit special, you cannot read CAN frames w/o sending a 'read' command, so i > > need some sort of polling. AFAIK, the Linux USB stack provides that for me, > > except that the device won't read anything unless you send it a command. > > I don't know if you have to implement the polling yourself or if there is a > polling helper. I'll ask my co-workers. > > Is that a Interrupt Transfer Endpoint or a normal Bulk Endpoint? AFAIU the firmware, it's just a normal Bulk Endpoint, which i think is the problem. > > I have the feeling that current drivers are for devices that can > > return data by just scheduling read transfer. > > Yes. Current drivers get notified by the device, if there is a CAN frame waiting. > > > Anyone would have a clue on how these drivers work, and if my device > > is really that special? > > Yes, your device is quite special :) Hum, no good news... The device has 3 interfaces: - keyboard - mouse - device specific (CAN) The reason for HID is that these sort of devices[1] communicate over N2K [1] https://www.simrad-yachting.com/en-nz/simrad/type/autopilots/autopilot-remote-controllers/simrad-op50-remote/ Thanks, Chris $ lsusb -v Bus 001 Device 105: ID 1cda:03e8 Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x1cda idProduct 0x03e8 bcdDevice 0.13 iManufacturer 1 Navico Asia Pacific Ltd iProduct 2 Navico USB IO Computer iSerial 3 SN-03EC-FFFFFFFF bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 82 bNumInterfaces 3 bConfigurationValue 1 iConfiguration 0 bmAttributes 0x80 (Bus Powered) MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 1 bInterfaceClass 3 Human Interface Device bInterfaceSubClass 1 Boot Interface Subclass bInterfaceProtocol 1 Keyboard iInterface 4 Virtual Keyboard HID Device Descriptor: bLength 9 bDescriptorType 33 bcdHID 1.01 bCountryCode 0 Not supported bNumDescriptors 1 bDescriptorType 34 Report wDescriptorLength 63 Report Descriptors: ** UNAVAILABLE ** Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0008 1x 8 bytes bInterval 10 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 0 bNumEndpoints 1 bInterfaceClass 3 Human Interface Device bInterfaceSubClass 1 Boot Interface Subclass bInterfaceProtocol 2 Mouse iInterface 5 Virtual Mouse HID Device Descriptor: bLength 9 bDescriptorType 33 bcdHID 1.01 bCountryCode 0 Not supported bNumDescriptors 1 bDescriptorType 34 Report wDescriptorLength 50 Report Descriptors: ** UNAVAILABLE ** Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x84 EP 4 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0008 1x 8 bytes bInterval 10 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 2 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 255 Vendor Specific Class bInterfaceSubClass 255 Vendor Specific Subclass bInterfaceProtocol 255 Vendor Specific Protocol iInterface 6 Client Application Interface Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Device Status: 0x0000 (Bus Powered)