Sunday, November 3, 2013

Getting USB Debugging Info from the Linux Command Line.

Not ready to give up on this just yet. Having a closer look at the command line tools that are available.
seans@snowpack:~$ sudo lsusb -v

...

Bus 002 Device 005: ID 04e8:1306 Samsung Electronics Co., Ltd 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x04e8 Samsung Electronics Co., Ltd
  idProduct          0x1306 
  bcdDevice            0.00
  iManufacturer           1 SAMSUNG  
  iProduct                2 Samsung Digital Camera 
  iSerial                 3 E00000000002 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           32
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xc0
      Self Powered
    MaxPower                0mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         8 Mass Storage
      bInterfaceSubClass      5 SFF-8070i
      bInterfaceProtocol     80 
      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     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 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 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  bNumConfigurations      1
Device Status:     0x0001
  Self Powered
Ubuntu has a USB debugging feature, which on my installation was running automatically. You can monitor the communication on the various USB buses by,
seans@snowpack:~$ sudo cat /sys/kernel/debug/usb/usbmon/2u > bus2data.txt
Here's a sample of the output,
ffff88009bf78240 752186120 S Bo:2:005:2 -115 31 = 55534243 18070000 08000000 80010c4a 01000010 00000008 00000000 000000
ffff88009bf78240 752186154 C Bo:2:005:2 0 31 >
ffff880062803c00 752186180 S Bi:2:005:2 -115 8 <
ffff880062803c00 752186403 C Bi:2:005:2 -32 0
ffff88009bf78240 752186412 S Co:2:005:0 s 02 01 0000 0082 0000 0
ffff88009bf78240 752186527 C Co:2:005:0 0 0
ffff88009bf78240 752186548 S Bi:2:005:2 -115 13 <
ffff88009bf78240 752207425 C Bi:2:005:2 0 13 = 55534253 18070000 08000000 01
ffff88009bf78240 752207452 S Bo:2:005:2 -115 31 = 55534243 19070000 12000000 80010c03 00000012 00000000 00000000 000000
ffff88009bf78240 752207652 C Bo:2:005:2 0 31 >
ffff880062803c00 752207718 S Bi:2:005:2 -115 18 <
ffff880062803c00 752207778 C Bi:2:005:2 0 18 = 70000500 0000000a 00000000 20000000 0000
ffff88009bf78240 752207788 S Bi:2:005:2 -115 13 <
ffff88009bf78240 752207901 C Bi:2:005:2 0 13 = 55534253 19070000 00000000 00
ffff88009bf78240 752698083 S Bo:2:005:2 -115 31 = 55534243 1a070000 00000000 00000c00 00000000 00000000 00000000 000000
ffff88009bf78240 752698157 C Bo:2:005:2 0 31 >
ffff88009bf78240 752698391 S Bi:2:005:2 -115 13 <
ffff88009bf78240 752698527 C Bi:2:005:2 0 13 = 55534253 1a070000 00000000 00
ffff88009bf78240 754234230 S Bo:2:005:2 -115 31 = 55534243 1b070000 08000000 80010c4a 01000010 00000008 00000000 000000
ffff88009bf78240 754234295 C Bo:2:005:2 0 31 >
ffff8801380f9f00 754234315 S Bi:2:005:2 -115 8 <
ffff8801380f9f00 754234415 C Bi:2:005:2 -32 0
ffff88009bf78240 754234438 S Co:2:005:0 s 02 01 0000 0082 0000 0
ffff88009bf78240 754234528 C Co:2:005:0 0 0
ffff88009bf78240 754234540 S Bi:2:005:2 -115 13 <
ffff88009bf78240 754255617 C Bi:2:005:2 0 13 = 55534253 1b070000 08000000 01
ffff88009bf78240 754255664 S Bo:2:005:2 -115 31 = 55534243 1c070000 12000000 80010c03 00000012 00000000 00000000 000000
ffff88009bf78240 754255906 C Bo:2:005:2 0 31 >
ffff880132d0b3c0 754255925 S Bi:2:005:2 -115 18 <
ffff880132d0b3c0 754256032 C Bi:2:005:2 0 18 = 70000500 0000000a 00000000 20000000 0000
ffff88009bf78240 754256047 S Bi:2:005:2 -115 13 <
ffff88009bf78240 754256155 C Bi:2:005:2 0 13 = 55534253 1c070000 00000000 00
I still don't understand some of the intermediate messages, but I found a resource that explains a couple of them. I made this legend from the description on that webpage.
The upshot is that there seems to be a means to send a variety of commands over the same "configuration". However, I haven't been able to find any resource that describes the commands and arguments that would be recognized by the device. I thought about just sending 256 different command signals to see what comes back, but I think I'd risk sending a factory reset signal or something that might render the camera useless. I'd rather have a camera that doesn't do everything I want but works than have no camera at all.

No comments:

Post a Comment