User Tools

Site Tools


마소전략커맨더

관련 파일

  • drivers/hiddev.c
  • drivers/hid/usbhid/hid-pidff.c
  • Documentation/usb/gadget_hid.txt

HID report

  • /dev/hidgX
  • /dev/hidrawX

references

libusb

int usb_control_msg(usb_dev_handle *dev, int requesttype, int request, int value, int index, char *bytes, int size, int timeout);

in kernel

/**
 * usb_control_msg - Builds a control urb, sends it off and waits for completion
 * @dev: pointer to the usb device to send the message to
 * @pipe: endpoint "pipe" to send the message to
 * @request: USB message request value
 * @requesttype: USB message request type value
 * @value: USB message value
 * @index: USB message index value
 * @data: pointer to the data to send
 * @size: length in bytes of the data to send
 * @timeout: time in msecs to wait for the message to complete before timing
 *	out (if 0 the wait is forever)
 */
int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
		    __u8 requesttype, __u16 value, __u16 index, void *data,
		    __u16 size, int timeout)

code practice

깜박이는 속도

	memcpy(buf, "\x02\x22\x22", 0x0000003);
	ret = usb_control_msg(devh, USB_TYPE_CLASS + USB_RECIP_INTERFACE, 0x0000009, 0x0000302, 0x0000000, buf, 0x0000003, 1000);
  • 020101 : 파르르르르
  • 021111 : 빠르게
  • 022222 : 느리게

LED ON/OFF

두바이트에 다음과 같이 할당되어 있음 B(link)와 O(n)비트를 동시에 설정할 수 없음

 4  3  2  1  n  R  6  5
BO BO BO BO xx BO BO BO

테스스코드

	memcpy(buf, "\x01\xAA\xAA", 0x0000003);
	ret = usb_control_msg(devh, USB_TYPE_CLASS + USB_RECIP_INTERFACE, 0x0000009, 0x0000301, 0x0000000, buf, 0x0000003, 1000);
  • 1번 LED : 01 01 00
  • 1번 LED 깜박임 : 01 02 00
  • 2번 LED : 01 04 00
  • 3번 LED : 01 10 00
  • 4번 LED : 01 40 00
  • 7개 모두 on : 01 55 15
  • 전체 깝박임 : 01 AA 2A

장치정보

usb ID

Bus 002 Device 002: ID 045e:0033 Microsoft Corp. Sidewinder Strategic Commander

상세정보

$ sudo lsusb -v -d 045e:0033

