signal11 / hidapi

A Simple library for communicating with USB and Bluetooth HID devices on Linux, Mac, and Windows.
http://www.signal11.us/oss/hidapi/
Other
2.46k stars 901 forks source link

CreateFile failure #81

Open briancg opened 12 years ago

briancg commented 12 years ago

Hello, I am trying to use hidtest in VC++ 2010 express to communicate with an Atmel dev kit - set up as a USB HID device.

The first call to CreateFile fails (from hid_open from hid_enumerate).

Any suggestions as to what I am missing ?

Thanks Brian

signal11 commented 12 years ago

Did you modify the hidtest to try to open your device VID and PID? Did you try with the testgui?

briancg commented 12 years ago

Thanks for the quick response. Yes - handle = hid_open(0x3eb, 0x2304, NULL);
Testgui does not recognise any devices ! - not even 3 mice I tried ! - or this dev kit Just before the open_device call, device_interface_detail_data shows this content : device_interface_detail_data->DevicePath 0x0017363c "\?\hid#vid_03eb&pid_2304#7&34b7ee55&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}" Then open device returns with write_handle = 0xffffffff It appears that the correct device has been found ?

Thanks Brian

DevicePath = 0x00ef363c "\?\hid#vid_15d9&pid_0a4d#7&231f775c&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}" The vid & pid refer to a mouse.

briancg commented 12 years ago

please ignore last 2 lines above !

signal11 commented 12 years ago

Windows won't show keyboards and mice. You'd need something like a custom HID device or a joystick.

Download USBView and see if your device is showing up at all. I can't find a download link on Microsoft's website, so get it from FTDI: http://www.ftdichip.com/Support/Utilities.htm

briancg commented 12 years ago

Thanks - it does show - details as below. I did try to change it away from a mouse to avoid the windows issue...

Device Descriptor: bcdUSB: 0x0200 bDeviceClass: 0x00 bDeviceSubClass: 0x00 bDeviceProtocol: 0x00 bMaxPacketSize0: 0x40 (64) idVendor: 0x03EB (Atmel Corporation) idProduct: 0x2304 bcdDevice: 0x1000 iManufacturer: 0x01 0x0409: "ATMEL" iProduct: 0x02 0x0409: "AVR32 UC3 HID" iSerialNumber: 0x03 0x0409: "1.0.0.0.0.0.A" bNumConfigurations: 0x01

ConnectionStatus: DeviceConnected Current Config Value: 0x01 Device Bus Speed: Full Device Address: 0x02 Open Pipes: 1

Endpoint Descriptor: bEndpointAddress: 0x81 IN Transfer Type: Interrupt wMaxPacketSize: 0x0008 (8) bInterval: 0x05

Configuration Descriptor: wTotalLength: 0x0022 bNumInterfaces: 0x01 bConfigurationValue: 0x01 iConfiguration: 0x00 bmAttributes: 0xC0 (Bus Powered Self Powered ) MaxPower: 0x32 (100 Ma)

Interface Descriptor: bInterfaceNumber: 0x00 bAlternateSetting: 0x00 bNumEndpoints: 0x01 bInterfaceClass: 0x03 (HID) bInterfaceSubClass: 0x00 bInterfaceProtocol: 0x02 iInterface: 0x00

HID Descriptor: bcdHID: 0x0111 bCountryCode: 0x00 bNumDescriptors: 0x01 bDescriptorType: 0x22 wDescriptorLength: 0x0034

Endpoint Descriptor: bEndpointAddress: 0x81 IN Transfer Type: Interrupt wMaxPacketSize: 0x0008 (8) bInterval: 0x05

signal11 commented 12 years ago

It still says mouse: bInterfaceProtocol: 0x02

See the HID specification for more details: http://www.usb.org/developers/hidpage/

signal11 commented 12 years ago

Does Atmel provide a custom HID device demo? Picking at descriptors is error-prone when you're new to USB.

briancg commented 12 years ago

Thanks ! I was wondering if I'd missed something. Atmel's windows demo is Java based, and out of date - so does not work. Thanks for the guidance - will advise on progress.