PDA

View Full Version : Two instances of Teensy 2.0 in HID query Java using hidapi-1.1.jar



George
12-13-2012, 12:40 PM
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[i]);
System.err.println("---------------------------------------------\n");
}
System.gc();
}

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

86

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.

George
12-14-2012, 02:19 AM
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, usage_page=65481, usage=4, 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, usage_page=65451, usage=512, interface_number=-1]

Nantonos
12-14-2012, 04:55 PM
From hardware/teensy/cores/usb_rawhid/usb_private.h:


#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'.

George
12-14-2012, 05:30 PM
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.

Nantonos
12-14-2012, 05:34 PM
I wonder if usage_page=65481 is the Arduino serial debug emulation.

PaulStoffregen
12-14-2012, 08:54 PM
Yes, usage page 65481 (0xFFC9) & usage 4 is the emulated serial, so Serial.print() can send to the Arduino Serial Monitor.