Brent Bushnell
2009-01-31 06:24:51 UTC
I'm new to USB HID programming and unsure whether I'm misunderstanding
the device documentation or just going about this incorrectly.
I have a touch screen that I've successfully run the python
test_hidwrap.py against.
After reviewing the HID class documentation and the device documentation
(http://home.eeti.com.tw/web20/drivers/Software%20Programming%20Guide_%20v1.5.pdf
),
I'm fairly certain I should be sending a diagnostics packet using
set_output_report.
The trouble is that every path I try results in a broken pipe error.
I've gathered that the path values ending in 0x00000000 are not
complete paths
and possibly additional bytes for neighboring paths?
Looking through the archives, it seems like others have had a similar
problem
to the one I'm having, but I've been unable to extract a solution from
these earlier
posts.
Any thoughts would be greatly appreciated! Thanks.
==> relevant python code:
iface = hidwrap.Interface(vendor_id=0xeef, product_id=0x0001)
iface.write_identification(sys.stdout)
iface.dump_tree(sys.stdout)
paths=[ [0x00010001,0x00010001,0x00010030],
[0x00010001,0x00010001,0x00010031],
[0x000d0004,0x000d0020,0x000d0042],
[0x000d0004,0x000d0020,0x000d0032],
[0x000d0004,0x000d0020,0x00010030],
[0x000d0004,0x000d0020,0x00010031]]
for path in paths:
try:
bytes = struct.pack('3b',0x0A,0x31,0x41)
print 'Sending buffer of size %i to screen: %s' %
(len(bytes), repr(bytes))
iface.set_output_report(path, bytes)
except:
print "%s: %s" % (sys.exc_info()[0], sys.exc_info()[1])
==> code output:
NOTICE: hid_init(): libhid 0.2.17 is being initialized.
<snip>
parse tree of HIDInterface 001/010[0]:
path: 0x00010001.0x00010001.0x00000000; type: 0x80
path: 0x00010001.0x00010001.0x00000000; type: 0x80
path: 0x00010001.0x00010001.0x00000000; type: 0x80
path: 0x00010001.0x00010001.0x00010030; type: 0x80
path: 0x00010001.0x00010001.0x00010031; type: 0x80
path: 0x000d0004.0x000d0020.0x000d0042; type: 0x80
path: 0x000d0004.0x000d0020.0x000d0032; type: 0x80
path: 0x000d0004.0x000d0020.0x00000000; type: 0x80
path: 0x000d0004.0x000d0020.0x00000000; type: 0x80
path: 0x000d0004.0x000d0020.0x00000000; type: 0x80
path: 0x000d0004.0x000d0020.0x00000000; type: 0x80
path: 0x000d0004.0x000d0020.0x00000000; type: 0x80
path: 0x000d0004.0x000d0020.0x00000000; type: 0x80
path: 0x000d0004.0x000d0020.0x00010030; type: 0x80
path: 0x000d0004.0x000d0020.0x00010031; type: 0x80
TRACE: hid_reset_parser(): resetting the HID parser for USB device
001/010[0]...
Sending buffer of size 3 to screen: '\n1A'
TRACE: hid_set_output_report(): looking up report ID...
TRACE: hid_prepare_parse_path(): preparing search path of depth 3
for parse tree of USB device 001/010[0]...
TRACE: hid_prepare_parse_path(): search path prepared for parse
tree of USB device 001/010[0].
TRACE: hid_format_path(): formatting device path...
WARNING: hid_find_object(): can't find requested item
0x00010001.0x00010001.0x00010030 of USB device 001/010[0].
TRACE: hid_set_output_report(): sending report ID 0x00 (length: 3)
to USB device 001/010[0]...
WARNING: hid_set_output_report(): failed to send report to USB device
001/010[0]:error sending control message: Broken pipe.
hidwrap.HIDError: (19, 'set_output_report: libhid: failed to set
report')
==> lsusb -d 0eef:0001 -vvv
Bus 001 Device 006: ID 0eef:0001 D-WAV Scientific Co., Ltd eGalax
TouchScreen
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x0eef D-WAV Scientific Co., Ltd
idProduct 0x0001 eGalax TouchScreen
bcdDevice 2.00
iManufacturer 1 eGalax Inc.
iProduct 2 USB TouchController
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 34
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 1 eGalax Inc.
bmAttributes 0xa0
Remote Wakeup
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Devices
bInterfaceSubClass 0 No Subclass
bInterfaceProtocol 0 None
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.00
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 141
Report Descriptor: (length is 141)
Item(Global): Usage Page, data= [ 0x01 ] 1
Generic Desktop Controls
Item(Local ): Usage, data= [ 0x01 ] 1
Pointer
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= [ 0x09 ] 9
Buttons
Item(Local ): Usage Minimum, data= [ 0x01 ] 1
Button 1 (Primary)
Item(Local ): Usage Maximum, data= [ 0x02 ] 2
Button 2 (Secondary)
Item(Global): Logical Minimum, data= [ 0x00 ] 0
Item(Global): Logical Maximum, data= [ 0x01 ] 1
Item(Global): Report Count, data= [ 0x02 ] 2
Item(Global): Report Size, data= [ 0x01 ] 1
Item(Main ): Input, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position
Non_Volatile Bitfield
Item(Global): Report Count, data= [ 0x01 ] 1
Item(Global): Report Size, data= [ 0x06 ] 6
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= [ 0x01 ] 1
Generic Desktop Controls
Item(Local ): Usage, data= [ 0x30 ] 48
Direction-X
Item(Local ): Usage, data= [ 0x31 ] 49
Direction-Y
Item(Global): Logical Minimum, data= [ 0x2a 0x00 ] 42
Item(Global): Logical Maximum, data= [ 0xbd 0x07 ] 1981
Item(Global): Physical Minimum, data= [ 0x00 0x00 ] 0
Item(Global): Physical Maximum, data= [ 0xff 0x0f ] 4095
Item(Global): Unit, data= [ 0x00 0x00 ] 0
Item(Global): Report Size, data= [ 0x10 ] 16
Item(Global): Report Count, data= [ 0x02 ] 2
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(Main ): End Collection, data=none
Item(Global): Usage Page, data= [ 0x0d ] 13
Digitizer
Item(Local ): Usage, data= [ 0x04 ] 4
Touch Screen
Item(Main ): Collection, data= [ 0x01 ] 1
Application
Item(Global): Report ID, data= [ 0x02 ] 2
Item(Local ): Usage, data= [ 0x20 ] 32
Stylus
Item(Main ): Collection, data= [ 0x00 ] 0
Physical
Item(Local ): Usage, data= [ 0x42 ] 66
Tip Switch
Item(Local ): Usage, data= [ 0x32 ] 50
In Range
Item(Global): Logical Minimum, data= [ 0x00 ] 0
Item(Global): Logical Maximum, data= [ 0x01 ] 1
Item(Global): Report Count, data= [ 0x02 ] 2
Item(Global): Report Size, data= [ 0x01 ] 1
Item(Main ): Input, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position
Non_Volatile Bitfield
Item(Global): Report Count, data= [ 0x06 ] 6
Item(Global): Report Size, data= [ 0x01 ] 1
Item(Main ): Input, data= [ 0x03 ] 3
Constant Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position
Non_Volatile Bitfield
Item(Global): Usage Page, data= [ 0x01 ] 1
Generic Desktop Controls
Item(Local ): Usage, data= [ 0x30 ] 48
Direction-X
Item(Global): Report Size, data= [ 0x10 ] 16
Item(Global): Report Count, data= [ 0x01 ] 1
Item(Global): Push, data=none
Item(Global): Unit Exponent, data= [ 0x0d ] 13
Item(Global): Unit, data= [ 0x33 ] 51
Item(Global): Physical Minimum, data= [ 0x00 0x00 ] 0
Item(Global): Physical Maximum, data= [ 0x99 0x28 ] 10393
Item(Global): Logical Minimum, data= [ 0x00 0x00 ] 0
Item(Global): Logical Maximum, data= [ 0xff 0x0f ] 4095
Item(Main ): Input, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position
Non_Volatile Bitfield
Item(Local ): Usage, data= [ 0x31 ] 49
Direction-Y
Item(Global): Logical Minimum, data= [ 0x00 0x00 ] 0
Item(Global): Logical Maximum, data= [ 0xff 0x0f ] 4095
Item(Global): Physical Minimum, data= [ 0x00 0x00 ] 0
Item(Global): Physical Maximum, data= [ 0xaf 0x19 ] 6575
Item(Main ): Input, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position
Non_Volatile Bitfield
Item(Global): Pop, data=none
Item(Main ): End Collection, data=none
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 0x0008 1x 8 bytes
bInterval 3
the device documentation or just going about this incorrectly.
I have a touch screen that I've successfully run the python
test_hidwrap.py against.
After reviewing the HID class documentation and the device documentation
(http://home.eeti.com.tw/web20/drivers/Software%20Programming%20Guide_%20v1.5.pdf
),
I'm fairly certain I should be sending a diagnostics packet using
set_output_report.
The trouble is that every path I try results in a broken pipe error.
I've gathered that the path values ending in 0x00000000 are not
complete paths
and possibly additional bytes for neighboring paths?
Looking through the archives, it seems like others have had a similar
problem
to the one I'm having, but I've been unable to extract a solution from
these earlier
posts.
Any thoughts would be greatly appreciated! Thanks.
==> relevant python code:
iface = hidwrap.Interface(vendor_id=0xeef, product_id=0x0001)
iface.write_identification(sys.stdout)
iface.dump_tree(sys.stdout)
paths=[ [0x00010001,0x00010001,0x00010030],
[0x00010001,0x00010001,0x00010031],
[0x000d0004,0x000d0020,0x000d0042],
[0x000d0004,0x000d0020,0x000d0032],
[0x000d0004,0x000d0020,0x00010030],
[0x000d0004,0x000d0020,0x00010031]]
for path in paths:
try:
bytes = struct.pack('3b',0x0A,0x31,0x41)
print 'Sending buffer of size %i to screen: %s' %
(len(bytes), repr(bytes))
iface.set_output_report(path, bytes)
except:
print "%s: %s" % (sys.exc_info()[0], sys.exc_info()[1])
==> code output:
NOTICE: hid_init(): libhid 0.2.17 is being initialized.
<snip>
parse tree of HIDInterface 001/010[0]:
path: 0x00010001.0x00010001.0x00000000; type: 0x80
path: 0x00010001.0x00010001.0x00000000; type: 0x80
path: 0x00010001.0x00010001.0x00000000; type: 0x80
path: 0x00010001.0x00010001.0x00010030; type: 0x80
path: 0x00010001.0x00010001.0x00010031; type: 0x80
path: 0x000d0004.0x000d0020.0x000d0042; type: 0x80
path: 0x000d0004.0x000d0020.0x000d0032; type: 0x80
path: 0x000d0004.0x000d0020.0x00000000; type: 0x80
path: 0x000d0004.0x000d0020.0x00000000; type: 0x80
path: 0x000d0004.0x000d0020.0x00000000; type: 0x80
path: 0x000d0004.0x000d0020.0x00000000; type: 0x80
path: 0x000d0004.0x000d0020.0x00000000; type: 0x80
path: 0x000d0004.0x000d0020.0x00000000; type: 0x80
path: 0x000d0004.0x000d0020.0x00010030; type: 0x80
path: 0x000d0004.0x000d0020.0x00010031; type: 0x80
TRACE: hid_reset_parser(): resetting the HID parser for USB device
001/010[0]...
Sending buffer of size 3 to screen: '\n1A'
TRACE: hid_set_output_report(): looking up report ID...
TRACE: hid_prepare_parse_path(): preparing search path of depth 3
for parse tree of USB device 001/010[0]...
TRACE: hid_prepare_parse_path(): search path prepared for parse
tree of USB device 001/010[0].
TRACE: hid_format_path(): formatting device path...
WARNING: hid_find_object(): can't find requested item
0x00010001.0x00010001.0x00010030 of USB device 001/010[0].
TRACE: hid_set_output_report(): sending report ID 0x00 (length: 3)
to USB device 001/010[0]...
WARNING: hid_set_output_report(): failed to send report to USB device
001/010[0]:error sending control message: Broken pipe.
hidwrap.HIDError: (19, 'set_output_report: libhid: failed to set
report')
==> lsusb -d 0eef:0001 -vvv
Bus 001 Device 006: ID 0eef:0001 D-WAV Scientific Co., Ltd eGalax
TouchScreen
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x0eef D-WAV Scientific Co., Ltd
idProduct 0x0001 eGalax TouchScreen
bcdDevice 2.00
iManufacturer 1 eGalax Inc.
iProduct 2 USB TouchController
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 34
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 1 eGalax Inc.
bmAttributes 0xa0
Remote Wakeup
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Devices
bInterfaceSubClass 0 No Subclass
bInterfaceProtocol 0 None
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.00
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 141
Report Descriptor: (length is 141)
Item(Global): Usage Page, data= [ 0x01 ] 1
Generic Desktop Controls
Item(Local ): Usage, data= [ 0x01 ] 1
Pointer
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= [ 0x09 ] 9
Buttons
Item(Local ): Usage Minimum, data= [ 0x01 ] 1
Button 1 (Primary)
Item(Local ): Usage Maximum, data= [ 0x02 ] 2
Button 2 (Secondary)
Item(Global): Logical Minimum, data= [ 0x00 ] 0
Item(Global): Logical Maximum, data= [ 0x01 ] 1
Item(Global): Report Count, data= [ 0x02 ] 2
Item(Global): Report Size, data= [ 0x01 ] 1
Item(Main ): Input, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position
Non_Volatile Bitfield
Item(Global): Report Count, data= [ 0x01 ] 1
Item(Global): Report Size, data= [ 0x06 ] 6
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= [ 0x01 ] 1
Generic Desktop Controls
Item(Local ): Usage, data= [ 0x30 ] 48
Direction-X
Item(Local ): Usage, data= [ 0x31 ] 49
Direction-Y
Item(Global): Logical Minimum, data= [ 0x2a 0x00 ] 42
Item(Global): Logical Maximum, data= [ 0xbd 0x07 ] 1981
Item(Global): Physical Minimum, data= [ 0x00 0x00 ] 0
Item(Global): Physical Maximum, data= [ 0xff 0x0f ] 4095
Item(Global): Unit, data= [ 0x00 0x00 ] 0
Item(Global): Report Size, data= [ 0x10 ] 16
Item(Global): Report Count, data= [ 0x02 ] 2
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(Main ): End Collection, data=none
Item(Global): Usage Page, data= [ 0x0d ] 13
Digitizer
Item(Local ): Usage, data= [ 0x04 ] 4
Touch Screen
Item(Main ): Collection, data= [ 0x01 ] 1
Application
Item(Global): Report ID, data= [ 0x02 ] 2
Item(Local ): Usage, data= [ 0x20 ] 32
Stylus
Item(Main ): Collection, data= [ 0x00 ] 0
Physical
Item(Local ): Usage, data= [ 0x42 ] 66
Tip Switch
Item(Local ): Usage, data= [ 0x32 ] 50
In Range
Item(Global): Logical Minimum, data= [ 0x00 ] 0
Item(Global): Logical Maximum, data= [ 0x01 ] 1
Item(Global): Report Count, data= [ 0x02 ] 2
Item(Global): Report Size, data= [ 0x01 ] 1
Item(Main ): Input, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position
Non_Volatile Bitfield
Item(Global): Report Count, data= [ 0x06 ] 6
Item(Global): Report Size, data= [ 0x01 ] 1
Item(Main ): Input, data= [ 0x03 ] 3
Constant Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position
Non_Volatile Bitfield
Item(Global): Usage Page, data= [ 0x01 ] 1
Generic Desktop Controls
Item(Local ): Usage, data= [ 0x30 ] 48
Direction-X
Item(Global): Report Size, data= [ 0x10 ] 16
Item(Global): Report Count, data= [ 0x01 ] 1
Item(Global): Push, data=none
Item(Global): Unit Exponent, data= [ 0x0d ] 13
Item(Global): Unit, data= [ 0x33 ] 51
Item(Global): Physical Minimum, data= [ 0x00 0x00 ] 0
Item(Global): Physical Maximum, data= [ 0x99 0x28 ] 10393
Item(Global): Logical Minimum, data= [ 0x00 0x00 ] 0
Item(Global): Logical Maximum, data= [ 0xff 0x0f ] 4095
Item(Main ): Input, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position
Non_Volatile Bitfield
Item(Local ): Usage, data= [ 0x31 ] 49
Direction-Y
Item(Global): Logical Minimum, data= [ 0x00 0x00 ] 0
Item(Global): Logical Maximum, data= [ 0xff 0x0f ] 4095
Item(Global): Physical Minimum, data= [ 0x00 0x00 ] 0
Item(Global): Physical Maximum, data= [ 0xaf 0x19 ] 6575
Item(Main ): Input, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position
Non_Volatile Bitfield
Item(Global): Pop, data=none
Item(Main ): End Collection, data=none
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 0x0008 1x 8 bytes
bInterval 3