|
From: SANJAY G. <gup...@sa...> - 2013-10-07 05:38:29
|
<HTML><HEAD><TITLE>Samsung Enterprise Portal mySingle</TITLE>
<META content=IE=5 http-equiv=X-UA-Compatible>
<META content="text/html; charset=euc-kr" http-equiv=Content-Type>
<STYLE id=mysingle_style type=text/css>P {
MARGIN-BOTTOM: 5px; FONT-SIZE: 12pt; FONT-FAMILY: 굴림체, arial; MARGIN-TOP: 5px
}
TD {
MARGIN-BOTTOM: 5px; FONT-SIZE: 12pt; FONT-FAMILY: 굴림체, arial; MARGIN-TOP: 5px
}
LI {
MARGIN-BOTTOM: 5px; FONT-SIZE: 12pt; FONT-FAMILY: 굴림체, arial; MARGIN-TOP: 5px
}
BODY {
FONT-SIZE: 12pt; FONT-FAMILY: 굴림체, arial; MARGIN: 10px; LINE-HEIGHT: 1.4
}
</STYLE>
<META name=GENERATOR content=ActiveSquare></HEAD>
<BODY>
<P><SPAN style="FONT-SIZE: 10pt">Thanks for your great support.</SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt">I tried below as suggested:-</SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt"></SPAN> </P>
<P><SPAN style="FONT-SIZE: 10pt"> </SPAN><SPAN style="FONT-SIZE: 10pt"><SPAN style="FONT-SIZE: 8pt">int maxPacketSize = outUsbPipe.getUsbEndpoint().getUsbEndpointDescriptor().wMaxPacketSize( );<BR> log("Max Packet Size: " + maxPacketSize);<BR> final byte[] buffer = new byte[8192];</SPAN></SPAN></P>
<P><SPAN style="FONT-SIZE: 8pt"> for (int offset=0; offset<buffer.length; offset+=maxPacketSize) {<BR> final UsbIrp usbIrp = outUsbPipe.createUsbIrp( );<BR> usbIrp.setData(buffer, offset, maxPacketSize);</SPAN></P>
<P><SPAN style="FONT-SIZE: 8pt"></SPAN> </P>
<P><SPAN style="FONT-SIZE: 8pt"> //Asynchronously submit the UsbIrp to UsbPipe</SPAN></P>
<P><SPAN style="FONT-SIZE: 8pt"> log("==> Asynchronously submitting the UsbIrp to UsbPipe ...");<BR> outUsbPipe.asyncSubmit(usbIrp);</SPAN></P>
<P><SPAN style="FONT-SIZE: 8pt"></SPAN> </P>
<P><SPAN style="FONT-SIZE: 8pt"> //Wait for the UsbIrp to complete<BR> log("Waiting for the UsbIrp to complete ...");<BR> usbIrp.waitUntilComplete();</SPAN></P>
<P><SPAN style="FONT-SIZE: 8pt"></SPAN> </P>
<P><SPAN style="FONT-SIZE: 8pt"> log("!!! Successfully submitted the UsbIrp to UsbPipe ...");<BR> }</SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt"></SPAN> </P>
<P><SPAN style="FONT-SIZE: 10pt">But after successfully executing the loop for 3 times, it goes stuck on waitUntilComplete() as below-</SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt"></SPAN> </P>
<P><SPAN style="FONT-SIZE: 10pt"><EM><SPAN style="FONT-SIZE: 8pt">Max Packet Size: 512<BR>==> Asynchronously submitting the UsbIrp to UsbPipe ...<BR>Waiting for the UsbIrp to complete ...<BR>!!! Successfully submitted the UsbIrp to UsbPipe ...<BR>==> Asynchronously submitting the UsbIrp to UsbPipe ...<BR>Waiting for the UsbIrp to complete ...<BR>!!! Successfully submitted the UsbIrp to UsbPipe ...<BR>==> Asynchronously submitting the UsbIrp to UsbPipe ...<BR>Waiting for the UsbIrp to complete ...<BR>!!! Successfully submitted the UsbIrp to UsbPipe ...<BR>==> Asynchronously submitting the UsbIrp to UsbPipe ...<BR>Waiting for the UsbIrp to complete ...</SPAN></EM><SPAN style="FONT-SIZE: 8pt"><BR></SPAN></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt"><SPAN style="FONT-SIZE: 8pt"> </P></SPAN></SPAN>
<P><SPAN style="FONT-SIZE: 10pt">I even put a UsbPipeListener before the above code to poll the UsbPipeDataEvent on Input UsbPipe but failed to receive any event.</SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt"></SPAN> </P><SPAN style="FONT-SIZE: 10pt">
<P><SPAN style="FONT-SIZE: 8pt">final UsbPipeListener listener = new UsbPipeListener() {</SPAN></P>
<P><SPAN style="FONT-SIZE: 8pt"> @Override<BR> public void errorEventOccurred(UsbPipeErrorEvent event) {<BR> // TODO Auto-generated method stub</SPAN></P>
<P><SPAN style="FONT-SIZE: 8pt"> }</SPAN></P>
<P><SPAN style="FONT-SIZE: 8pt"> @Override<BR> public void dataEventOccurred(UsbPipeDataEvent event) {<BR> final int transferLength = event.getActualLength();<BR> log("UsbPipeDataEvent occurred on IN UsbPipe with data size " + transferLength);</SPAN></P>
<P><SPAN style="FONT-SIZE: 8pt"></SPAN> </P>
<P><SPAN style="FONT-SIZE: 8pt"> //Asynchronously read the status in byte[] from IN UsbPipe<BR> log("Asynchronously reading the status in byte[] from IN UsbPipe ...");<BR> UsbIrp irp = inUsbPipe.asyncSubmit(new byte[transferLength]);</SPAN></P>
<P><SPAN style="FONT-SIZE: 8pt"></SPAN> </P>
<P><SPAN style="FONT-SIZE: 8pt"> //Wait for the UsbIrp to complete<BR> log("Waiting for the reading to complete ...");<BR> irp.waitUntilComplete();<BR> }<BR> };<BR> inUsbPipe.addUsbPipeListener(listener);</SPAN></SPAN></P>
<P><EM><SPAN style="FONT-SIZE: 10pt"></SPAN></EM> </P>
<P><SPAN style="FONT-SIZE: 10pt">------- Original Message -------<BR>Sender : Dan Streetman<dds...@ie...> <BR>Date : Oct 02, 2013 22:31 (GMT+09:00)<BR>Title : Re: [javax-usb-devel] Hang problem with UsbPipe.syncSubmit(byte[])<BR><BR>On Wed, Oct 2, 2013 at 6:23 AM, SANJAY GUPTA <gup...@sa...> wrote:<BR>> Hi All,<BR>><BR>> Please look below the sample scenario:-<BR>><BR>> final byte[] outData = new byte[] {<BR>> (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03,<BR>> (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,<BR>> (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,<BR>> (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x01B,<BR>> (byte) 0x0C, (byte) 0x0D, (byte) 0x0E, (byte) 0x0F,<BR>> (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03,<BR>> (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,<BR>> (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }<BR>> final byte[] inData = new byte[13];<BR>><BR>> log("Synchronously submitting the byte[] to UsbPipe ...");<BR>> outUsbPipe.syncSubmit(data);<BR>><BR>> //Synchronously read the status from IN UsbPipe<BR>> log("Synchronously reading the status from IN UsbPipe ...");<BR>> inUsbPipe.syncSubmit(inData);<BR>><BR>> This code is working fine but I am facing problem if I want to change (reduce/reduce/modify) the outData.<BR>> The control gets hang on reading the status data from the Input UsbPipe.<BR>> Any suggestion on below points will be helpful:-<BR>> 1. Is there any specific data format (may be starting header) in the actual data being transferred?<BR><BR>Data formats are entirely up to the device, unless the device<BR>implements a higher level spec (like HID, mass storage, etc) that<BR>itself contains the API for the data format. USB doesn't specify any<BR>data format at all, except for the control pipe 8-byte setup packet<BR>that must preface each control transfer, and the various default<BR>control pipe standard requests (set interface, clear stall, etc).<BR><BR></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff">===> Thanks A lot. I am using a mass-storage device and BULK type UsbEndpoint for data transfer.</SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff">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.</SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff">And then I have no choice but the unplug the device.</SPAN><SPAN style="FONT-SIZE: 10pt"><BR><BR><BR><BR>> 2. What is the data size which can be transferred using single invocation of syncSubmit()?<BR><BR>it's been a while, but IIRC there's no limit in java, although I think<BR>the platform may enforce limits. I don't really remember the details<BR>though. For interrupt pipes, you of course should usually submit<BR>exactly the pipe size (wMaxPacketSize).<BR></SPAN></P>
<P><SPAN style="COLOR: #0000ff"><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff">===> Mass-storage device and BULK type UsbEndpoint.</SPAN></SPAN><SPAN style="FONT-SIZE: 10pt"><BR><BR>> 3. What is the status data size which is received on Input Pipe as a result of out data transfer?<BR><BR>it's entirely dependent on your device. although if your input pipe<BR>is an interrupt pipe, it should be the wMaxPacketSize from the<BR>endpoint descriptor.<BR><BR>Also, assuming your input pipe is interrupt type, it's probably better<BR>for you to keep a buffer on it, which will cause continuous polling of<BR>the device, as required by spec when the device is in use. You can do<BR>that either with a separate Thread that does nothing except<BR>syncSubmit() a buffer or irp to the pipe, then passes the returned<BR>data off somewhere else to process and immediately syncSubmit() a new<BR>buffer, or you can use asyncSubmit() with either a listener on the<BR>pipe or a separate Thread to waitUntilComplete() for the irp, and then<BR>also hand off the returned data to process somewhere else and<BR>immediately sync or async submit again a new buffer. With<BR>asyncSubmit(), you can submit multiple buffers, which is better<BR>because it keeps the low level platform queued up with buffers so that<BR>the device polling never stops, and you don't have to try to be quite<BR>so fast at resubmitting a new buffer.<BR></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff">===> Mass-storage device and BULK type UsbEndpoint.</SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt"><BR><BR>><BR>> Thanks in Advance..<BR>> Sanjay Gupta<BR>><BR>> ------------------------------------------------------------------------------<BR>> October Webinars: Code for Performance<BR>> Free Intel webinars can help you accelerate application performance.<BR>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from<BR>> the latest Intel processors and coprocessors. See abstracts and register ><BR>> http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk<BR>> _______________________________________________<BR>> javax-usb-devel mailing list<BR>> jav...@li...<BR>> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel<BR></SPAN></P><SPAN style="FONT-SIZE: 10pt"><IMG style="DISPLAY: none" border=0 src="http://ext.samsung.net/mailcheck/SeenTimeChecker?do=5b5b806e569672b08cefaf4d8420c5e41c40cf68e6889fd228f41a3773fe88f8a28a0f20ff0f747d3545973b7b0cb61b980b3871b38ac66662d74ed859d628c32758cd62c5cf0684a728c55b39cc59eacf878f9a26ce15a0" width=0 height=0> </SPAN>
<P><SPAN style="FONT-SIZE: 10pt"></SPAN> </P>
<TABLE id=confidentialsignimg>
<TBODY>
<TR>
<TD NAMO_LOCK>
<P><SPAN style="FONT-SIZE: 10pt"><IMG border=0 src="cid:XOK...@na..." width=520></SPAN></P></TD></TR></TBODY></TABLE></BODY></HTML><img src='http://ext.samsung.net/mailcheck/SeenTimeChecker?do=5b5b806e569672b0bc92d2761ed4130879e64b9460f8cf0c28f41a3773fe88f8a28a0f20ff0f747d3545973b7b0cb61b980b3871b38ac66662d74ed859d628c32758cd62c5cf0684a728c55b39cc59eacf878f9a26ce15a0' border=0 width=0 height=0 style='display:none'> |