Two instances of Teensy 2.0 in HID query Java using hidapi-1.1.jar

Status
Not open for further replies.

George

Member
Was wondering why I get two instances of the Teensy as a HID in my Java code. Here is a short snip of the java code, I'm using the hidapi-1.1.jar.

{
HIDManager manager = HIDManager.getInstance();
HIDDeviceInfo[] devs = manager.listDevices();
System.err.println("Devices:\n\n");
for(int i=0;i<devs.length;i++)
{
System.err.println(""+i+".\t"+devs);
System.err.println("---------------------------------------------\n");
}
System.gc();
}

Here is a screen shot that shows both in the array of variables:

Screen Shot 2012-12-13 at 7.30.49 AM.png

My issue is that when I call for the specific devices using:
HIDManager hid_mgr = HIDManager.getInstance();
dev = hid_mgr.openById(VENDOR_ID, PRODUCT_ID, null);
I get the "wrong" one and the data that I can obtain is not correct. The rawhid_test program does show the correct data.
 
Last edited:
Here is a better view of the HID data that is displayed. The difference between the two is the usage_page and the usage.

6 HIDDeviceInfo [path=USB_16c0_0486_0x7fa02c25d4c0, vendor_id=5824, product_id=1158, serial_number=, release_number=258, manufacturer_string=,
product_string=Teensyduino RawHID Device, [FONT=Arial Black]usage_page=65481, usage=4,[/FONT] interface_number=-1]

8 HIDDeviceInfo [path=USB_16c0_0486_0x7fa02c25db50, vendor_id=5824, product_id=1158, serial_number=, release_number=258, manufacturer_string=,
product_string=Teensyduino RawHID Device, [FONT=Arial Black]usage_page=65451, usage=512,[/FONT] interface_number=-1]
 
From hardware/teensy/cores/usb_rawhid/usb_private.h:

Code:
#define RAWHID_USAGE_PAGE	0xFFAB  // recommended: 0xFF00 to 0xFFFF
#define RAWHID_USAGE		0x0200  // recommended: 0x0100 to 0xFFFF

0xFFAB is 65451 so that explains one of your values. The range 0xFF00 to 0xFFFF is 'vendor defined'.
 
Yeah, I figured out that the instance I want is the second one. At this point I am just wondering why it shows up twice when I list the devices in my code. It is not the only device that shows up twice so it must be "normal" or have something to do with the library I am using to list the HID devices. The good news is that I can identify the instance I want and open it, read, write, etc., and I get the data as expected. When I opened the other instance the data that was presented was not correct.
 
Yes, usage page 65481 (0xFFC9) & usage 4 is the emulated serial, so Serial.print() can send to the Arduino Serial Monitor.
 
Status
Not open for further replies.
Back
Top