WICG / webhid

Web API for accessing Human Interface Devices (HID)
Other
142 stars 35 forks source link

Communication with a HID device that uses endpoints instead of reports #85

Closed prochazkaml closed 3 years ago

prochazkaml commented 3 years ago

TL;DR: I'm attempting to create a web app which communicates with a device from 2007. The problem is that WebUSB won't allow me to use it, because it implements a "protected interface class" (it's a HID device), but I can't use WebHID, because the device communicates over standard endpoints, instead of sending/receiving reports.


A bit of background: as it seems, our school is trying to migrate from using Windows 10 machines in classes to Chrome OS-based devices. Hooray! However, there is one place, where this move is not possible, and that is our physics lab, which to this day uses these old analog dual-channel data-loggers, which rely on some software from the Windows XP days, thus we still need the Windows 10 machines to run it. I (as a student) have offered to volunteer with reverse-engineering the communication protocol between those devices and the software and then perhaps creating a web app using WebUSB/WebHID. After a couple of weeks, I have now fully reverse-engineered the protocol (to the point that I have created a usable clone of the original device using a Raspberry Pi Pico – and yes, it works with the original software), and I set out to start working on the actual web app.

I originally wanted to use WebUSB, since that's what I'm familiar with, however, I hit a problem:

image

That's right. This device's only interface for whatever reason implements a HID class, instead of vendor-specific. So of course, after a bit of research, I discovered WebHID. However, that (as far as I am aware) can only communicate by sending/receiving reports. This device doesn't support that though! It only communicates over the standard endpoints.

So now I'm stuck. Is there a way to communicate over endpoints using WebHID, or is there some way of using the old WebUSB, or have I hit a dead end with this project?

Any help would be much appreciated.

For those that are interested, here's the lsusb listing of the mysterious device, with redacted vendor/product IDs/strings:

Bus 001 Device 024: ID REDACTED
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor         REDACTED 
  idProduct        REDACTED 
  bcdDevice            1.00
  iManufacturer           1 REDACTED
  iProduct                2 REDACTED
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0029
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.00
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      52
         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     0x0040  1x 64 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval               1
Device Status:     0x0000
  (Bus Powered)
prochazkaml commented 3 years ago

Nevermind, I'm an idiot.