On Mon, Mar 23, 2009 at 12:12 AM, wind sh <[email protected]> wrote: > a. from the display result, could i be told that this device is HID?
The part of your descriptors you want to look at is: > bInterfaceClass : 0x03 From the HID spec (technically called "Device Class Definition for HID 1.11"), section 4.1 (page 7), the line you want to read is "The bInterfaceClass member of an Interface descriptor is always 3 for HID class devices." > b. the running result shows that "Could not claim interface : Device or > resource busy', from the source code, u can see that i did interf.claim() > and interf.release(), why it still happen? Your device is already driven by the native Linux driver. You need to remove the native Linux driver. One way is to "force" claiming it from javax.usb. http://javax-usb.org/faq.html#force_claim > c. i received 2 device at work, 1 is attached USB device, this device's info > is collected/displayed at the following, another remote wireless device can > send signal/data to this attached USB device. > from my program, u can see that i opened the pipe, but how can my > program know remote device whether send signal to this device or not? should > i implement listener? > also, how can my program know how many bytes remote device send to > attached USB device? and how to read in? You need to read the HID spec. Download it here. http://www.usb.org/developers/devclass_docs/HID1_11.pdf or from this web page http://www.usb.org/developers/hidpage/ You might be able to read your device's HID report descriptors (which you have not printed below) to find out how to talk to your device. It's quite possible that they will not tell you enough, and you'll need to either read some speciifcation for your device, or you could try to read someone else's driver for your device to see how to talk to it. > > follow your advise, i make big progress, so any further help is greatly > appreciated. > > tks in advance > > john > > > > the display info: > ------------------------------------------------------------------------------------------- > devics manufactur is Microchip Technology Inc. > devics product string is 802.15.4 2.4GHz Packet Sniffer > devics product desc is bLength : 18 > bDescriptorType : 0x01 > bcdUSB : 0200 > bDeviceClass : 0x00 > bDeviceSubClass : 0x00 > bDeviceProtocol : 0x00 > bMaxPacketSize0 : 8 > idVendor : 0x04d8 > idProduct : 0x000e > bcdDevice : 0000 > iManufacturer : 1 > iProduct : 2 > iSerialNumber : 0 > bNumConfigurations : 1 > devics version is 0.0.0 > USB version is 2.0.0 > this is USB function > > 802.15.4 2.4GHz Packet Sniffer is configured > active config is com.ibm.jusb.usbconfiguration...@1787038 > active config number is 1 > active config include > com.ibm.jusb.usbconfiguration...@1787038 > bNumInterfaces()=1 > print IO begin > all settings is [com.ibm.jusb.usbinterface...@55571e] > usb configuration belong to =com.ibm.jusb.usbconfiguration...@1787038 > usb configuration desc = bLength : 9 > bDescriptorType : 0x04 > bInterfaceNumber : 0 > bAlternateSetting : 0 > bNumEndpoints : 2 > bInterfaceClass : 0x03 > bInterfaceSubClass : 0x00 > bInterfaceProtocol : 0x00 > iInterface : 0 > getInterfaceString = null > Endpoint address =129 > max packet size=64 bytes > Endpoint address =129 > max packet size=64 bytes > print IO end > test IO begin > javax.usb.UsbPlatformException: Could not claim interface : Device or > resource busy > at > com.ibm.jusb.os.linux.JavaxUsb.errorToUsbException(JavaxUsb.java:73) > at > com.ibm.jusb.os.linux.LinuxInterfaceOsImp.claim(LinuxInterfaceOsImp.java:88) > at com.ibm.jusb.UsbInterfaceImp.claim(UsbInterfaceImp.java:109) > at com.ibm.jusb.UsbInterfaceImp.claim(UsbInterfaceImp.java:83) > at TraverseUSB.testIO(TraverseUSB.java:161) > at TraverseUSB.traverse(TraverseUSB.java:62) > at TraverseUSB.traverse(TraverseUSB.java:33) > at TraverseUSB.traverse(TraverseUSB.java:33) > at TraverseUSB.main(TraverseUSB.java:16) > test IO end > > > the partial source code: > ------------------------------------------------------------------------------------------------ > > public static void testIO(UsbDevice device) { > try { > // Access to the active configuration of the USB device, obtain > // all the interfaces available in that configuration. > UsbConfiguration config = device.getActiveUsbConfiguration(); > List totalInterfaces = config.getUsbInterfaces(); > // Traverse through all the interfaces, and access the endpoints > // available to that interface for I/O. > for (int i=0; i<totalInterfaces.size(); i++) { > UsbInterface interf = (UsbInterface) totalInterfaces.get(i); > interf.claim(); > System.out.println(" all settings is "+interf.getSettings()); > System.out.println(" usb configuration belong to > ="+interf.getUsbConfiguration()); > System.out.println(" usb configuration desc = > "+interf.getUsbInterfaceDescriptor()); > System.out.println(" getInterfaceString = > "+interf.getInterfaceString()); > List totalEndpoints = interf.getUsbEndpoints(); > for (int j=0; j<totalEndpoints.size(); j++) { > // Access the particular endpoint, determine the direction > // of its data flow, and type of data transfer, and open the > // data pipe for I/O. > UsbEndpoint ep = (UsbEndpoint) totalEndpoints.get(i); > int direction = ep.getDirection(); > int type = ep.getType(); > UsbPipe pipe = ep.getUsbPipe(); > pipe.open(); > // Perform I/O through the USB pipe here. > pipe.close(); > } > interf.release(); > } > } catch (Exception e) { e.printStackTrace();} > } > > > > --- On Tue, 3/17/09, Dan Streetman <[email protected]> wrote: > > From: Dan Streetman <[email protected]> > Subject: Re: HID device > To: [email protected] > Cc: [email protected] > Date: Tuesday, March 17, 2009, 6:27 PM > >> a. how to check the attached device is HID device? > > While "HID device" is common in referring to such devices, > technically > it is each device interface that implements the HID class. > > So you should check the device's interface(s), the interface > descriptor for each interface will have a class. If that class is > HID, then the interface supports the HID protocol. See the javax.usb > API, specifically the UsbInterface and UsbInterfaceDescriptor. The > API is part of the source code or on the website: > http://javax-usb.org/jdoc/ > >> b. do u have any example to show us about implementing USB<->HID > translation >> on top of javax.usb? > > No, not really. HID is actually not nearly as complicated as most > other protocols, but it's still fairly complicated. However, for many > HID devices, there is a very limited number of reports that they use, > so many times you don't have to actually implement the entire HID > spec, and if you're just talking to this one device that you know the > specific HID Report descriptors to (i.e. you know all its reports), > then you can "fake" talking HID to it. For example, you can parse > the > device's HID report descriptor(s) manually (i.e., read the binary > yourself and parse it) and then you know the specific reports the > device will send/receive. You then don't need to implement a HID > parser, because you're only talking to the one HID device and you can > code directly to what its HID reports will look like. > >> c. if you do not have examples handy, so what is the approach/advise/steps >> to implement USB<->HID? >> d. where i can find more info about HID protocol specfication? > > First you will need to read the HID spec. If you haven't read the USB > spec either, you need to read that too, Chapter 5 and 9 I think (not > sure) are the relevant parts. The HID and USB specs are both > available from http://usb.org > >> e. javax-usb support both USB 1.x and USB 2.x? > > What specifically do you mean by "support"? Do you mean, will USB > 2.0 > devices work with javax.usb? Yes, they will. > > > On Tue, Mar 17, 2009 at 5:39 PM, wind sh <[email protected]> wrote: >> >> I asked you the question regarding zigbee device last week, and get lots > of >> help from you... >> >> today i received the actual device, and was told that it is HID > device..and >> this HID device received remote data by zigbee protocol... >> >> i reviewed your site's FAQ again, it says the following: >> >> HID is a protocol layered on top of USB, so you can use any HID device > with >> javax.usb. However you will need to implement USB<->HID translation > on top >> of javax.usb. You will need to be familiar with the HID specification to > do >> this. >> >> then, i have the following as the following: >> >> a. how to check the attached device is HID device? >> >> b. do u have any example to show us about implementing USB<->HID > translation >> on top of javax.usb? >> >> c. if you do not have examples handy, so what is the approach/advise/steps >> to implement USB<->HID? >> >> d. where i can find more info about HID protocol specfication? >> >> e. javax-usb support both USB 1.x and USB 2.x? >> >> tks in advance, your comments is really helpful. >> >> john >> > > ------------------------------------------------------------------------------ _______________________________________________ javax-usb-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
