You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(23) |
Nov
(37) |
Dec
(2) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(32) |
Feb
(20) |
Mar
(8) |
Apr
(10) |
May
(5) |
Jun
(26) |
Jul
(7) |
Aug
(18) |
Sep
(14) |
Oct
(22) |
Nov
(23) |
Dec
(19) |
| 2004 |
Jan
(29) |
Feb
(15) |
Mar
(2) |
Apr
(15) |
May
|
Jun
(16) |
Jul
(13) |
Aug
(1) |
Sep
(29) |
Oct
(15) |
Nov
(19) |
Dec
(2) |
| 2005 |
Jan
(12) |
Feb
(9) |
Mar
(19) |
Apr
(18) |
May
(25) |
Jun
(5) |
Jul
(35) |
Aug
(13) |
Sep
(13) |
Oct
(12) |
Nov
(22) |
Dec
(19) |
| 2006 |
Jan
(23) |
Feb
(19) |
Mar
(6) |
Apr
(2) |
May
(12) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
(4) |
Oct
(4) |
Nov
(14) |
Dec
(2) |
| 2007 |
Jan
(2) |
Feb
(1) |
Mar
(2) |
Apr
|
May
(6) |
Jun
|
Jul
(20) |
Aug
(34) |
Sep
(2) |
Oct
|
Nov
(24) |
Dec
(17) |
| 2008 |
Jan
(8) |
Feb
(36) |
Mar
(7) |
Apr
(11) |
May
(1) |
Jun
(19) |
Jul
(16) |
Aug
(72) |
Sep
(6) |
Oct
|
Nov
(1) |
Dec
(13) |
| 2009 |
Jan
(20) |
Feb
(18) |
Mar
(33) |
Apr
(42) |
May
(16) |
Jun
(2) |
Jul
|
Aug
(8) |
Sep
(19) |
Oct
(9) |
Nov
(3) |
Dec
(7) |
| 2010 |
Jan
(1) |
Feb
|
Mar
(3) |
Apr
|
May
|
Jun
(8) |
Jul
(11) |
Aug
(2) |
Sep
(3) |
Oct
(2) |
Nov
(6) |
Dec
(2) |
| 2011 |
Jan
|
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
(3) |
Apr
(3) |
May
(1) |
Jun
(1) |
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2013 |
Jan
|
Feb
(5) |
Mar
|
Apr
|
May
(8) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(24) |
Nov
|
Dec
(3) |
| 2014 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
| 2015 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
(1) |
Oct
(1) |
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Trygve L. <tr...@in...> - 2018-05-11 08:56:49
|
on., 09.05.2018 kl. 18.06 +0200, skrev Peter Stoiber: > Hello, > > I sucessfully build the Library and wrote some Lines to search for > connected devices in Java, but the program cant find anything. The > low level api works with the prebuiled jar files and I can find the > connected devices. The system is Linux Mint 18.3 64bit. Does it work if you run it with sudo? -- Trygve |
|
From: Peter S. <sto...@gm...> - 2018-05-09 16:06:35
|
Hello, I sucessfully build the Library and wrote some Lines to search for connected devices in Java, but the program cant find anything. The low level api works with the prebuiled jar files and I can find the connected devices. The system is Linux Mint 18.3 64bit. Regards, Peter |
|
From: Peter S. <sto...@gm...> - 2018-05-06 10:02:14
|
Finally I solved to rebuild the 3 Libs (Javxx-usb Javax-usb-ri Javax-usb-ri-linux) with ant (64bit) and could load the Javax-usb sucessful to my project |
|
From: Peter S. <sto...@gm...> - 2018-05-05 18:27:33
|
Hello, I'm going to start with Javax-usb and looking for some support. My operating system is linux mint 18.3. (64 bit). I want to include the high level api of the usb4java to a Java project, but allways facing different javax.usb. errors in eclipse, when using the api. Is there a standard way for including the api to linux, because the last rpm package ( RPM ) <https://sourceforge.net/projects/javax-usb/files/OldFiles/javax-usb-ri-0.10.4-1.i386.rpm/download> is quite old and only for 32 bit environment. Thanks in advance, Peter |
|
From: Andres <nor...@ba...> - 2015-10-07 05:43:41
|
Andres te ha dejado un mensaje Puedes responder immediatamente usando nuestro sistema de intercambio de mensajes. Descubre tu mensaje... http://us1.badoo.com/andres.alcarraz/in/b4YFDgiChBs/?lang_id=7&g=57-0-4&m=61&mid=5614b105000000000007004d06251e050192d79700a5 Otras personas esperando: Si el link no funciona, copia y pégalo en la barra de tu buscador. Has recibido este email de Badoo Trading Limited (dirección postal a continuación). Si no deseas recibir comunicaciones por parte de Badoo en el futuro, haz clic aquí para desactivarlas: https://us1.badoo.com/impersonation.phtml?lang_id=7&email=javax-usb-devel%40lists.sourceforge.net&block_code=b54466&m=61&mid=5614b105000000000007004d06251e050192d79700a5&g=0-0-4. Badoo Trading Limited es una sociedad de responsabilidad limitada registrada en Inglaterra y Gales con número 7540255 y domicilio en Media Village, 131 - 151 Great Titchfield Street, Londres, W1W 5BB. |
|
From: Malcolm C. <cru...@gm...> - 2015-09-18 12:29:21
|
Hello all, I'm trying to get USB bus and port information for a given USBDevice, to map it to /dev/bus/usb/ on Ubuntu. I can get the port with device.getParentUsbPort().getPortNumber(), but not the bus. Is this possible without going down to LibUsb level? And if not, how do I convert a USBDevice to LibUsb's Device to get the info that way? Malcolm |
|
From: Dara M. <d....@ca...> - 2015-08-13 16:53:14
|
Hi,
I'm new in development using javax-usb and I've got a problem which I don't understand.
I'm using javax-usb to connect a card reader to a printer.
Here is my code to claim my UsbInterface and to open an UsbPipe
protected void init() throws UsbException {
UsbConfiguration config = device.getActiveUsbConfiguration();
UsbEndpoint endptIn = null;
UsbEndpoint ep = null;
if (config != null) {
interf = config.getUsbInterface((byte) 0);
}
/** Claim the UsbInterface. */
try {
if (!interf.isClaimed()) {
interf.claim();
}
} catch (UsbClaimException e) {
e.printStackTrace();
} catch (UsbNotActiveException e) {
e.printStackTrace();
} catch (UsbDisconnectedException e) {
e.printStackTrace();
}
/** Get the endpoint. */
List eps = interf.getUsbEndpoints();
boolean foundEp = false;
for (int j = 0; j < eps.size(); j++) {
ep = (UsbEndpoint) eps.get(j);
int t = ep.getType();
Logs.debug(className, functionName, "endpointaddress: " + ep.getUsbEndpointDescriptor().bEndpointAddress());
if (t == UsbConst.ENDPOINT_TYPE_INTERRUPT
&& ep.getDirection() == UsbConst.ENDPOINT_DIRECTION_IN
&& ep.getUsbEndpointDescriptor().bEndpointAddress() == SCHOMAKER_ENDPOINT_ADDR) {
endptIn = ep;
foundEp = true;
break;
}
}
if (!foundEp) {
for (int j = 0; j < eps.size(); j++) {
ep = (UsbEndpoint) eps.get(j);
int t = ep.getType();
if (t == UsbConst.ENDPOINT_TYPE_INTERRUPT
&& ep.getDirection() == UsbConst.ENDPOINT_DIRECTION_IN) {
endptIn = ep;
foundEp = true;
break;
}
}
}
/** Get and open the UsbPipe. */
pipe = endptIn.getUsbPipe();
if (!pipe.isOpen()) {
pipe.open();
}
}
Here is how I'm reading the data:
public void startReader() {
/** We need to create the Thread-class in this method. */
new Thread() {
public void run() {
stop_flag = true;
while (stop_flag) {
try {
byte[] temp = new byte[buffer_size];
irpIn = pipe.createUsbIrp();
irpIn.setData(temp);
pipe.asyncSubmit(irpIn);
irpIn.waitUntilComplete();
byte[] buffer = new byte[irpIn.getActualLength()];
//reading the data
Thread.sleep(50);
} catch (Exception e) {
//in case of disconnect error occurs.
Logs.error(className, functionName, "exception of send command " + e);
}//end try catch
}//end while
}//end run()
}.start();
}
And when I'm trying to release:
public void releaseUsbInterface() throws UsbException, UsbDisconnectedException {
if (interf != null) {
pipe.close();
interf.release();
}
}
When I'm doing this, the code is blocked on the line interf.release() and I can't do anything.
I have to unplug manually the card reader.
Do you have any idea what is the problem?
Best regards,
Dara Mom
|
|
From: Siva K. <inv...@gm...> - 2015-03-23 07:52:31
|
When i scanned using scanner attached through USB im getting 8 bytes of data The data we are getting in the format of [0,0,30,0,0,0,0,0] Any one have idea why we are getting data in this format with the value in 3rd position. The Hex code corresponding to ASCII is 31. But we are getting one number less than that. We are not unable to get the default starting or end of the scanned data. We are using Honeywell Xenon 1900 scanner Regards Siva |
|
From: Ajay S. <gnr...@gm...> - 2014-09-10 14:47:46
|
I am trying to communicate with usb webcam.While sniffing with usb sniffer under request column I found strange requests,and I can not send them using usb4j api.These are(exact words under request column in usb sniffer ) 1.Class Interface 2.Select Interface 3.Set Power While using device.createUsbControlIrp() and device.syncSubmit(usbcontrolirp) sniffer always shows 'control transfer' text under request column.And I can not copy above 3 in anyway with this So why & what are these requests and how can I issue them? |
|
From: Klaus R. <k...@ai...> - 2014-03-22 16:56:56
|
Hi, I have a device where I have to switch to configuration 2, interface 1 and alternate setting 2. I now wonder what is the correct way to do this with javax-usb? There are no methods for setting the configuration or alternate setting, so is the user responsible for sending the necessary standard control requests himself? Or is the javax-usb implementation responsible for automatically setting the right configuration and alternate setting when claiming the interface? Let's look at some example code: UsbConfiguration config = device.getUsbConfiguration((byte) 2); UsbInterface iface = config.getUsbInterface((byte) 1); UsbInterface setting = iface.getSetting((byte) 2); setting.claim(); Is that the correct way to do it? My own javax-usb implementation currently throws a UsbNotActiveException because the interface (and the configuration) is indeed not active. Now I wonder if my implementation violates the javax-usb specs and I have to change my implementation so it automatically selects the configuration and alternate setting on claim or if the user is responsible for that by manually sending SET_CONFIGURATION and SET_INTERFACE control requests before claiming the interface. -- Klaus Reimer <http://www.ailis.de/~k/> [2FC4 CCA0 C03B 1E5F 1ACC 94D6 6461 426C E734 75A1] |
|
From: Hsieh D. <di...@gm...> - 2013-12-03 10:24:28
|
Many Thanks for Andres Alcarraz, your message give me a hope So all I need to do is compile that native library libJavaxUsb.so to 64 bit Could you tell me the tool / book / direction that I can try to compile thta libJavaxUsb.so to 64bits 1. Makefile 2. gcc 3. Ant 4. Eclipse 5. JNI JDK 6. GLPK for Java Above uncertain items was I search from the net All of your advice I will appreciate |
|
From: Andrés A. <alc...@gm...> - 2013-12-02 14:26:58
|
You have to compile the native library libJavaxUsb.so to 64 bits. El 02/12/13 07:17, Hsieh Dinow escribió: > Any of your answer or advice will be strongly appreciated > I used JSR80 components on Java-32bit. And everything is okay with > below configuration > > * /JRE/LIB/EXT/jsr80-1.0.1.jar > * /JRE/LIB/EXT/jsr80_linux-1.0.1.jar > * /JRE/LIB/EXT/jsr80_ri-1.0.1.jar > * /JRE/LIB/i386/libJavaxUsb.so > > While I tried to put the same components on Java-64bit, the > exception was caught once I start to run java > > * Exception : javax.usb.UsbException : Error while loading share > library libJavaxUsb.so(libJavaxUsb.so : wrong ELF class : ELFCLASS32) > * But this Java-64bit can run the other class well > > Does Java-64bit work with libJavaxUsb.so ? > > > ------------------------------------------------------------------------------ > Rapidly troubleshoot problems before they affect your business. Most IT > organizations don't have a clear picture of how application performance > affects their revenue. With AppDynamics, you get 100% visibility into your > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! > http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk > > > _______________________________________________ > javax-usb-devel mailing list > jav...@li... > https://lists.sourceforge.net/lists/listinfo/javax-usb-devel -- And |
|
From: Hsieh D. <di...@gm...> - 2013-12-02 09:17:58
|
Any of your answer or advice will be strongly appreciated I used JSR80 components on Java-32bit. And everything is okay with below configuration - /JRE/LIB/EXT/jsr80-1.0.1.jar - /JRE/LIB/EXT/jsr80_linux-1.0.1.jar - /JRE/LIB/EXT/jsr80_ri-1.0.1.jar - /JRE/LIB/i386/libJavaxUsb.so While I tried to put the same components on Java-64bit, the exception was caught once I start to run java - Exception : javax.usb.UsbException : Error while loading share library libJavaxUsb.so(libJavaxUsb.so : wrong ELF class : ELFCLASS32) - But this Java-64bit can run the other class well Does Java-64bit work with libJavaxUsb.so ? |
|
From: Dan S. <dds...@ie...> - 2013-10-15 12:35:29
|
On Tue, Oct 15, 2013 at 7:12 AM, SANJAY GUPTA <gup...@sa...> wrote: > 2. Token Packet Format - | Sync | PID | ADDR | ENDP | CRC5 | EOP | > Data Packet Format - | Sync | PID | Data | CRC16 | EOP | > Handshake Packet Format - | Sync | PID | EOP | > > Question:- Does the javax.usb APIs take care these low level details of preparing these packets for the given data to transfer ? > Or if the programmer is expected to form the packets in desired format before actually starting the transmission? If yes, how to calculate fields CRC, Sync etc.? > As per my understanding, the javax.usb APIs do the task for provided data buffer for transmission. The sync, pid, etc. tokens are handled entirely by the usb host controller hardware. No software is involved in directly managing them (they are indirectly managed by the usb host controller driver, which manages the host-controller-specific data structures and api) > Also, the Usb specification does not impose any structural constraints on the actual data being transmitted. Let me know, if I am wrong The usb spec imposes no constraints on the actual data being transmitted. Each device does have a specific protocol that must be followed however. > > > Second, Linux will be driving this device by default, and allowing you > to access it as a normal storage device. Why don't you want to let > Linux do the mass storage work for you? Just mount the device's > filesystem(s) and access them directly using normal file i/o. > > => My purpose is to create a test application using javax.usb APIs for testing the performance of USB on different printer models. if you understand your printers' interface(s), you should work directly with them instead of using a usb key. Mass storage isn't a simple protocol. > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk > _______________________________________________ > javax-usb-devel mailing list > jav...@li... > https://lists.sourceforge.net/lists/listinfo/javax-usb-devel |
|
From: SANJAY G. <gup...@sa...> - 2013-10-15 11:12:17
|
Thanks, Sanjay Gupta<p> </p><p> </p> ------- Original Message ------- Sender : Dan Streetman<dds...@ie...> Date : Oct 15, 2013 01:30 (GMT+09:00) Title : Re: [javax-usb-devel] Packet Data Format On Mon, Oct 14, 2013 at 2:53 AM, SANJAY GUPTA <gup...@sa...> wrote: > > Hi All, > I have a USB flash drive with below specification: First, for any usb flash drive, it's almost guaranteed the device is a mass storage device, so its protocol will be based on that spec, which you'll need to understand. => What I have understood till now is [Reference: http://www.beyondlogic.org/usbnutshell/usb3.shtml#USBProtocols] 1. Each USB transaction consists of a (i) Token Packet (Header defining what it expects to follow), an (ii) Optional Data Packet, (Containing the payload) and a (iii) Status Packet (Used to acknowledge transactions and to provide a means of error correction) 2. Token Packet Format - | Sync | PID | ADDR | ENDP | CRC5 | EOP | Data Packet Format - | Sync | PID | Data | CRC16 | EOP | Handshake Packet Format - | Sync | PID | EOP | Question:- Does the javax.usb APIs take care these low level details of preparing these packets for the given data to transfer ? Or if the programmer is expected to form the packets in desired format before actually starting the transmission? If yes, how to calculate fields CRC, Sync etc.? As per my understanding, the javax.usb APIs do the task for provided data buffer for transmission. Also, the Usb specification does not impose any structural constraints on the actual data being transmitted. Let me know, if I am wrong Second, Linux will be driving this device by default, and allowing you to access it as a normal storage device. Why don't you want to let Linux do the mass storage work for you? Just mount the device's filesystem(s) and access them directly using normal file i/o. => My purpose is to create a test application using javax.usb APIs for testing the performance of USB on different printer models. |
|
From: Dan S. <dds...@ie...> - 2013-10-14 16:30:29
|
On Mon, Oct 14, 2013 at 2:53 AM, SANJAY GUPTA <gup...@sa...> wrote: > > Hi All, > I have a USB flash drive with below specification: First, for any usb flash drive, it's almost guaranteed the device is a mass storage device, so its protocol will be based on that spec, which you'll need to understand. Second, Linux will be driving this device by default, and allowing you to access it as a normal storage device. Why don't you want to let Linux do the mass storage work for you? Just mount the device's filesystem(s) and access them directly using normal file i/o. |
|
From: SANJAY G. <gup...@sa...> - 2013-10-14 06:53:21
|
Hi All, I have a USB flash drive with below specification: Manufacturer String: Memorette Inc. Product String: Memorette UFD SerialNumber String: ML0306E32F0B0109 Speed: DEVICE_SPEED_FULL Does anybody know about this device's protocol or low-level packet data format so as to interact with this device in BULK I/O operation using javax.usb APIs ? Thanks, Sanjay Gupta |
|
From: SANJAY G. <gup...@sa...> - 2013-10-11 04:34:48
|
It would be greatly appreciated if someone could provide an example code to poll the input pipe to read buffer.
I tried a thread as shown below but no help:-
final Thread thread = new Thread(new Runnable() {
@Override
public void run() {
//Asynchronously read the status in list of UsbIrps from IN UsbPipe
log("Asynchronously reading the status in list of UsbIrps from IN UsbPipe ...");
final List<UsbIrp> list = new ArrayList<UsbIrp>();
final UsbIrp usbIrp1 = inUsbPipe.createUsbIrp();
usbIrp1.setAcceptShortPacket(true);
usbIrp1.setData(new byte[maxPacketSize]);
list.add(usbIrp1);
final UsbIrp usbIrp2 = inUsbPipe.createUsbIrp();
usbIrp2.setAcceptShortPacket(true);
usbIrp2.setData(new byte[maxPacketSize]);
list.add(usbIrp2);
try {
inUsbPipe.asyncSubmit(list);
} catch (UsbNotActiveException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UsbNotOpenException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UsbDisconnectedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UsbException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
thread.start();
I don't know how to keep buffers ready for reading the data from input pipe. And after reading the buffer, how should I resubmit another buffer. I event kept a listener on Input pipe to get notification of a data event but no event is received while I am submitting the input buffer in the thread.
final UsbPipeListener listener = new UsbPipeListener() {
@Override
public void errorEventOccurred(UsbPipeErrorEvent event) {
// TODO Auto-generated method stub
}
@Override
public void dataEventOccurred(UsbPipeDataEvent event) {
final int transferLength = event.getActualLength();
log("UsbPipeDataEvent occurred on IN UsbPipe with data size " + transferLength);
}
};
inUsbPipe.addUsbPipeListener(listener);
Thanks,
Sanjay Gupta
------- Original Message -------
Sender : SANJAY GUPTA<gup...@sa...> S5/Senior Engineer/Architecture Analysis Lab./Samsung Electronics
Date : Oct 10, 2013 12:09 (GMT+09:00)
Title : Re: Re: [javax-usb-devel] Hang problem with UsbPipe.syncSubmit(byte[])
Thanks,
Sanjay Gupta<p> </p><p> </p>
------- Original Message -------
Sender : Dan Streetman<dds...@ie...>
Date : Oct 08, 2013 21:28 (GMT+09:00)
Title : Re: [javax-usb-devel] Hang problem with UsbPipe.syncSubmit(byte[])
On Tue, Oct 8, 2013 at 3:51 AM, SANJAY GUPTA <gup...@sa...> wrote:
> Thanks,
> Sanjay Gupta<p> </p><p> </p>
>
> ------- Original Message -------
> Sender : Dan Streetman<dds...@ie...>
> Date : Oct 07, 2013 21:37 (GMT+09:00)
> Title : Re: [javax-usb-devel] Hang problem with UsbPipe.syncSubmit(byte[])
>
> On Mon, Oct 7, 2013 at 1:48 AM, SANJAY GUPTA <gup...@sa...> wrote:
>> Reposting the query after removing formatting...
>>
>> Thanks for your great support.
>> I tried below as suggested:-
>>
>> int maxPacketSize = outUsbPipe.getUsbEndpoint().getUsbEndpointDescriptor().wMaxPacketSize( );
>> log("Max Packet Size: " + maxPacketSize);
>> final byte[] buffer = new byte[8192];
>> for (int offset=0; offset<buffer.length; offset+=maxPacketSize) {
>> final UsbIrp usbIrp = outUsbPipe.createUsbIrp( );
>> usbIrp.setData(buffer, offset, maxPacketSize);
>
> Well I don't think I suggested splitting the output data into max
> packet sized irps, that's certainly unnecessary and will drastically
> cut down on your throughput. I think I said use "reasonable" buffer
> sizes. I'm pretty sure 8k is ok to send in a single irp.
>
> ==> If I transmit the whole buffer of 8K in single submission using asyncSubmt() and wait for it to complete, the submission never gets completed and stucks on waitUntilComplete(). The same thing happens while using syncSubmit(). I do wait for the asynSubmit() to complete because my purpose is to capture the completion time for the submission for different sized buffers.
>
> Also, please not that the hang happens only when the buffer is uninitialized. If I initialize the buffer then the UsbStallException is thrown.
>
> for (int index=0; index<buffer.length; index++) {
> buffer[index] = (byte) index;
> }
This sounds like you don't understand the protocol of your device.
###==> I noticed that the maxPacketSize which the UsbEndpoint of my device can transfer is 512 bytes and the maximum buffer size which I can transfer to the out UsbPipe is 1536 bytes (which is exactly 3 times the maxPacketSize).
After transmitting this size of buffer, I cannot transfer any more byte to the pipe.
Even after closing the pipe & releasing the interface, and again claim() and open() the next time, the data transfer gets stuck.
I feel sorry bothering you but I am unable to understand whats the issue with the trasnfer data size.
It is also to be noted that, the I am able to transfer only 1536 bytes, no matter in what sequece.
Either I send all bytes at the same time or by splitting them in different exececutions (close pipe and again open), the extra data transfer gets stuck.
And I have to unplug the device and plug it again to execute.
>
>>
>> //Asynchronously submit the UsbIrp to UsbPipe
>> log("==> Asynchronously submitting the UsbIrp to UsbPipe ...");
>> outUsbPipe.asyncSubmit(usbIrp);
>>
>> //Wait for the UsbIrp to complete
>> log("Waiting for the UsbIrp to complete ...");
>> usbIrp.waitUntilComplete();
>>
>> log("!!! Successfully submitted the UsbIrp to UsbPipe ...");
>> }
>>
>> But after successfully executing the loop for 3 times, it goes stuck on waitUntilComplete() as below-
>>
>> Max Packet Size: 512
>> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
>> Waiting for the UsbIrp to complete ...
>> !!! Successfully submitted the UsbIrp to UsbPipe ...
>> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
>> Waiting for the UsbIrp to complete ...
>> !!! Successfully submitted the UsbIrp to UsbPipe ...
>> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
>> Waiting for the UsbIrp to complete ...
>> !!! Successfully submitted the UsbIrp to UsbPipe ...
>> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
>> Waiting for the UsbIrp to complete ...
>>
>>
>> I even put a UsbPipeListener before the above code to poll the UsbPipeDataEvent on Input UsbPipe but failed to receive any event.
>
> did you actually submit one or more buffers to the input pipe? You
> obviously will never get anything if you don't submit a buffer to be
> filled.
>
> ==> My mistake. But I have a feeling that if the status data from the Input pipe is not read then further submission gets stuck. So, how to know that there is some data to be read on the input pipe?
When you get a buffer back (i.e. a completed IRP), either when
syncSubmit() returns or waitUntilComplete() returns or your listener
gets triggered, the device has already sent data back, that is now in
the buffer you provided.
Knowing that there is data "to be read" on the pipe isn't possible
(except predicting that there *should* be data sent back from the
device based on the specific device protocol, of course). Generally
you should just keep buffer(s) "pending" on any input pipe, since most
specs describe actions that the driver (you) should take when the
device sends any data in. The pending buffer will then just return to
you immediately with the data (and you should then resubmit another
buffer - it's good to keep multiple buffers pending so there's never
any gap in device polling).
Keep in mind that using javax.usb isn't high level programming.
You're doing very low level device communication, and it's
complicated, because the usb spec is very complicated.
###==> Can you please provide a example code to poll the input pipe to read buffer.
>
>>
>> final UsbPipeListener listener = new UsbPipeListener() {
>> @Override
>> public void errorEventOccurred(UsbPipeErrorEvent event) {
>> // TODO Auto-generated method stub
>> }
>> @Override
>> public void dataEventOccurred(UsbPipeDataEvent event) {
>> final int transferLength = event.getActualLength();
>> log("UsbPipeDataEvent occurred on IN UsbPipe with data size " + transferLength);
>>
>> //Asynchronously read the status in byte[] from IN UsbPipe
>> log("Asynchronously reading the status in byte[] from IN UsbPipe ...");
>> UsbIrp irp = inUsbPipe.asyncSubmit(new byte[transferLength]);
>
> you shouldn't be using getActualLength to size the next buffer to send
> - it should be consistent, or at least based on the device's protocol,
> and the actual length is simply how many bytes this irp returned.
>
>>
>> //Wait for the UsbIrp to complete
>> log("Waiting for the reading to complete ...");
>> irp.waitUntilComplete();
>
> um...what is the point of asyncSubmit() and then immediately in the
> same thread waiting for it to complete? Additionally, your listener
> callback is supposed to be quick, since calls will come sequentially.
> And what is the point of waiting for the irp to complete right before
> you exit the method?
>
>> }
>> };
>> inUsbPipe.addUsbPipeListener(listener);
>>
>> ------- Original Message -------
>> Sender : Dan Streetman<dds...@ie...>
>> Date : Oct 02, 2013 22:31 (GMT+09:00)
>> Title : Re: [javax-usb-devel] Hang problem with UsbPipe.syncSubmit(byte[])
>>
>> On Wed, Oct 2, 2013 at 6:23 AM, SANJAY GUPTA <gup...@sa...> wrote:
>>> Hi All,
>>>
>>> Please look below the sample scenario:-
>>>
>>> final byte[] outData = new byte[] {
>>> (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03,
>>> (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,
>>> (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
>>> (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x01B,
>>> (byte) 0x0C, (byte) 0x0D, (byte) 0x0E, (byte) 0x0F,
>>> (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03,
>>> (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,
>>> (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }
>>> final byte[] inData = new byte[13];
>>>
>>> log("Synchronously submitting the byte[] to UsbPipe ...");
>>> outUsbPipe.syncSubmit(data);
>>>
>>> //Synchronously read the status from IN UsbPipe
>>> log("Synchronously reading the status from IN UsbPipe ...");
>>> inUsbPipe.syncSubmit(inData);
>>>
>>> This code is working fine but I am facing problem if I want to change (reduce/reduce/modify) the outData.
>>> The control gets hang on reading the status data from the Input UsbPipe.
>>> Any suggestion on below points will be helpful:-
>>> 1. Is there any specific data format (may be starting header) in the actual data being transferred?
>>
>> Data formats are entirely up to the device, unless the device
>> implements a higher level spec (like HID, mass storage, etc) that
>> itself contains the API for the data format. USB doesn't specify any
>> data format at all, except for the control pipe 8-byte setup packet
>> that must preface each control transfer, and the various default
>> control pipe standard requests (set interface, clear stall, etc).
>>
>>
>> ===> Thanks A lot. I am using a mass-storage device and BULK type UsbEndpoint for data transfer.
>> But the problem is, suppose I keep the value of outData[8] as non-zero with all other things intact, the submission gets hanged which never completes.
>> And then I have no choice but the unplug the device.
>>
>>
>>
>>> 2. What is the data size which can be transferred using single invocation of syncSubmit()?
>>
>> it's been a while, but IIRC there's no limit in java, although I think
>> the platform may enforce limits. I don't really remember the details
>> though. For interrupt pipes, you of course should usually submit
>> exactly the pipe size (wMaxPacketSize).
>>
>> ===> Mass-storage device and BULK type UsbEndpoint.
>>
>>> 3. What is the status data size which is received on Input Pipe as a result of out data transfer?
>>
>> it's entirely dependent on your device. although if your input pipe
>> is an interrupt pipe, it should be the wMaxPacketSize from the
>> endpoint descriptor.
>>
>> Also, assuming your input pipe is interrupt type, it's probably better
>> for you to keep a buffer on it, which will cause continuous polling of
>> the device, as required by spec when the device is in use. You can do
>> that either with a separate Thread that does nothing except
>> syncSubmit() a buffer or irp to the pipe, then passes the returned
>> data off somewhere else to process and immediately syncSubmit() a new
>> buffer, or you can use asyncSubmit() with either a listener on the
>> pipe or a separate Thread to waitUntilComplete() for the irp, and then
>> also hand off the returned data to process somewhere else and
>> immediately sync or async submit again a new buffer. With
>> asyncSubmit(), you can submit multiple buffers, which is better
>> because it keeps the low level platform queued up with buffers so that
>> the device polling never stops, and you don't have to try to be quite
>> so fast at resubmitting a new buffer.
>>
>> ===> Mass-storage device and BULK type UsbEndpoint.
>>
>>
>>>
>>> Thanks in Advance..
>>> Sanjay Gupta
>>>
>>> ------------------------------------------------------------------------------
>>> October Webinars: Code for Performance
>>> Free Intel webinars can help you accelerate application performance.
>>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
>>> the latest Intel processors and coprocessors. See abstracts and register >
>>> http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> javax-usb-devel mailing list
>>> jav...@li...
>>> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
>>
>>
>> ------------------------------------------------------------------------------
>> October Webinars: Code for Performance
>> Free Intel webinars can help you accelerate application performance.
>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
>> the latest Intel processors and coprocessors. See abstracts and register >
>> http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
>> _______________________________________________
>> javax-usb-devel mailing list
>> jav...@li...
>> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
> _______________________________________________
> javax-usb-devel mailing list
> jav...@li...
> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
_______________________________________________
javax-usb-devel mailing list
jav...@li...
https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
|
|
From: SANJAY G. <gup...@sa...> - 2013-10-11 04:29:35
|
It would be greatly appreciated if some could provide an example code to poll the input pipe to read buffer.
I tried a thread as shown below but no help:-
final Thread thread = new Thread(new Runnable() {
@Override
public void run() {
//Asynchronously read the status in list of UsbIrps from IN UsbPipe
log("Asynchronously reading the status in list of UsbIrps from IN UsbPipe ...");
final List<UsbIrp> list = new ArrayList<UsbIrp>();
final UsbIrp usbIrp1 = inUsbPipe.createUsbIrp();
usbIrp1.setAcceptShortPacket(true);
usbIrp1.setData(new byte[maxPacketSize]);
list.add(usbIrp1);
final UsbIrp usbIrp2 = inUsbPipe.createUsbIrp();
usbIrp2.setAcceptShortPacket(true);
usbIrp2.setData(new byte[8]);
list.add(usbIrp2);
try {
inUsbPipe.asyncSubmit(list);
} catch (UsbNotActiveException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UsbNotOpenException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UsbDisconnectedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UsbException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
thread.start();
I don't know how to keep buffers ready for reading the data from input pipe. And after reading the buffer, how should I resubmit another buffer. I event kept a listener on Input pipe to get notification of a data event but no event is received while I am submitting the input buffer in the thread.
final UsbPipeListener listener = new UsbPipeListener() {
@Override
public void errorEventOccurred(UsbPipeErrorEvent event) {
// TODO Auto-generated method stub
}
@Override
public void dataEventOccurred(UsbPipeDataEvent event) {
final int transferLength = event.getActualLength();
log("UsbPipeDataEvent occurred on IN UsbPipe with data size " + transferLength);
}
};
inUsbPipe.addUsbPipeListener(listener);
Thanks,
Sanjay Gupta
------- Original Message -------
Sender : SANJAY GUPTA<gup...@sa...> S5/Senior Engineer/Architecture Analysis Lab./Samsung Electronics
Date : Oct 10, 2013 12:09 (GMT+09:00)
Title : Re: Re: [javax-usb-devel] Hang problem with UsbPipe.syncSubmit(byte[])
Thanks,
Sanjay Gupta<p> </p><p> </p>
------- Original Message -------
Sender : Dan Streetman<dds...@ie...>
Date : Oct 08, 2013 21:28 (GMT+09:00)
Title : Re: [javax-usb-devel] Hang problem with UsbPipe.syncSubmit(byte[])
On Tue, Oct 8, 2013 at 3:51 AM, SANJAY GUPTA <gup...@sa...> wrote:
> Thanks,
> Sanjay Gupta<p> </p><p> </p>
>
> ------- Original Message -------
> Sender : Dan Streetman<dds...@ie...>
> Date : Oct 07, 2013 21:37 (GMT+09:00)
> Title : Re: [javax-usb-devel] Hang problem with UsbPipe.syncSubmit(byte[])
>
> On Mon, Oct 7, 2013 at 1:48 AM, SANJAY GUPTA <gup...@sa...> wrote:
>> Reposting the query after removing formatting...
>>
>> Thanks for your great support.
>> I tried below as suggested:-
>>
>> int maxPacketSize = outUsbPipe.getUsbEndpoint().getUsbEndpointDescriptor().wMaxPacketSize( );
>> log("Max Packet Size: " + maxPacketSize);
>> final byte[] buffer = new byte[8192];
>> for (int offset=0; offset<buffer.length; offset+=maxPacketSize) {
>> final UsbIrp usbIrp = outUsbPipe.createUsbIrp( );
>> usbIrp.setData(buffer, offset, maxPacketSize);
>
> Well I don't think I suggested splitting the output data into max
> packet sized irps, that's certainly unnecessary and will drastically
> cut down on your throughput. I think I said use "reasonable" buffer
> sizes. I'm pretty sure 8k is ok to send in a single irp.
>
> ==> If I transmit the whole buffer of 8K in single submission using asyncSubmt() and wait for it to complete, the submission never gets completed and stucks on waitUntilComplete(). The same thing happens while using syncSubmit(). I do wait for the asynSubmit() to complete because my purpose is to capture the completion time for the submission for different sized buffers.
>
> Also, please not that the hang happens only when the buffer is uninitialized. If I initialize the buffer then the UsbStallException is thrown.
>
> for (int index=0; index<buffer.length; index++) {
> buffer[index] = (byte) index;
> }
This sounds like you don't understand the protocol of your device.
###==> I noticed that the maxPacketSize which the UsbEndpoint of my device can transfer is 512 bytes and the maximum buffer size which I can transfer to the out UsbPipe is 1536 bytes (which is exactly 3 times the maxPacketSize).
After transmitting this size of buffer, I cannot transfer any more byte to the pipe.
Even after closing the pipe & releasing the interface, and again claim() and open() the next time, the data transfer gets stuck.
I feel sorry bothering you but I am unable to understand whats the issue with the trasnfer data size.
It is also to be noted that, the I am able to transfer only 1536 bytes, no matter in what sequece.
Either I send all bytes at the same time or by splitting them in different exececutions (close pipe and again open), the extra data transfer gets stuck.
And I have to unplug the device and plug it again to execute.
>
>>
>> //Asynchronously submit the UsbIrp to UsbPipe
>> log("==> Asynchronously submitting the UsbIrp to UsbPipe ...");
>> outUsbPipe.asyncSubmit(usbIrp);
>>
>> //Wait for the UsbIrp to complete
>> log("Waiting for the UsbIrp to complete ...");
>> usbIrp.waitUntilComplete();
>>
>> log("!!! Successfully submitted the UsbIrp to UsbPipe ...");
>> }
>>
>> But after successfully executing the loop for 3 times, it goes stuck on waitUntilComplete() as below-
>>
>> Max Packet Size: 512
>> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
>> Waiting for the UsbIrp to complete ...
>> !!! Successfully submitted the UsbIrp to UsbPipe ...
>> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
>> Waiting for the UsbIrp to complete ...
>> !!! Successfully submitted the UsbIrp to UsbPipe ...
>> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
>> Waiting for the UsbIrp to complete ...
>> !!! Successfully submitted the UsbIrp to UsbPipe ...
>> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
>> Waiting for the UsbIrp to complete ...
>>
>>
>> I even put a UsbPipeListener before the above code to poll the UsbPipeDataEvent on Input UsbPipe but failed to receive any event.
>
> did you actually submit one or more buffers to the input pipe? You
> obviously will never get anything if you don't submit a buffer to be
> filled.
>
> ==> My mistake. But I have a feeling that if the status data from the Input pipe is not read then further submission gets stuck. So, how to know that there is some data to be read on the input pipe?
When you get a buffer back (i.e. a completed IRP), either when
syncSubmit() returns or waitUntilComplete() returns or your listener
gets triggered, the device has already sent data back, that is now in
the buffer you provided.
Knowing that there is data "to be read" on the pipe isn't possible
(except predicting that there *should* be data sent back from the
device based on the specific device protocol, of course). Generally
you should just keep buffer(s) "pending" on any input pipe, since most
specs describe actions that the driver (you) should take when the
device sends any data in. The pending buffer will then just return to
you immediately with the data (and you should then resubmit another
buffer - it's good to keep multiple buffers pending so there's never
any gap in device polling).
Keep in mind that using javax.usb isn't high level programming.
You're doing very low level device communication, and it's
complicated, because the usb spec is very complicated.
###==> Can you please provide a example code to poll the input pipe to read buffer.
>
>>
>> final UsbPipeListener listener = new UsbPipeListener() {
>> @Override
>> public void errorEventOccurred(UsbPipeErrorEvent event) {
>> // TODO Auto-generated method stub
>> }
>> @Override
>> public void dataEventOccurred(UsbPipeDataEvent event) {
>> final int transferLength = event.getActualLength();
>> log("UsbPipeDataEvent occurred on IN UsbPipe with data size " + transferLength);
>>
>> //Asynchronously read the status in byte[] from IN UsbPipe
>> log("Asynchronously reading the status in byte[] from IN UsbPipe ...");
>> UsbIrp irp = inUsbPipe.asyncSubmit(new byte[transferLength]);
>
> you shouldn't be using getActualLength to size the next buffer to send
> - it should be consistent, or at least based on the device's protocol,
> and the actual length is simply how many bytes this irp returned.
>
>>
>> //Wait for the UsbIrp to complete
>> log("Waiting for the reading to complete ...");
>> irp.waitUntilComplete();
>
> um...what is the point of asyncSubmit() and then immediately in the
> same thread waiting for it to complete? Additionally, your listener
> callback is supposed to be quick, since calls will come sequentially.
> And what is the point of waiting for the irp to complete right before
> you exit the method?
>
>> }
>> };
>> inUsbPipe.addUsbPipeListener(listener);
>>
>> ------- Original Message -------
>> Sender : Dan Streetman<dds...@ie...>
>> Date : Oct 02, 2013 22:31 (GMT+09:00)
>> Title : Re: [javax-usb-devel] Hang problem with UsbPipe.syncSubmit(byte[])
>>
>> On Wed, Oct 2, 2013 at 6:23 AM, SANJAY GUPTA <gup...@sa...> wrote:
>>> Hi All,
>>>
>>> Please look below the sample scenario:-
>>>
>>> final byte[] outData = new byte[] {
>>> (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03,
>>> (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,
>>> (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
>>> (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x01B,
>>> (byte) 0x0C, (byte) 0x0D, (byte) 0x0E, (byte) 0x0F,
>>> (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03,
>>> (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,
>>> (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }
>>> final byte[] inData = new byte[13];
>>>
>>> log("Synchronously submitting the byte[] to UsbPipe ...");
>>> outUsbPipe.syncSubmit(data);
>>>
>>> //Synchronously read the status from IN UsbPipe
>>> log("Synchronously reading the status from IN UsbPipe ...");
>>> inUsbPipe.syncSubmit(inData);
>>>
>>> This code is working fine but I am facing problem if I want to change (reduce/reduce/modify) the outData.
>>> The control gets hang on reading the status data from the Input UsbPipe.
>>> Any suggestion on below points will be helpful:-
>>> 1. Is there any specific data format (may be starting header) in the actual data being transferred?
>>
>> Data formats are entirely up to the device, unless the device
>> implements a higher level spec (like HID, mass storage, etc) that
>> itself contains the API for the data format. USB doesn't specify any
>> data format at all, except for the control pipe 8-byte setup packet
>> that must preface each control transfer, and the various default
>> control pipe standard requests (set interface, clear stall, etc).
>>
>>
>> ===> Thanks A lot. I am using a mass-storage device and BULK type UsbEndpoint for data transfer.
>> But the problem is, suppose I keep the value of outData[8] as non-zero with all other things intact, the submission gets hanged which never completes.
>> And then I have no choice but the unplug the device.
>>
>>
>>
>>> 2. What is the data size which can be transferred using single invocation of syncSubmit()?
>>
>> it's been a while, but IIRC there's no limit in java, although I think
>> the platform may enforce limits. I don't really remember the details
>> though. For interrupt pipes, you of course should usually submit
>> exactly the pipe size (wMaxPacketSize).
>>
>> ===> Mass-storage device and BULK type UsbEndpoint.
>>
>>> 3. What is the status data size which is received on Input Pipe as a result of out data transfer?
>>
>> it's entirely dependent on your device. although if your input pipe
>> is an interrupt pipe, it should be the wMaxPacketSize from the
>> endpoint descriptor.
>>
>> Also, assuming your input pipe is interrupt type, it's probably better
>> for you to keep a buffer on it, which will cause continuous polling of
>> the device, as required by spec when the device is in use. You can do
>> that either with a separate Thread that does nothing except
>> syncSubmit() a buffer or irp to the pipe, then passes the returned
>> data off somewhere else to process and immediately syncSubmit() a new
>> buffer, or you can use asyncSubmit() with either a listener on the
>> pipe or a separate Thread to waitUntilComplete() for the irp, and then
>> also hand off the returned data to process somewhere else and
>> immediately sync or async submit again a new buffer. With
>> asyncSubmit(), you can submit multiple buffers, which is better
>> because it keeps the low level platform queued up with buffers so that
>> the device polling never stops, and you don't have to try to be quite
>> so fast at resubmitting a new buffer.
>>
>> ===> Mass-storage device and BULK type UsbEndpoint.
>>
>>
>>>
>>> Thanks in Advance..
>>> Sanjay Gupta
>>>
>>> ------------------------------------------------------------------------------
>>> October Webinars: Code for Performance
>>> Free Intel webinars can help you accelerate application performance.
>>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
>>> the latest Intel processors and coprocessors. See abstracts and register >
>>> http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> javax-usb-devel mailing list
>>> jav...@li...
>>> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
>>
>>
>> ------------------------------------------------------------------------------
>> October Webinars: Code for Performance
>> Free Intel webinars can help you accelerate application performance.
>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
>> the latest Intel processors and coprocessors. See abstracts and register >
>> http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
>> _______________________________________________
>> javax-usb-devel mailing list
>> jav...@li...
>> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
> _______________________________________________
> javax-usb-devel mailing list
> jav...@li...
> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
|
|
From: SANJAY G. <gup...@sa...> - 2013-10-10 03:09:44
|
Thanks,
Sanjay Gupta<p> </p><p> </p>
------- Original Message -------
Sender : Dan Streetman<dds...@ie...>
Date : Oct 08, 2013 21:28 (GMT+09:00)
Title : Re: [javax-usb-devel] Hang problem with UsbPipe.syncSubmit(byte[])
On Tue, Oct 8, 2013 at 3:51 AM, SANJAY GUPTA <gup...@sa...> wrote:
> Thanks,
> Sanjay Gupta<p> </p><p> </p>
>
> ------- Original Message -------
> Sender : Dan Streetman<dds...@ie...>
> Date : Oct 07, 2013 21:37 (GMT+09:00)
> Title : Re: [javax-usb-devel] Hang problem with UsbPipe.syncSubmit(byte[])
>
> On Mon, Oct 7, 2013 at 1:48 AM, SANJAY GUPTA <gup...@sa...> wrote:
>> Reposting the query after removing formatting...
>>
>> Thanks for your great support.
>> I tried below as suggested:-
>>
>> int maxPacketSize = outUsbPipe.getUsbEndpoint().getUsbEndpointDescriptor().wMaxPacketSize( );
>> log("Max Packet Size: " + maxPacketSize);
>> final byte[] buffer = new byte[8192];
>> for (int offset=0; offset<buffer.length; offset+=maxPacketSize) {
>> final UsbIrp usbIrp = outUsbPipe.createUsbIrp( );
>> usbIrp.setData(buffer, offset, maxPacketSize);
>
> Well I don't think I suggested splitting the output data into max
> packet sized irps, that's certainly unnecessary and will drastically
> cut down on your throughput. I think I said use "reasonable" buffer
> sizes. I'm pretty sure 8k is ok to send in a single irp.
>
> ==> If I transmit the whole buffer of 8K in single submission using asyncSubmt() and wait for it to complete, the submission never gets completed and stucks on waitUntilComplete(). The same thing happens while using syncSubmit(). I do wait for the asynSubmit() to complete because my purpose is to capture the completion time for the submission for different sized buffers.
>
> Also, please not that the hang happens only when the buffer is uninitialized. If I initialize the buffer then the UsbStallException is thrown.
>
> for (int index=0; index<buffer.length; index++) {
> buffer[index] = (byte) index;
> }
This sounds like you don't understand the protocol of your device.
###==> I noticed that the maxPacketSize which the UsbEndpoint of my device can transfer is 512 bytes and the maximum buffer size which I can transfer to the out UsbPipe is 1536 bytes (which is exactly 3 times the maxPacketSize).
After transmitting this size of buffer, I cannot transfer any more byte to the pipe.
Even after closing the pipe & releasing the interface, and again claim() and open() the next time, the data transfer gets stuck.
I feel sorry bothering you but I am unable to understand whats the issue with the trasnfer data size.
It is also to be noted that, the I am able to transfer only 1536 bytes, no matter in what sequece.
Either I send all bytes at the same time or by splitting them in different exececutions (close pipe and again open), the extra data transfer gets stuck.
And I have to unplug the device and plug it again to execute.
>
>>
>> //Asynchronously submit the UsbIrp to UsbPipe
>> log("==> Asynchronously submitting the UsbIrp to UsbPipe ...");
>> outUsbPipe.asyncSubmit(usbIrp);
>>
>> //Wait for the UsbIrp to complete
>> log("Waiting for the UsbIrp to complete ...");
>> usbIrp.waitUntilComplete();
>>
>> log("!!! Successfully submitted the UsbIrp to UsbPipe ...");
>> }
>>
>> But after successfully executing the loop for 3 times, it goes stuck on waitUntilComplete() as below-
>>
>> Max Packet Size: 512
>> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
>> Waiting for the UsbIrp to complete ...
>> !!! Successfully submitted the UsbIrp to UsbPipe ...
>> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
>> Waiting for the UsbIrp to complete ...
>> !!! Successfully submitted the UsbIrp to UsbPipe ...
>> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
>> Waiting for the UsbIrp to complete ...
>> !!! Successfully submitted the UsbIrp to UsbPipe ...
>> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
>> Waiting for the UsbIrp to complete ...
>>
>>
>> I even put a UsbPipeListener before the above code to poll the UsbPipeDataEvent on Input UsbPipe but failed to receive any event.
>
> did you actually submit one or more buffers to the input pipe? You
> obviously will never get anything if you don't submit a buffer to be
> filled.
>
> ==> My mistake. But I have a feeling that if the status data from the Input pipe is not read then further submission gets stuck. So, how to know that there is some data to be read on the input pipe?
When you get a buffer back (i.e. a completed IRP), either when
syncSubmit() returns or waitUntilComplete() returns or your listener
gets triggered, the device has already sent data back, that is now in
the buffer you provided.
Knowing that there is data "to be read" on the pipe isn't possible
(except predicting that there *should* be data sent back from the
device based on the specific device protocol, of course). Generally
you should just keep buffer(s) "pending" on any input pipe, since most
specs describe actions that the driver (you) should take when the
device sends any data in. The pending buffer will then just return to
you immediately with the data (and you should then resubmit another
buffer - it's good to keep multiple buffers pending so there's never
any gap in device polling).
Keep in mind that using javax.usb isn't high level programming.
You're doing very low level device communication, and it's
complicated, because the usb spec is very complicated.
###==> Can you please provide a example code to poll the input pipe to read buffer.
>
>>
>> final UsbPipeListener listener = new UsbPipeListener() {
>> @Override
>> public void errorEventOccurred(UsbPipeErrorEvent event) {
>> // TODO Auto-generated method stub
>> }
>> @Override
>> public void dataEventOccurred(UsbPipeDataEvent event) {
>> final int transferLength = event.getActualLength();
>> log("UsbPipeDataEvent occurred on IN UsbPipe with data size " + transferLength);
>>
>> //Asynchronously read the status in byte[] from IN UsbPipe
>> log("Asynchronously reading the status in byte[] from IN UsbPipe ...");
>> UsbIrp irp = inUsbPipe.asyncSubmit(new byte[transferLength]);
>
> you shouldn't be using getActualLength to size the next buffer to send
> - it should be consistent, or at least based on the device's protocol,
> and the actual length is simply how many bytes this irp returned.
>
>>
>> //Wait for the UsbIrp to complete
>> log("Waiting for the reading to complete ...");
>> irp.waitUntilComplete();
>
> um...what is the point of asyncSubmit() and then immediately in the
> same thread waiting for it to complete? Additionally, your listener
> callback is supposed to be quick, since calls will come sequentially.
> And what is the point of waiting for the irp to complete right before
> you exit the method?
>
>> }
>> };
>> inUsbPipe.addUsbPipeListener(listener);
>>
>> ------- Original Message -------
>> Sender : Dan Streetman<dds...@ie...>
>> Date : Oct 02, 2013 22:31 (GMT+09:00)
>> Title : Re: [javax-usb-devel] Hang problem with UsbPipe.syncSubmit(byte[])
>>
>> On Wed, Oct 2, 2013 at 6:23 AM, SANJAY GUPTA <gup...@sa...> wrote:
>>> Hi All,
>>>
>>> Please look below the sample scenario:-
>>>
>>> final byte[] outData = new byte[] {
>>> (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03,
>>> (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,
>>> (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
>>> (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x01B,
>>> (byte) 0x0C, (byte) 0x0D, (byte) 0x0E, (byte) 0x0F,
>>> (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03,
>>> (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,
>>> (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }
>>> final byte[] inData = new byte[13];
>>>
>>> log("Synchronously submitting the byte[] to UsbPipe ...");
>>> outUsbPipe.syncSubmit(data);
>>>
>>> //Synchronously read the status from IN UsbPipe
>>> log("Synchronously reading the status from IN UsbPipe ...");
>>> inUsbPipe.syncSubmit(inData);
>>>
>>> This code is working fine but I am facing problem if I want to change (reduce/reduce/modify) the outData.
>>> The control gets hang on reading the status data from the Input UsbPipe.
>>> Any suggestion on below points will be helpful:-
>>> 1. Is there any specific data format (may be starting header) in the actual data being transferred?
>>
>> Data formats are entirely up to the device, unless the device
>> implements a higher level spec (like HID, mass storage, etc) that
>> itself contains the API for the data format. USB doesn't specify any
>> data format at all, except for the control pipe 8-byte setup packet
>> that must preface each control transfer, and the various default
>> control pipe standard requests (set interface, clear stall, etc).
>>
>>
>> ===> Thanks A lot. I am using a mass-storage device and BULK type UsbEndpoint for data transfer.
>> But the problem is, suppose I keep the value of outData[8] as non-zero with all other things intact, the submission gets hanged which never completes.
>> And then I have no choice but the unplug the device.
>>
>>
>>
>>> 2. What is the data size which can be transferred using single invocation of syncSubmit()?
>>
>> it's been a while, but IIRC there's no limit in java, although I think
>> the platform may enforce limits. I don't really remember the details
>> though. For interrupt pipes, you of course should usually submit
>> exactly the pipe size (wMaxPacketSize).
>>
>> ===> Mass-storage device and BULK type UsbEndpoint.
>>
>>> 3. What is the status data size which is received on Input Pipe as a result of out data transfer?
>>
>> it's entirely dependent on your device. although if your input pipe
>> is an interrupt pipe, it should be the wMaxPacketSize from the
>> endpoint descriptor.
>>
>> Also, assuming your input pipe is interrupt type, it's probably better
>> for you to keep a buffer on it, which will cause continuous polling of
>> the device, as required by spec when the device is in use. You can do
>> that either with a separate Thread that does nothing except
>> syncSubmit() a buffer or irp to the pipe, then passes the returned
>> data off somewhere else to process and immediately syncSubmit() a new
>> buffer, or you can use asyncSubmit() with either a listener on the
>> pipe or a separate Thread to waitUntilComplete() for the irp, and then
>> also hand off the returned data to process somewhere else and
>> immediately sync or async submit again a new buffer. With
>> asyncSubmit(), you can submit multiple buffers, which is better
>> because it keeps the low level platform queued up with buffers so that
>> the device polling never stops, and you don't have to try to be quite
>> so fast at resubmitting a new buffer.
>>
>> ===> Mass-storage device and BULK type UsbEndpoint.
>>
>>
>>>
>>> Thanks in Advance..
>>> Sanjay Gupta
>>>
>>> ------------------------------------------------------------------------------
>>> October Webinars: Code for Performance
>>> Free Intel webinars can help you accelerate application performance.
>>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
>>> the latest Intel processors and coprocessors. See abstracts and register >
>>> http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> javax-usb-devel mailing list
>>> jav...@li...
>>> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
>>
>>
>> ------------------------------------------------------------------------------
>> October Webinars: Code for Performance
>> Free Intel webinars can help you accelerate application performance.
>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
>> the latest Intel processors and coprocessors. See abstracts and register >
>> http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
>> _______________________________________________
>> javax-usb-devel mailing list
>> jav...@li...
>> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
> _______________________________________________
> javax-usb-devel mailing list
> jav...@li...
> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
|
|
From: SANJAY G. <gup...@sa...> - 2013-10-10 02:20:14
|
Thanks,
Sanjay Gupta<p> </p><p> </p>
------- Original Message -------
Sender : Dan Streetman<dds...@ie...>
Date : Oct 08, 2013 21:28 (GMT+09:00)
Title : Re: [javax-usb-devel] Hang problem with UsbPipe.syncSubmit(byte[])
On Tue, Oct 8, 2013 at 3:51 AM, SANJAY GUPTA <gup...@sa...> wrote:
> Thanks,
> Sanjay Gupta<p> </p><p> </p>
>
> ------- Original Message -------
> Sender : Dan Streetman<dds...@ie...>
> Date : Oct 07, 2013 21:37 (GMT+09:00)
> Title : Re: [javax-usb-devel] Hang problem with UsbPipe.syncSubmit(byte[])
>
> On Mon, Oct 7, 2013 at 1:48 AM, SANJAY GUPTA <gup...@sa...> wrote:
>> Reposting the query after removing formatting...
>>
>> Thanks for your great support.
>> I tried below as suggested:-
>>
>> int maxPacketSize = outUsbPipe.getUsbEndpoint().getUsbEndpointDescriptor().wMaxPacketSize( );
>> log("Max Packet Size: " + maxPacketSize);
>> final byte[] buffer = new byte[8192];
>> for (int offset=0; offset<buffer.length; offset+=maxPacketSize) {
>> final UsbIrp usbIrp = outUsbPipe.createUsbIrp( );
>> usbIrp.setData(buffer, offset, maxPacketSize);
>
> Well I don't think I suggested splitting the output data into max
> packet sized irps, that's certainly unnecessary and will drastically
> cut down on your throughput. I think I said use "reasonable" buffer
> sizes. I'm pretty sure 8k is ok to send in a single irp.
>
> ==> If I transmit the whole buffer of 8K in single submission using asyncSubmt() and wait for it to complete, the submission never gets completed and stucks on waitUntilComplete(). The same thing happens while using syncSubmit(). I do wait for the asynSubmit() to complete because my purpose is to capture the completion time for the submission for different sized buffers.
>
> Also, please not that the hang happens only when the buffer is uninitialized. If I initialize the buffer then the UsbStallException is thrown.
>
> for (int index=0; index<buffer.length; index++) {
> buffer[index] = (byte) index;
> }
This sounds like you don't understand the protocol of your device.
>
>>
>> //Asynchronously submit the UsbIrp to UsbPipe
>> log("==> Asynchronously submitting the UsbIrp to UsbPipe ...");
>> outUsbPipe.asyncSubmit(usbIrp);
>>
>> //Wait for the UsbIrp to complete
>> log("Waiting for the UsbIrp to complete ...");
>> usbIrp.waitUntilComplete();
>>
>> log("!!! Successfully submitted the UsbIrp to UsbPipe ...");
>> }
>>
>> But after successfully executing the loop for 3 times, it goes stuck on waitUntilComplete() as below-
>>
>> Max Packet Size: 512
>> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
>> Waiting for the UsbIrp to complete ...
>> !!! Successfully submitted the UsbIrp to UsbPipe ...
>> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
>> Waiting for the UsbIrp to complete ...
>> !!! Successfully submitted the UsbIrp to UsbPipe ...
>> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
>> Waiting for the UsbIrp to complete ...
>> !!! Successfully submitted the UsbIrp to UsbPipe ...
>> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
>> Waiting for the UsbIrp to complete ...
>>
>>
>> I even put a UsbPipeListener before the above code to poll the UsbPipeDataEvent on Input UsbPipe but failed to receive any event.
>
> did you actually submit one or more buffers to the input pipe? You
> obviously will never get anything if you don't submit a buffer to be
> filled.
>
> ==> My mistake. But I have a feeling that if the status data from the Input pipe is not read then further submission gets stuck. So, how to know that there is some data to be read on the input pipe?
When you get a buffer back (i.e. a completed IRP), either when
syncSubmit() returns or waitUntilComplete() returns or your listener
gets triggered, the device has already sent data back, that is now in
the buffer you provided.
Knowing that there is data "to be read" on the pipe isn't possible
(except predicting that there *should* be data sent back from the
device based on the specific device protocol, of course). Generally
you should just keep buffer(s) "pending" on any input pipe, since most
specs describe actions that the driver (you) should take when the
device sends any data in. The pending buffer will then just return to
you immediately with the data (and you should then resubmit another
buffer - it's good to keep multiple buffers pending so there's never
any gap in device polling).
Keep in mind that using javax.usb isn't high level programming.
You're doing very low level device communication, and it's
complicated, because the usb spec is very complicated.
###==> Can you please provide a example code to poll the input pipe to read buffer.
>
>>
>> final UsbPipeListener listener = new UsbPipeListener() {
>> @Override
>> public void errorEventOccurred(UsbPipeErrorEvent event) {
>> // TODO Auto-generated method stub
>> }
>> @Override
>> public void dataEventOccurred(UsbPipeDataEvent event) {
>> final int transferLength = event.getActualLength();
>> log("UsbPipeDataEvent occurred on IN UsbPipe with data size " + transferLength);
>>
>> //Asynchronously read the status in byte[] from IN UsbPipe
>> log("Asynchronously reading the status in byte[] from IN UsbPipe ...");
>> UsbIrp irp = inUsbPipe.asyncSubmit(new byte[transferLength]);
>
> you shouldn't be using getActualLength to size the next buffer to send
> - it should be consistent, or at least based on the device's protocol,
> and the actual length is simply how many bytes this irp returned.
>
>>
>> //Wait for the UsbIrp to complete
>> log("Waiting for the reading to complete ...");
>> irp.waitUntilComplete();
>
> um...what is the point of asyncSubmit() and then immediately in the
> same thread waiting for it to complete? Additionally, your listener
> callback is supposed to be quick, since calls will come sequentially.
> And what is the point of waiting for the irp to complete right before
> you exit the method?
>
>> }
>> };
>> inUsbPipe.addUsbPipeListener(listener);
>>
>> ------- Original Message -------
>> Sender : Dan Streetman<dds...@ie...>
>> Date : Oct 02, 2013 22:31 (GMT+09:00)
>> Title : Re: [javax-usb-devel] Hang problem with UsbPipe.syncSubmit(byte[])
>>
>> On Wed, Oct 2, 2013 at 6:23 AM, SANJAY GUPTA <gup...@sa...> wrote:
>>> Hi All,
>>>
>>> Please look below the sample scenario:-
>>>
>>> final byte[] outData = new byte[] {
>>> (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03,
>>> (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,
>>> (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
>>> (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x01B,
>>> (byte) 0x0C, (byte) 0x0D, (byte) 0x0E, (byte) 0x0F,
>>> (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03,
>>> (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,
>>> (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }
>>> final byte[] inData = new byte[13];
>>>
>>> log("Synchronously submitting the byte[] to UsbPipe ...");
>>> outUsbPipe.syncSubmit(data);
>>>
>>> //Synchronously read the status from IN UsbPipe
>>> log("Synchronously reading the status from IN UsbPipe ...");
>>> inUsbPipe.syncSubmit(inData);
>>>
>>> This code is working fine but I am facing problem if I want to change (reduce/reduce/modify) the outData.
>>> The control gets hang on reading the status data from the Input UsbPipe.
>>> Any suggestion on below points will be helpful:-
>>> 1. Is there any specific data format (may be starting header) in the actual data being transferred?
>>
>> Data formats are entirely up to the device, unless the device
>> implements a higher level spec (like HID, mass storage, etc) that
>> itself contains the API for the data format. USB doesn't specify any
>> data format at all, except for the control pipe 8-byte setup packet
>> that must preface each control transfer, and the various default
>> control pipe standard requests (set interface, clear stall, etc).
>>
>>
>> ===> Thanks A lot. I am using a mass-storage device and BULK type UsbEndpoint for data transfer.
>> But the problem is, suppose I keep the value of outData[8] as non-zero with all other things intact, the submission gets hanged which never completes.
>> And then I have no choice but the unplug the device.
>>
>>
>>
>>> 2. What is the data size which can be transferred using single invocation of syncSubmit()?
>>
>> it's been a while, but IIRC there's no limit in java, although I think
>> the platform may enforce limits. I don't really remember the details
>> though. For interrupt pipes, you of course should usually submit
>> exactly the pipe size (wMaxPacketSize).
>>
>> ===> Mass-storage device and BULK type UsbEndpoint.
>>
>>> 3. What is the status data size which is received on Input Pipe as a result of out data transfer?
>>
>> it's entirely dependent on your device. although if your input pipe
>> is an interrupt pipe, it should be the wMaxPacketSize from the
>> endpoint descriptor.
>>
>> Also, assuming your input pipe is interrupt type, it's probably better
>> for you to keep a buffer on it, which will cause continuous polling of
>> the device, as required by spec when the device is in use. You can do
>> that either with a separate Thread that does nothing except
>> syncSubmit() a buffer or irp to the pipe, then passes the returned
>> data off somewhere else to process and immediately syncSubmit() a new
>> buffer, or you can use asyncSubmit() with either a listener on the
>> pipe or a separate Thread to waitUntilComplete() for the irp, and then
>> also hand off the returned data to process somewhere else and
>> immediately sync or async submit again a new buffer. With
>> asyncSubmit(), you can submit multiple buffers, which is better
>> because it keeps the low level platform queued up with buffers so that
>> the device polling never stops, and you don't have to try to be quite
>> so fast at resubmitting a new buffer.
>>
>> ===> Mass-storage device and BULK type UsbEndpoint.
>>
>>
>>>
>>> Thanks in Advance..
>>> Sanjay Gupta
>>>
>>> ------------------------------------------------------------------------------
>>> October Webinars: Code for Performance
>>> Free Intel webinars can help you accelerate application performance.
>>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
>>> the latest Intel processors and coprocessors. See abstracts and register >
>>> http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> javax-usb-devel mailing list
>>> jav...@li...
>>> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
>>
>>
>> ------------------------------------------------------------------------------
>> October Webinars: Code for Performance
>> Free Intel webinars can help you accelerate application performance.
>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
>> the latest Intel processors and coprocessors. See abstracts and register >
>> http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
>> _______________________________________________
>> javax-usb-devel mailing list
>> jav...@li...
>> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
> _______________________________________________
> javax-usb-devel mailing list
> jav...@li...
> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
|
|
From: Dan S. <dds...@ie...> - 2013-10-08 12:28:46
|
On Tue, Oct 8, 2013 at 3:51 AM, SANJAY GUPTA <gup...@sa...> wrote:
> Thanks,
> Sanjay Gupta<p> </p><p> </p>
>
> ------- Original Message -------
> Sender : Dan Streetman<dds...@ie...>
> Date : Oct 07, 2013 21:37 (GMT+09:00)
> Title : Re: [javax-usb-devel] Hang problem with UsbPipe.syncSubmit(byte[])
>
> On Mon, Oct 7, 2013 at 1:48 AM, SANJAY GUPTA <gup...@sa...> wrote:
>> Reposting the query after removing formatting...
>>
>> Thanks for your great support.
>> I tried below as suggested:-
>>
>> int maxPacketSize = outUsbPipe.getUsbEndpoint().getUsbEndpointDescriptor().wMaxPacketSize( );
>> log("Max Packet Size: " + maxPacketSize);
>> final byte[] buffer = new byte[8192];
>> for (int offset=0; offset<buffer.length; offset+=maxPacketSize) {
>> final UsbIrp usbIrp = outUsbPipe.createUsbIrp( );
>> usbIrp.setData(buffer, offset, maxPacketSize);
>
> Well I don't think I suggested splitting the output data into max
> packet sized irps, that's certainly unnecessary and will drastically
> cut down on your throughput. I think I said use "reasonable" buffer
> sizes. I'm pretty sure 8k is ok to send in a single irp.
>
> ==> If I transmit the whole buffer of 8K in single submission using asyncSubmt() and wait for it to complete, the submission never gets completed and stucks on waitUntilComplete(). The same thing happens while using syncSubmit(). I do wait for the asynSubmit() to complete because my purpose is to capture the completion time for the submission for different sized buffers.
>
> Also, please not that the hang happens only when the buffer is uninitialized. If I initialize the buffer then the UsbStallException is thrown.
>
> for (int index=0; index<buffer.length; index++) {
> buffer[index] = (byte) index;
> }
This sounds like you don't understand the protocol of your device.
>
>>
>> //Asynchronously submit the UsbIrp to UsbPipe
>> log("==> Asynchronously submitting the UsbIrp to UsbPipe ...");
>> outUsbPipe.asyncSubmit(usbIrp);
>>
>> //Wait for the UsbIrp to complete
>> log("Waiting for the UsbIrp to complete ...");
>> usbIrp.waitUntilComplete();
>>
>> log("!!! Successfully submitted the UsbIrp to UsbPipe ...");
>> }
>>
>> But after successfully executing the loop for 3 times, it goes stuck on waitUntilComplete() as below-
>>
>> Max Packet Size: 512
>> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
>> Waiting for the UsbIrp to complete ...
>> !!! Successfully submitted the UsbIrp to UsbPipe ...
>> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
>> Waiting for the UsbIrp to complete ...
>> !!! Successfully submitted the UsbIrp to UsbPipe ...
>> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
>> Waiting for the UsbIrp to complete ...
>> !!! Successfully submitted the UsbIrp to UsbPipe ...
>> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
>> Waiting for the UsbIrp to complete ...
>>
>>
>> I even put a UsbPipeListener before the above code to poll the UsbPipeDataEvent on Input UsbPipe but failed to receive any event.
>
> did you actually submit one or more buffers to the input pipe? You
> obviously will never get anything if you don't submit a buffer to be
> filled.
>
> ==> My mistake. But I have a feeling that if the status data from the Input pipe is not read then further submission gets stuck. So, how to know that there is some data to be read on the input pipe?
When you get a buffer back (i.e. a completed IRP), either when
syncSubmit() returns or waitUntilComplete() returns or your listener
gets triggered, the device has already sent data back, that is now in
the buffer you provided.
Knowing that there is data "to be read" on the pipe isn't possible
(except predicting that there *should* be data sent back from the
device based on the specific device protocol, of course). Generally
you should just keep buffer(s) "pending" on any input pipe, since most
specs describe actions that the driver (you) should take when the
device sends any data in. The pending buffer will then just return to
you immediately with the data (and you should then resubmit another
buffer - it's good to keep multiple buffers pending so there's never
any gap in device polling).
Keep in mind that using javax.usb isn't high level programming.
You're doing very low level device communication, and it's
complicated, because the usb spec is very complicated.
>
>>
>> final UsbPipeListener listener = new UsbPipeListener() {
>> @Override
>> public void errorEventOccurred(UsbPipeErrorEvent event) {
>> // TODO Auto-generated method stub
>> }
>> @Override
>> public void dataEventOccurred(UsbPipeDataEvent event) {
>> final int transferLength = event.getActualLength();
>> log("UsbPipeDataEvent occurred on IN UsbPipe with data size " + transferLength);
>>
>> //Asynchronously read the status in byte[] from IN UsbPipe
>> log("Asynchronously reading the status in byte[] from IN UsbPipe ...");
>> UsbIrp irp = inUsbPipe.asyncSubmit(new byte[transferLength]);
>
> you shouldn't be using getActualLength to size the next buffer to send
> - it should be consistent, or at least based on the device's protocol,
> and the actual length is simply how many bytes this irp returned.
>
>>
>> //Wait for the UsbIrp to complete
>> log("Waiting for the reading to complete ...");
>> irp.waitUntilComplete();
>
> um...what is the point of asyncSubmit() and then immediately in the
> same thread waiting for it to complete? Additionally, your listener
> callback is supposed to be quick, since calls will come sequentially.
> And what is the point of waiting for the irp to complete right before
> you exit the method?
>
>> }
>> };
>> inUsbPipe.addUsbPipeListener(listener);
>>
>> ------- Original Message -------
>> Sender : Dan Streetman<dds...@ie...>
>> Date : Oct 02, 2013 22:31 (GMT+09:00)
>> Title : Re: [javax-usb-devel] Hang problem with UsbPipe.syncSubmit(byte[])
>>
>> On Wed, Oct 2, 2013 at 6:23 AM, SANJAY GUPTA <gup...@sa...> wrote:
>>> Hi All,
>>>
>>> Please look below the sample scenario:-
>>>
>>> final byte[] outData = new byte[] {
>>> (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03,
>>> (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,
>>> (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
>>> (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x01B,
>>> (byte) 0x0C, (byte) 0x0D, (byte) 0x0E, (byte) 0x0F,
>>> (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03,
>>> (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,
>>> (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }
>>> final byte[] inData = new byte[13];
>>>
>>> log("Synchronously submitting the byte[] to UsbPipe ...");
>>> outUsbPipe.syncSubmit(data);
>>>
>>> //Synchronously read the status from IN UsbPipe
>>> log("Synchronously reading the status from IN UsbPipe ...");
>>> inUsbPipe.syncSubmit(inData);
>>>
>>> This code is working fine but I am facing problem if I want to change (reduce/reduce/modify) the outData.
>>> The control gets hang on reading the status data from the Input UsbPipe.
>>> Any suggestion on below points will be helpful:-
>>> 1. Is there any specific data format (may be starting header) in the actual data being transferred?
>>
>> Data formats are entirely up to the device, unless the device
>> implements a higher level spec (like HID, mass storage, etc) that
>> itself contains the API for the data format. USB doesn't specify any
>> data format at all, except for the control pipe 8-byte setup packet
>> that must preface each control transfer, and the various default
>> control pipe standard requests (set interface, clear stall, etc).
>>
>>
>> ===> Thanks A lot. I am using a mass-storage device and BULK type UsbEndpoint for data transfer.
>> But the problem is, suppose I keep the value of outData[8] as non-zero with all other things intact, the submission gets hanged which never completes.
>> And then I have no choice but the unplug the device.
>>
>>
>>
>>> 2. What is the data size which can be transferred using single invocation of syncSubmit()?
>>
>> it's been a while, but IIRC there's no limit in java, although I think
>> the platform may enforce limits. I don't really remember the details
>> though. For interrupt pipes, you of course should usually submit
>> exactly the pipe size (wMaxPacketSize).
>>
>> ===> Mass-storage device and BULK type UsbEndpoint.
>>
>>> 3. What is the status data size which is received on Input Pipe as a result of out data transfer?
>>
>> it's entirely dependent on your device. although if your input pipe
>> is an interrupt pipe, it should be the wMaxPacketSize from the
>> endpoint descriptor.
>>
>> Also, assuming your input pipe is interrupt type, it's probably better
>> for you to keep a buffer on it, which will cause continuous polling of
>> the device, as required by spec when the device is in use. You can do
>> that either with a separate Thread that does nothing except
>> syncSubmit() a buffer or irp to the pipe, then passes the returned
>> data off somewhere else to process and immediately syncSubmit() a new
>> buffer, or you can use asyncSubmit() with either a listener on the
>> pipe or a separate Thread to waitUntilComplete() for the irp, and then
>> also hand off the returned data to process somewhere else and
>> immediately sync or async submit again a new buffer. With
>> asyncSubmit(), you can submit multiple buffers, which is better
>> because it keeps the low level platform queued up with buffers so that
>> the device polling never stops, and you don't have to try to be quite
>> so fast at resubmitting a new buffer.
>>
>> ===> Mass-storage device and BULK type UsbEndpoint.
>>
>>
>>>
>>> Thanks in Advance..
>>> Sanjay Gupta
>>>
>>> ------------------------------------------------------------------------------
>>> October Webinars: Code for Performance
>>> Free Intel webinars can help you accelerate application performance.
>>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
>>> the latest Intel processors and coprocessors. See abstracts and register >
>>> http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> javax-usb-devel mailing list
>>> jav...@li...
>>> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
>>
>>
>> ------------------------------------------------------------------------------
>> October Webinars: Code for Performance
>> Free Intel webinars can help you accelerate application performance.
>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
>> the latest Intel processors and coprocessors. See abstracts and register >
>> http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
>> _______________________________________________
>> javax-usb-devel mailing list
>> jav...@li...
>> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
> _______________________________________________
> javax-usb-devel mailing list
> jav...@li...
> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
|
|
From: SANJAY G. <gup...@sa...> - 2013-10-08 07:51:19
|
Thanks,
Sanjay Gupta<p> </p><p> </p>
------- Original Message -------
Sender : Dan Streetman<dds...@ie...>
Date : Oct 07, 2013 21:37 (GMT+09:00)
Title : Re: [javax-usb-devel] Hang problem with UsbPipe.syncSubmit(byte[])
On Mon, Oct 7, 2013 at 1:48 AM, SANJAY GUPTA <gup...@sa...> wrote:
> Reposting the query after removing formatting...
>
> Thanks for your great support.
> I tried below as suggested:-
>
> int maxPacketSize = outUsbPipe.getUsbEndpoint().getUsbEndpointDescriptor().wMaxPacketSize( );
> log("Max Packet Size: " + maxPacketSize);
> final byte[] buffer = new byte[8192];
> for (int offset=0; offset<buffer.length; offset+=maxPacketSize) {
> final UsbIrp usbIrp = outUsbPipe.createUsbIrp( );
> usbIrp.setData(buffer, offset, maxPacketSize);
Well I don't think I suggested splitting the output data into max
packet sized irps, that's certainly unnecessary and will drastically
cut down on your throughput. I think I said use "reasonable" buffer
sizes. I'm pretty sure 8k is ok to send in a single irp.
==> If I transmit the whole buffer of 8K in single submission using asyncSubmt() and wait for it to complete, the submission never gets completed and stucks on waitUntilComplete(). The same thing happens while using syncSubmit(). I do wait for the asynSubmit() to complete because my purpose is to capture the completion time for the submission for different sized buffers.
Also, please not that the hang happens only when the buffer is uninitialized. If I initialize the buffer then the UsbStallException is thrown.
for (int index=0; index<buffer.length; index++) {
buffer[index] = (byte) index;
}
>
> //Asynchronously submit the UsbIrp to UsbPipe
> log("==> Asynchronously submitting the UsbIrp to UsbPipe ...");
> outUsbPipe.asyncSubmit(usbIrp);
>
> //Wait for the UsbIrp to complete
> log("Waiting for the UsbIrp to complete ...");
> usbIrp.waitUntilComplete();
>
> log("!!! Successfully submitted the UsbIrp to UsbPipe ...");
> }
>
> But after successfully executing the loop for 3 times, it goes stuck on waitUntilComplete() as below-
>
> Max Packet Size: 512
> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
> Waiting for the UsbIrp to complete ...
> !!! Successfully submitted the UsbIrp to UsbPipe ...
> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
> Waiting for the UsbIrp to complete ...
> !!! Successfully submitted the UsbIrp to UsbPipe ...
> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
> Waiting for the UsbIrp to complete ...
> !!! Successfully submitted the UsbIrp to UsbPipe ...
> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
> Waiting for the UsbIrp to complete ...
>
>
> I even put a UsbPipeListener before the above code to poll the UsbPipeDataEvent on Input UsbPipe but failed to receive any event.
did you actually submit one or more buffers to the input pipe? You
obviously will never get anything if you don't submit a buffer to be
filled.
==> My mistake. But I have a feeling that if the status data from the Input pipe is not read then further submission gets stuck. So, how to know that there is some data to be read on the input pipe?
>
> final UsbPipeListener listener = new UsbPipeListener() {
> @Override
> public void errorEventOccurred(UsbPipeErrorEvent event) {
> // TODO Auto-generated method stub
> }
> @Override
> public void dataEventOccurred(UsbPipeDataEvent event) {
> final int transferLength = event.getActualLength();
> log("UsbPipeDataEvent occurred on IN UsbPipe with data size " + transferLength);
>
> //Asynchronously read the status in byte[] from IN UsbPipe
> log("Asynchronously reading the status in byte[] from IN UsbPipe ...");
> UsbIrp irp = inUsbPipe.asyncSubmit(new byte[transferLength]);
you shouldn't be using getActualLength to size the next buffer to send
- it should be consistent, or at least based on the device's protocol,
and the actual length is simply how many bytes this irp returned.
>
> //Wait for the UsbIrp to complete
> log("Waiting for the reading to complete ...");
> irp.waitUntilComplete();
um...what is the point of asyncSubmit() and then immediately in the
same thread waiting for it to complete? Additionally, your listener
callback is supposed to be quick, since calls will come sequentially.
And what is the point of waiting for the irp to complete right before
you exit the method?
> }
> };
> inUsbPipe.addUsbPipeListener(listener);
>
> ------- Original Message -------
> Sender : Dan Streetman<dds...@ie...>
> Date : Oct 02, 2013 22:31 (GMT+09:00)
> Title : Re: [javax-usb-devel] Hang problem with UsbPipe.syncSubmit(byte[])
>
> On Wed, Oct 2, 2013 at 6:23 AM, SANJAY GUPTA <gup...@sa...> wrote:
>> Hi All,
>>
>> Please look below the sample scenario:-
>>
>> final byte[] outData = new byte[] {
>> (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03,
>> (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,
>> (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
>> (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x01B,
>> (byte) 0x0C, (byte) 0x0D, (byte) 0x0E, (byte) 0x0F,
>> (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03,
>> (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,
>> (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }
>> final byte[] inData = new byte[13];
>>
>> log("Synchronously submitting the byte[] to UsbPipe ...");
>> outUsbPipe.syncSubmit(data);
>>
>> //Synchronously read the status from IN UsbPipe
>> log("Synchronously reading the status from IN UsbPipe ...");
>> inUsbPipe.syncSubmit(inData);
>>
>> This code is working fine but I am facing problem if I want to change (reduce/reduce/modify) the outData.
>> The control gets hang on reading the status data from the Input UsbPipe.
>> Any suggestion on below points will be helpful:-
>> 1. Is there any specific data format (may be starting header) in the actual data being transferred?
>
> Data formats are entirely up to the device, unless the device
> implements a higher level spec (like HID, mass storage, etc) that
> itself contains the API for the data format. USB doesn't specify any
> data format at all, except for the control pipe 8-byte setup packet
> that must preface each control transfer, and the various default
> control pipe standard requests (set interface, clear stall, etc).
>
>
> ===> Thanks A lot. I am using a mass-storage device and BULK type UsbEndpoint for data transfer.
> But the problem is, suppose I keep the value of outData[8] as non-zero with all other things intact, the submission gets hanged which never completes.
> And then I have no choice but the unplug the device.
>
>
>
>> 2. What is the data size which can be transferred using single invocation of syncSubmit()?
>
> it's been a while, but IIRC there's no limit in java, although I think
> the platform may enforce limits. I don't really remember the details
> though. For interrupt pipes, you of course should usually submit
> exactly the pipe size (wMaxPacketSize).
>
> ===> Mass-storage device and BULK type UsbEndpoint.
>
>> 3. What is the status data size which is received on Input Pipe as a result of out data transfer?
>
> it's entirely dependent on your device. although if your input pipe
> is an interrupt pipe, it should be the wMaxPacketSize from the
> endpoint descriptor.
>
> Also, assuming your input pipe is interrupt type, it's probably better
> for you to keep a buffer on it, which will cause continuous polling of
> the device, as required by spec when the device is in use. You can do
> that either with a separate Thread that does nothing except
> syncSubmit() a buffer or irp to the pipe, then passes the returned
> data off somewhere else to process and immediately syncSubmit() a new
> buffer, or you can use asyncSubmit() with either a listener on the
> pipe or a separate Thread to waitUntilComplete() for the irp, and then
> also hand off the returned data to process somewhere else and
> immediately sync or async submit again a new buffer. With
> asyncSubmit(), you can submit multiple buffers, which is better
> because it keeps the low level platform queued up with buffers so that
> the device polling never stops, and you don't have to try to be quite
> so fast at resubmitting a new buffer.
>
> ===> Mass-storage device and BULK type UsbEndpoint.
>
>
>>
>> Thanks in Advance..
>> Sanjay Gupta
>>
>> ------------------------------------------------------------------------------
>> October Webinars: Code for Performance
>> Free Intel webinars can help you accelerate application performance.
>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
>> the latest Intel processors and coprocessors. See abstracts and register >
>> http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
>> _______________________________________________
>> javax-usb-devel mailing list
>> jav...@li...
>> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
>
>
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
> _______________________________________________
> javax-usb-devel mailing list
> jav...@li...
> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
|
|
From: Dan S. <dds...@ie...> - 2013-10-07 12:37:42
|
On Mon, Oct 7, 2013 at 1:48 AM, SANJAY GUPTA <gup...@sa...> wrote:
> Reposting the query after removing formatting...
>
> Thanks for your great support.
> I tried below as suggested:-
>
> int maxPacketSize = outUsbPipe.getUsbEndpoint().getUsbEndpointDescriptor().wMaxPacketSize( );
> log("Max Packet Size: " + maxPacketSize);
> final byte[] buffer = new byte[8192];
> for (int offset=0; offset<buffer.length; offset+=maxPacketSize) {
> final UsbIrp usbIrp = outUsbPipe.createUsbIrp( );
> usbIrp.setData(buffer, offset, maxPacketSize);
Well I don't think I suggested splitting the output data into max
packet sized irps, that's certainly unnecessary and will drastically
cut down on your throughput. I think I said use "reasonable" buffer
sizes. I'm pretty sure 8k is ok to send in a single irp.
>
> //Asynchronously submit the UsbIrp to UsbPipe
> log("==> Asynchronously submitting the UsbIrp to UsbPipe ...");
> outUsbPipe.asyncSubmit(usbIrp);
>
> //Wait for the UsbIrp to complete
> log("Waiting for the UsbIrp to complete ...");
> usbIrp.waitUntilComplete();
>
> log("!!! Successfully submitted the UsbIrp to UsbPipe ...");
> }
>
> But after successfully executing the loop for 3 times, it goes stuck on waitUntilComplete() as below-
>
> Max Packet Size: 512
> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
> Waiting for the UsbIrp to complete ...
> !!! Successfully submitted the UsbIrp to UsbPipe ...
> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
> Waiting for the UsbIrp to complete ...
> !!! Successfully submitted the UsbIrp to UsbPipe ...
> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
> Waiting for the UsbIrp to complete ...
> !!! Successfully submitted the UsbIrp to UsbPipe ...
> ==> Asynchronously submitting the UsbIrp to UsbPipe ...
> Waiting for the UsbIrp to complete ...
>
>
> I even put a UsbPipeListener before the above code to poll the UsbPipeDataEvent on Input UsbPipe but failed to receive any event.
did you actually submit one or more buffers to the input pipe? You
obviously will never get anything if you don't submit a buffer to be
filled.
>
> final UsbPipeListener listener = new UsbPipeListener() {
> @Override
> public void errorEventOccurred(UsbPipeErrorEvent event) {
> // TODO Auto-generated method stub
> }
> @Override
> public void dataEventOccurred(UsbPipeDataEvent event) {
> final int transferLength = event.getActualLength();
> log("UsbPipeDataEvent occurred on IN UsbPipe with data size " + transferLength);
>
> //Asynchronously read the status in byte[] from IN UsbPipe
> log("Asynchronously reading the status in byte[] from IN UsbPipe ...");
> UsbIrp irp = inUsbPipe.asyncSubmit(new byte[transferLength]);
you shouldn't be using getActualLength to size the next buffer to send
- it should be consistent, or at least based on the device's protocol,
and the actual length is simply how many bytes this irp returned.
>
> //Wait for the UsbIrp to complete
> log("Waiting for the reading to complete ...");
> irp.waitUntilComplete();
um...what is the point of asyncSubmit() and then immediately in the
same thread waiting for it to complete? Additionally, your listener
callback is supposed to be quick, since calls will come sequentially.
And what is the point of waiting for the irp to complete right before
you exit the method?
> }
> };
> inUsbPipe.addUsbPipeListener(listener);
>
> ------- Original Message -------
> Sender : Dan Streetman<dds...@ie...>
> Date : Oct 02, 2013 22:31 (GMT+09:00)
> Title : Re: [javax-usb-devel] Hang problem with UsbPipe.syncSubmit(byte[])
>
> On Wed, Oct 2, 2013 at 6:23 AM, SANJAY GUPTA <gup...@sa...> wrote:
>> Hi All,
>>
>> Please look below the sample scenario:-
>>
>> final byte[] outData = new byte[] {
>> (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03,
>> (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,
>> (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
>> (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x01B,
>> (byte) 0x0C, (byte) 0x0D, (byte) 0x0E, (byte) 0x0F,
>> (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03,
>> (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,
>> (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }
>> final byte[] inData = new byte[13];
>>
>> log("Synchronously submitting the byte[] to UsbPipe ...");
>> outUsbPipe.syncSubmit(data);
>>
>> //Synchronously read the status from IN UsbPipe
>> log("Synchronously reading the status from IN UsbPipe ...");
>> inUsbPipe.syncSubmit(inData);
>>
>> This code is working fine but I am facing problem if I want to change (reduce/reduce/modify) the outData.
>> The control gets hang on reading the status data from the Input UsbPipe.
>> Any suggestion on below points will be helpful:-
>> 1. Is there any specific data format (may be starting header) in the actual data being transferred?
>
> Data formats are entirely up to the device, unless the device
> implements a higher level spec (like HID, mass storage, etc) that
> itself contains the API for the data format. USB doesn't specify any
> data format at all, except for the control pipe 8-byte setup packet
> that must preface each control transfer, and the various default
> control pipe standard requests (set interface, clear stall, etc).
>
>
> ===> Thanks A lot. I am using a mass-storage device and BULK type UsbEndpoint for data transfer.
> But the problem is, suppose I keep the value of outData[8] as non-zero with all other things intact, the submission gets hanged which never completes.
> And then I have no choice but the unplug the device.
>
>
>
>> 2. What is the data size which can be transferred using single invocation of syncSubmit()?
>
> it's been a while, but IIRC there's no limit in java, although I think
> the platform may enforce limits. I don't really remember the details
> though. For interrupt pipes, you of course should usually submit
> exactly the pipe size (wMaxPacketSize).
>
> ===> Mass-storage device and BULK type UsbEndpoint.
>
>> 3. What is the status data size which is received on Input Pipe as a result of out data transfer?
>
> it's entirely dependent on your device. although if your input pipe
> is an interrupt pipe, it should be the wMaxPacketSize from the
> endpoint descriptor.
>
> Also, assuming your input pipe is interrupt type, it's probably better
> for you to keep a buffer on it, which will cause continuous polling of
> the device, as required by spec when the device is in use. You can do
> that either with a separate Thread that does nothing except
> syncSubmit() a buffer or irp to the pipe, then passes the returned
> data off somewhere else to process and immediately syncSubmit() a new
> buffer, or you can use asyncSubmit() with either a listener on the
> pipe or a separate Thread to waitUntilComplete() for the irp, and then
> also hand off the returned data to process somewhere else and
> immediately sync or async submit again a new buffer. With
> asyncSubmit(), you can submit multiple buffers, which is better
> because it keeps the low level platform queued up with buffers so that
> the device polling never stops, and you don't have to try to be quite
> so fast at resubmitting a new buffer.
>
> ===> Mass-storage device and BULK type UsbEndpoint.
>
>
>>
>> Thanks in Advance..
>> Sanjay Gupta
>>
>> ------------------------------------------------------------------------------
>> October Webinars: Code for Performance
>> Free Intel webinars can help you accelerate application performance.
>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
>> the latest Intel processors and coprocessors. See abstracts and register >
>> http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
>> _______________________________________________
>> javax-usb-devel mailing list
>> jav...@li...
>> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
>
>
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
> _______________________________________________
> javax-usb-devel mailing list
> jav...@li...
> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
|
|
From: Dan S. <dds...@ie...> - 2013-10-07 12:28:39
|
On Mon, Oct 7, 2013 at 4:21 AM, SANJAY GUPTA <gup...@sa...> wrote:
>
> Thanks Dan,
>
>
>
> I was wrong to assume that each UsbDevice has atleast one Control Type UsbEndpoint other than the default control endpoint.
>
> Can you list out
>
> 1. Some of the control device examples
>
> 2. Operations which can't be done using default control endpoint
>
I don't know what you are looking for here...if you want to know what
the standard usb control requests are, read the usb spec chapter 9.
>
>
> Sorry, if its too novice a query!!!
>
> Thanks.
> Sanjay Gupta
>
>
>
>
>
> ------- Original Message -------
>
> Sender : SANJAY GUPTA<gup...@sa...> S5/Senior Engineer/Architecture Analysis Lab./Samsung Electronics
>
> Date : Oct 04, 2013 11:29 (GMT+09:00)
>
> Title : Re: [javax-usb-devel] Unable to fine Control type UsbEndpoint on UsbDevice
>
>
>
> Thanks for your reply.
>
> I am not interested in default control endpoint.
>
> I know the endpoing with address 0x00 is a default control endpoint with which I am able to do control operations using UsbControlIrp.
>
> But I want to get other endpoint provided by currently active configuration and interface which has type ENDPOINT_TYPE_CONTROL.
>
> For your information, the UsbDevice is a mass-storage device.
>
>
>
> On Wed, Oct 2, 2013 at 6:30 AM, SANJAY GUPTA <gup...@sa...> wrote:
>
>
> > Hi All,
> >
> > I am trying to find the Control type UsbEndpoint using below method expecting that each UsbDevice has atlease one control endpoint. But this is unable to find the desired endpoint and returns null.
>
> You're probably talking about endpoint 0, or the "default control
> pipe", which is a special endpoint that doesn't belong to any
> configuration or interface (or, depending on how you read the spec, it
> belongs to all configurations and interfaces, but that is not the
> interpretation used by javax.usb). You can use it via the UsbDevice
> interface methods createUsbControlIrp(), asyncSubmit() or
> syncSubmit(), etc.
>
> >
> > private UsbEndpoint getControlEndpoint(final UsbDevice usbDevice) {
> > final UsbDeviceDescriptor usbDeviceDescriptor = usbDevice.getUsbDeviceDescriptor();
> > for ( int i=0; i<usbDeviceDescriptor.bNumConfigurations(); i++ )
> > {
> > final UsbConfiguration usbCurrentConfig = usbDevice.getUsbConfiguration((byte) (i+1));
> > if ( usbCurrentConfig == null) {
> > continue;
> > }
> >
> > final UsbConfigurationDescriptor usbCurrentConfigDescriptor = usbCurrentConfig.getUsbConfigurationDescriptor();
> > for ( int j=0; j<usbCurrentConfigDescriptor.bNumInterfaces(); j++ )
> > {
> > UsbInterface usbCurrentInterface = usbCurrentConfig.getUsbInterface((byte) j);
> > for ( int k=0; k<usbCurrentInterface.getNumSettings(); k++ )
> > {
> > usbCurrentInterface = usbCurrentInterface.getSetting((byte) k);
> > final List<?> usbEndpoints = usbCurrentInterface.getUsbEndpoints();
> > for ( int l = 0; l<usbEndpoints.size(); l++ )
> > {
> > final UsbEndpoint usbCurrentEndpoint = (UsbEndpoint) usbEndpoints.get(l);
> > if ( usbCurrentEndpoint.getType() == UsbConst.ENDPOINT_TYPE_CONTROL & usbCurrentEndpoint.getUsbEndpointDescriptor().bEndpointAddress() != (byte) 0x00 )
> > {
> > return usbCurrentEndpoint;
> > }
> > }
> > }
> > }
> > }
> > return null;
> > }
> >
> > Any suggestion would be of great help.
> >
> > Thanks in Advance..
> > Sanjay Gupta
> >
> > ------------------------------------------------------------------------------
> > October Webinars: Code for Performance
> > Free Intel webinars can help you accelerate application performance.
> > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
> > the latest Intel processors and coprocessors. See abstracts and register >
> > http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
> > _______________________________________________
> > javax-usb-devel mailing list
> > jav...@li...
> > https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
>
>
>
>
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
> _______________________________________________
> javax-usb-devel mailing list
> jav...@li...
> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
>
|