Bus 002 Device 002: ID 045e:0033 Microsoft Corp. Sidewinder Strategic Commander
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x045e Microsoft Corp.
  idProduct          0x0033 Sidewinder Strategic Commander
  bcdDevice            0.51
  iManufacturer           1 Microsoft
  iProduct                2 Microsoft SideWinder Strategic Commander
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           34
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength     190
          Report Descriptor: (length is 190)
            Item(Global): Usage Page, data= [ 0x01 ] 1
                            Generic Desktop Controls
            Item(Local ): Usage, data= [ 0x00 ] 0
                            Undefined
            Item(Main  ): Collection, data= [ 0x01 ] 1
                            Application
            Item(Global): Report ID, data= [ 0x01 ] 1
            Item(Local ): Usage, data= [ 0x01 ] 1
                            Pointer
            Item(Main  ): Collection, data= [ 0x00 ] 0
                            Physical
            Item(Global): Usage Page, data= [ 0x01 ] 1
                            Generic Desktop Controls
            Item(Local ): Usage, data= [ 0x30 ] 48
                            Direction-X
            Item(Local ): Usage, data= [ 0x31 ] 49
                            Direction-Y
            Item(Local ): Usage, data= [ 0x35 ] 53
                            Rotate-Z
            Item(Global): Logical Minimum, data= [ 0x00 0xfe ] 65024
            Item(Global): Logical Maximum, data= [ 0xff 0x01 ] 511
            Item(Global): Physical Minimum, data= [ 0x00 ] 0
            Item(Global): Physical Maximum, data= [ 0xff 0x03 ] 1023
            Item(Global): Report Size, data= [ 0x0a ] 10
            Item(Global): Report Count, data= [ 0x03 ] 3
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Main  ): End Collection, data=none
            Item(Global): Report Size, data= [ 0x01 ] 1
            Item(Global): Report Count, data= [ 0x02 ] 2
            Item(Main  ): Input, data= [ 0x01 ] 1
                            Constant Array Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Usage Page, data= [ 0x09 ] 9
                            Buttons
            Item(Local ): Usage Minimum, data= [ 0x01 ] 1
                            Button 1 (Primary)
            Item(Local ): Usage Maximum, data= [ 0x0c ] 12
                            (null)
            Item(Global): Logical Minimum, data= [ 0x00 ] 0
            Item(Global): Logical Maximum, data= [ 0x01 ] 1
            Item(Global): Physical Minimum, data= [ 0x00 ] 0
            Item(Global): Physical Maximum, data= [ 0x01 ] 1
            Item(Global): Report Size, data= [ 0x01 ] 1
            Item(Global): Report Count, data= [ 0x0c ] 12
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Usage Page, data= [ 0x09 ] 9
                            Buttons
            Item(Global): Logical Minimum, data= [ 0x01 ] 1
            Item(Global): Logical Maximum, data= [ 0x03 ] 3
            Item(Local ): Usage, data= [ 0x0d ] 13
                            (null)
            Item(Local ): Usage, data= [ 0x0e ] 14
                            (null)
            Item(Local ): Usage, data= [ 0x0f ] 15
                            (null)
            Item(Global): Report Size, data= [ 0x02 ] 2
            Item(Global): Report Count, data= [ 0x01 ] 1
            Item(Main  ): Input, data= [ 0x20 ] 32
                            Data Array Absolute No_Wrap Linear
                            No_Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Report Size, data= [ 0x01 ] 1
            Item(Global): Report Count, data= [ 0x02 ] 2
            Item(Main  ): Input, data= [ 0x01 ] 1
                            Constant Array Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Report Size, data= [ 0x02 ] 2
            Item(Global): Report Count, data= [ 0x06 ] 6
            Item(Global): Logical Minimum, data= [ 0x00 ] 0
            Item(Global): Logical Maximum, data= [ 0x02 ] 2
            Item(Global): Usage Page, data= [ 0x08 ] 8
                            LEDs
            Item(Local ): Usage Minimum, data= [ 0x4b ] 75
                            Generic Indicator
            Item(Main  ): Collection, data= [ 0x02 ] 2
                            Logical
            Item(Local ): Usage Minimum, data= [ 0x49 ] 73
                            Indicator Green
            Item(Main  ): Collection, data= [ 0x02 ] 2
                            Logical
            Item(Local ): Usage, data= [ 0x3c ] 60
                            Usage Multi Indicator
            Item(Main  ): Collection, data= [ 0x02 ] 2
                            Logical
            Item(Local ): Usage, data= [ 0x41 ] 65
                            Indicator Off
            Item(Local ): Usage, data= [ 0x3d ] 61
                            Indicator On
            Item(Local ): Usage, data= [ 0x40 ] 64
                            Indicator Fast Blink
            Item(Main  ): Feature, data= [ 0x60 ] 96
                            Data Array Absolute No_Wrap Linear
                            No_Preferred_State Null_State Non_Volatile Bitfield
            Item(Main  ): End Collection, data=none
            Item(Main  ): End Collection, data=none
            Item(Main  ): End Collection, data=none
            Item(Global): Report Size, data= [ 0x02 ] 2
            Item(Global): Report Count, data= [ 0x01 ] 1
            Item(Global): Logical Minimum, data= [ 0x00 ] 0
            Item(Global): Logical Maximum, data= [ 0x02 ] 2
            Item(Global): Usage Page, data= [ 0x08 ] 8
                            LEDs
            Item(Local ): Usage Minimum, data= [ 0x4b ] 75
                            Generic Indicator
            Item(Main  ): Collection, data= [ 0x02 ] 2
                            Logical
            Item(Local ): Usage Minimum, data= [ 0x48 ] 72
                            Indicator Red
            Item(Main  ): Collection, data= [ 0x02 ] 2
                            Logical
            Item(Local ): Usage, data= [ 0x3c ] 60
                            Usage Multi Indicator
            Item(Main  ): Collection, data= [ 0x02 ] 2
                            Logical
            Item(Local ): Usage, data= [ 0x41 ] 65
                            Indicator Off
            Item(Local ): Usage, data= [ 0x3d ] 61
                            Indicator On
            Item(Local ): Usage, data= [ 0x40 ] 64
                            Indicator Fast Blink
            Item(Main  ): Feature, data= [ 0x60 ] 96
                            Data Array Absolute No_Wrap Linear
                            No_Preferred_State Null_State Non_Volatile Bitfield
            Item(Main  ): End Collection, data=none
            Item(Main  ): End Collection, data=none
            Item(Main  ): End Collection, data=none
            Item(Global): Report Size, data= [ 0x01 ] 1
            Item(Global): Report Count, data= [ 0x02 ] 2
            Item(Main  ): Feature, data= [ 0x01 ] 1
                            Constant Array Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Report ID, data= [ 0x02 ] 2
            Item(Global): Report Size, data= [ 0x08 ] 8
            Item(Global): Report Count, data= [ 0x01 ] 1
            Item(Global): Logical Minimum, data= [ 0x01 ] 1
            Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
            Item(Global): Physical Minimum, data= [ 0x01 ] 1
            Item(Global): Physical Maximum, data= [ 0xff 0x00 ] 255
            Item(Global): Unit, data= [ 0x01 0x10 ] 4097
                            System: SI Linear, Unit: Seconds
            Item(Global): Unit Exponent, data= [ 0x02 ] 2
                            Unit Exponent: 2
            Item(Local ): Usage, data= [ 0x45 ] 69
                            Fast Blink On Time
            Item(Main  ): Feature, data= [ 0x60 ] 96
                            Data Array Absolute No_Wrap Linear
                            No_Preferred_State Null_State Non_Volatile Bitfield
            Item(Local ): Usage, data= [ 0x46 ] 70
                            Fast Blink Off Time
            Item(Main  ): Feature, data= [ 0x60 ] 96
                            Data Array Absolute No_Wrap Linear
                            No_Preferred_State Null_State Non_Volatile Bitfield
            Item(Main  ): End Collection, data=none
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0007  1x 7 bytes
        bInterval              10
Device Status:     0x0000
  (Bus Powered)

references

마소전략커맨더.txt · Last modified: 2013/08/03 05:04 (external edit)