Hi,

I have a question about sending control/data bytes to a particular USB 
device. In short, this device is employed for receiving signals from 
distant sensors (e.g. for temperature measurements). Eventually I would 
need to get my hands on a live stream of data sent out by these sensors.

To control this all, I need to send certain sequences of control bytes 
to the device. But I am kind of stuck as I am not sure whether the 
device responses appropriately. Among the various things I have tried is 
the following (see also 
http://www.beyondlogic.org/usbnutshell/usb6.htm), which would inquire 
about the status of the device (I think...):


UsbDevice usbDevice = ....
byte[] data = new byte[2];
byte bmRequestType = (byte)10000000;
byte bRequest = (byte)0x00;
short wValue = 0;
short wIndex = 2;
UsbControlIrp controlIrp =
    usbDevice.createUsbControlIrp(bmRequestType,
                                  bRequest, wValue, wIndex);
controlIrp.setData(data);
usbDevice.asyncSubmit(controlIrp);


I observe that the request has been sent. Attached to the UsbDevice is a 
UsbDeviceListener, which informs me that the data has been sent. I have 
also attached to all USB pipes (there are two endpoints, call them 
DIRECTION_IN and DIRECTION_OUT) listeners.

Another example: the device also has its own set of command bytes, e.g. 
there is a simple ping command (according to the documentation of the 
device, the data buffer would contain just one byte):

usbPipe usbPipeOut = .....  // Attached to DIRECTION_OUT
byte[] data = new byte[1];
data[0] = (byte)0x00;
UbIrp irp = usbPipeOut.createUsbIrp();
irp.setData(data);
usbPipeOut.asyncSubmit(irp);

Again, I see that the request is made (no exceptions, everything seems 
fine). The listener reports to me that it was notified accordingly.

In both examples, the device is suppose to send a response. E.g. in the 
second example, the first byte of data buffer would contain (again) an 
0x00 (which it actually has, but of course is was already there). And in 
the first example (the status request), the device should return a two 
byte status report (I think, the USB standard is really massive, my 
interpretation may be completely wrong).

My question is two-fold:
1. Is the code given above correct?
2a. Example 2: Should I expect a response of the device sent through the 
USB pipe attached to DIRECTION_IN (so not through the USB pipe that was 
used to -send- the (control) command, attached to DIRECTION_OUT)?
2b. Example 1: Is the response by the device stored in the data buffer. 
But upon return, the data buffer is not modified at all.


Until now, I have not seen response (or there may have been a response, 
but I just don't know where to look for it).

Thanks for your help,

-- 
Andre H. Juffer              | Phone: +358-8-553 1161
Biocenter Oulu and           | Fax: +358-8-553-1141
Department of Biochemistry   | Email: andre.juf...@oulu.fi
University of Oulu, Finland  | WWW: www.biochem.oulu.fi/Biocomputing/
StruBioCat                   | WWW: www.strubiocat.oulu.fi
NordProt                     | WWW: www.nordprot.org
Triacle Biocomputing         | WWW: www.triacle-bc.com

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
javax-usb-devel mailing list
javax-usb-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/javax-usb-devel

Reply via email to