Hi Jan,
Thank you for your response comments.
The descriptors for the HID device define it to be "user defined" - and not a system mouse or keyboard. I have tried many times to get ReadFile and WriteFile to work, however they always fail. Currently the only method by which I am able to transfer data to/from the peripheral device is via HidD_SetFeature and HidD_GetFeature VB commands.
(a) The device is successfully detected, and registered for device notifications.
(b) The writeHandle is created using VB command:
writeHandle = CreateFile(CapturedDevicePathName, GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)
(c) The writeHandle is confirmed OK since writeHandle.IsInvalid = False
(d) The output report buffer is initialized with some data.
(e) The output report buffer is sent to the peripheral device using VB command:
WriteFile(writeHandle, OutputReportBuffer, OutputReportBuffer.Length, NumberOfBytesWritten, IntPtr.Zero)
(f) The number of bytes written to the peripheral device is zero (ie. NumberofBytesWritten=0) and the Last Error Code (Err.LastDllError) is "1" (ie. "incorrect function").
(g) The readHandle is attempted to be created using VB command:
readHandle = CreateFile(CapturedDevicePathName, GENERIC_READ, FILE_SHARE_READ Or FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0)
(h) The readHandle failed since readHandle.IsInvalid = True with the Last Error Code (Err.LastDllError) = "0".
The peripheral device is defined as:
1. Configuration Descriptor: 9 bytes, Type=2, TotalLength=0041 bytes, NumInterfaces=1, ConfigValue=1, Configuration=0, Attributes=self-powered + RWU supported, Max Power=2mA
2. Interface Descriptor: 9 bytes, Type=4, Interface=0, No alternate, 2 endpoints, InterfaceClass=HID, SubClass=0, Protocol=0, Interface=0
3. HID Descriptor: 9 bytes, Type=33=HID, HID Rev 1.1, country code = 0, 1 report descriptor, DescriptorType=34=Report, Report Descriptor Length=47
4. EndPoint Descriptor: 7 bytes, Type=5=EndPoint, EndPointAddress=82=EP2-IN Attributes=interrupt(03), MaxPacketSize=0064, Poll Interval=10msec
5. EndPoint Descriptor: 7 bytes, Type=5=EndPoint, EndPointAddress=01=EP1-OUT Attributes=control(03), MaxPacketSize=0064, Poll Interval=10msec
This has been verified (using USB Analyzer) as:
Device Descriptor:
bLength = 18
bDescriptorType = 1 (device)
bcdUSB = 0x0110 (Rev 1.1)
bDeviceClass = 0x00
bDeviceSubClass = 0x00
bDeviceProtocol = 0x00
bMaxPacketSize0 = 64
idVendor = 0x0B6A
idProduct = 0xABE1
bcdDEvice = 0x0100
iManufacturer = 1
iProduct = 2
iSerialNumber = 3
bNumCOnfigurations = 1
Configuration Descriptor:
bLength = 9
bDescriptorType = 2 (configuration)
wTotalLength = 41
bNumInterfaces = 1
bConfigurationValue = 1
iConfiguration = 0
bmAttributes = 1 (self-powered)
bmAttributes = 1 (remote wakeup)
bMaxPower = 2 mA
Interface Descriptor:
bLength = 9
bDescriptorType = 4 (interface)
bInterfaceNumber = 0
bAlternateSetting = 0
bNumEndpoint = 2
bInterfaceClass = 0x03 (HID)
bInterfaceSubClass = 0x00
bInterfaceProtocol = 0x00
iInterface = 0
HID Descriptor:
bLength = 9
bDescriptorType = 0x21 (HID)
bcdHID = 0x0110
bCountryCode = 0
bNumDescriptors = 1
bDescriptorType = REPORT (type 34)
wDescriptorLength = 47
EndPoint Descriptor:
bLength = 7
bDescriptorType = 5 (Endpoint)
bEndpointAddress = 0x82 (Endpoint 2 - IN)
bmAttributes = 0x03 (interrupt)
wMaxPacketSoze = 0x0040 (64)
bInterval = 0x0A (10ms)
EndPoint Descriptor:
bLength = 7
bDescriptorType = 5 (Endpoint)
bEndpointAddress = 0x01 (Endpoint 1 - OUT)
bmAttributes = 0x03 (interrupt)
wMaxPacketSoze = 0x0040 (64)
bInterval = 0x01 (1ms)
Report Descriptor: VENDOR-DEFINED Device (Input Report of 12 bytes, Output Report of 7 bytes, Feature Report of 8 bytes)
0x06,0xFFA0, // Usage Page (vendor defined)
0x09,0x01, // Usage (vendor defined)
0xA1,0x01, // Collection
0x09,0x01, // Usage (vendor defined)
0x15,0x00, // Logical Minimum = 0
0x26,0x00FF // Logical Maximum = 255
0x95,0x0C, // Report Count = 12
0x75,0x08, // Report Size = 8
0x81,0x02, // Input(Data,Variable,Absolute)
0x09,0x05, // Usage (vendor defined)
0x15,0x00, // Logical Minimum = 0
0x26,0x00FF // Logical Maximum = 255
0x95,0x06, // Report Count = 6
0x75,0x08, // Report Size = 8
0xB1,0x02, // Feature(Data,Variable,Absolute)
0x09,0x04, // Usage (vendor defined)
0x15,0x00, // Logical Minimum = 0
0x26,0x00FF // Logical Maximum = 255
0x95,0x07, // Report Count = 7
0x75,0x08, // Report Size = 8
0x91,0x02, // Output(Data,Variable,Absolute)
0xC0 // End Collection
I hope that this information will assist in resolving the faulty operation of the VB interface communicating with the peripheral device. However, I don't know whether this is the result of faulty specification of the peripheral device or faulty VB commands trying to access the report structures.
Thank you.