Hu Jan and everyone. I believe you're can help me.
Here is set of descriptors
const uint8_t HID_DeviceDescriptor[0x12] = {
0x12, // overall descriptor length
USB_DEVICE_DESCRIPTOR_TYPE, // bDescriptorType - Device descriptor
0x00, 0x02, // bcdUSB usb 2.0
// class, subclass
0x00, //bDeviceClass
0x00, //bDeviceSubClass
0x00, //bDeviceProtocol
0x40, //bMaxPacketSize - max size of packets
// vid pid
0x25, 0x09, //idVendor
0x37, 0x12, //idProduct
0, 0x01, // bcdDevice rel. DEVICE_VER_H.DEVICE_VER_L
1, //Index of string descriptor describing manufacturer //old value 1
2, //Index of string descriptor describing product //old value 2
3, //Index of string descriptor describing the device serial number //old value 3
0x01 // bNumConfigurations - configurations.
};
const uint8_t HID_ConfigDescriptor[0x29] = {//CustomHID_ConfigDescriptor
0x09,//config descr standart value
0x02,// Type (config descr)
0x22,//Totallength low half word (the length of the configuration descriptor, )
0x00,//Totallength hi half word (the interface descriptor, the HID descriptor, and one endpoint descriptor.)
0x01,//NumInterfaces This item defines the number of interface settings contained in this configuration.
0x01,//bConfigurationValue (Used in Get_Configuration and Set_Configuration to identify this configuration.)
0xB1,//iConfiguration (string index for a string that describes this configuration.) old 0x01
0x80,//bmAttributes
0x32,//MaxPower (in 2 mA units) (100ma)
0x09,// bLength
0x04,// bDescriptorType (Interface)
0x00,// bInterfaceNumber (only one interface)
0x00,// bAlternateSetting (for multiply interfaces)
0x01,// bNumEndpoints (only one EP)
0x03,// bInterfaceClass (3 = HID)
0x00,// bInterfaceSubClass
0x00,// bInterfaceProcotol
0xC1, // iInterface old 0x00
0x09, // bLength
0x21, // bDescriptorType
0x01,// bcdHID low
0x01,// bcdHID hi
0x00,// bCountryCode
0x01,//bNumDescriptors
0x22,// bDescriptorType - Hid report descriptor
Custom_HID_RepDesc_LEN_INOUT,// total length of report low//this is total length of report descriptor
0x0,// total length of report hi
0x07,//EP descr
0x05,// bDescriptorType (EP)
0x01,//ep address and direction addr=1 dir=OUT (old 0x81 addr=1 dir=IN)
0x03,//bmAttributes
0x0A,// MaxPacketSize (low)//old 2
0x00,// MaxPacketSize (hi)
10,// bInterval
0x07,//EP descr
0x05,// bDescriptorType (EP)
0x81,//ep address and direction addr=1 dir=IN
0x03,//bmAttributes
0x0A,// MaxPacketSize (low)//old 2
0x00,// MaxPacketSize (hi)
10// bInterval
};
const uint8_t Custom_HID_ReportDescriptorINOUT[Custom_HID_RepDesc_LEN_INOUT] = {
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x00, // USAGE (Undefined)
0xa1, 0x01, // COLLECTION (Application)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x02, // REPORT_COUNT (2)
0x09, 0x00, // USAGE (Undefined)
0x81, 0x82, // INPUT (Data,Var,Abs,Vol)
0x95, 0x05, // REPORT_COUNT (5)
0x09, 0x00, // USAGE (Undefined)
0x91, 0x82, // OUTPUT (Data,Var,Abs,Vol)
0xc0 // END_COLLECTION
};//
My device recognized by Windows and I can send bytes:
HANDLE file=CreateFile(ptrDetail->DevicePath,GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_WRITE|FILE_SHARE_READ,
(LPSECURITY_ATTRIBUTES)NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0);
char arr[6] = {0x0,0x31,0x02,0xA1,0xA2,0x13};/
WriteFile(file,arr,6,&sended,NULL);
But I can't perform Readfile():
char rxArr[20];
DWORD received;
memset(rxArr, 0, 20);
ReadFile(file,rxArr,3,&received,NULL);
Here program causing loop and I can't retrieve answer.
I.e. Reading not working.
If look at USB BUS using logic analyzer i see OUT packet when program perforw WriteFile() (PId, Address etc. all OK)
When host perform ReadFile() - NOTHING.
I think USB driver block my request.