JohnDMcMaster/faxitron

DC3 support

Opened this issue · 2 comments

I've managed to obtain a DX-50 with the DC3 option (Hamamatsu C9266-03).

USB VID: 0x0661
USB PID: 0x3400

dmesg output:

[440265.698953] usb 1-2.4: New USB device found, idVendor=0661, idProduct=3400, bcdDevice= 0.00
[440265.698955] usb 1-2.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[440265.698957] usb 1-2.4: Product: HPK C9266-03
[440265.698958] usb 1-2.4: Manufacturer: HPK

Since it's not a DC5 or DC12, dump.py fails with the following:

Writing to dump/2021-07-14_03

Sensor
Traceback (most recent call last):
  File "dump.py", line 68, in <module>
    main()
  File "dump.py", line 38, in main
    h = ham.Hamamatsu(init=False)
  File "/home/arthur/PiSync/faxitron/faxitron/ham.py", line 754, in __init__
    self.dev = open_dev(self.usbcontext)
  File "/home/arthur/PiSync/faxitron/faxitron/ham.py", line 743, in open_dev
    raise Exception("Failed to find a device")
Exception: Failed to find a device

What changes are needed to add DC3 support? Is it just a matter of adding the USB PIDs to ham.py?

Hmm I think that's about right...devices are pretty abstract and not a lot of device specific configuration is required. Some of the other image processing might have hard coded width/height though would need to double check.

However I did observe different status codes at one point. It's unclear if this is a bug (in my code) or something else, but take a look at STATUS_OK_DC5 vs STATUS_OK_DC12. Hopefully your device will just work with one of these and more status codes won't be required.

I saw that ham.py had the endpoints hardcoded for read and write:

    bulkWrite(0x01, cmd)
    if read:
        return bulkRead(0x83, 0x0200)

However the endpoints are completely different on mine, here's the lsusb output:

Bus 001 Device 036: ID 0661:3400 Hamamatsu Photonics K.K. USB Optical Mouse
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x0661 Hamamatsu Photonics K.K.
  idProduct          0x3400 
  bcdDevice            0.00
  iManufacturer           1 HPK
  iProduct                2 HPK C9266-03
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x002e
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x84  EP 4 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x86  EP 6 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  bNumConfigurations      1
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0002
  (Bus Powered)
  Remote Wakeup Enabled

So there's one OUT endpoint (0x02), and two IN endpoints (0x84 and 0x86). Tried writing to 0x02 instead of 0x01 but the reply length is different to what it expects:

File "/home/arthur/PiSync/faxitron/faxitron/ham.py", line 150, in parse_info1
    assert len(buff) == 0x80
AssertionError