It sounds like the device is sending you a 0-length packet.  It could
be part of its protocol.  Maybe you should try a second buffer?

Also, you're sending that on an input-direction pipe, do you realize
that?  You seem to be trying to send a command out to the device,
since you're formatting the data.  The data will just be overwritten
though.

For input-direction pipes you should just have a dedicated Thread to
manage the input or use multiple UsbIrps asynchronously and re-submit
the UsbIrp (or a new one) in a UsbPipeListener.

On 10/26/06, David A Scott <[EMAIL PROTECTED]> wrote:
> Hi, all. Could somebody help me out here? I'm pulling my hair out on
> this one...
>
> After finding my device, claiming the interface, grabbing an endpoint, and
> opening a pipe, I try to send 30 bytes down the pipe (see JUnit test below).
>
> The output says:
>
>   device = PowerShot G2
>   Sending 30 bytes
>   return code (expected=30,actual=0)
>
> I expect to see 30 bytes transferred, but I see 0.
>
> There are no exceptions thrown. For grins, I tried the other two endpoints,
> but they both block forever.
>
> My real question is: Why would I get a "successful" completion (no
> exceptions)
> but get zero bytes transferred? Am I doing something wrong here?
>
> Thanks,
>
> --dave;
>
> ===========================================================
>
> import java.util.ArrayList;
> import java.util.Collections;
> import java.util.Iterator;
> import java.util.List;
>
> import javax.usb.UsbConfiguration;
> import javax.usb.UsbDevice;
> import javax.usb.UsbEndpoint;
> import javax.usb.UsbHostManager;
> import javax.usb.UsbHub;
> import javax.usb.UsbInterface;
> import javax.usb.UsbPipe;
>
> import junit.framework.TestCase;
>
> public class SendToUsbDeviceTest extends TestCase {
>
>     UsbDevice device;
>
>     public void testSend() throws Exception {
>         List<UsbDevice> devices =
> findAddressableDevices(UsbHostManager.getUsbServices().getRootUsbHub());
>
>         Iterator it = devices.iterator();
>         while (it.hasNext()) {
>             // find my camera
>             if ((device =
> (UsbDevice)it.next()).getProductString().contains("G2"))
>                 break;
>         }
>         System.out.println("device = " + device.getProductString());
>
>         UsbConfiguration config = device.getActiveUsbConfiguration();
>         UsbInterface intf = config.getUsbInterface((byte)0);
>         intf.claim();
>         UsbEndpoint endp = intf.getUsbEndpoint((byte)0x83);
>         UsbPipe pipe = endp.getUsbPipe();
>         pipe.open();
>
>         byte[] data = new byte[] {
>                 (byte) 0x10, (byte) 0x01, (byte) 0x00, (byte) 0x00,
> (byte) 0x00, (byte) 0x00,
>                 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
> (byte) 0x00, (byte) 0x00,
>                 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
> (byte) 0x00, (byte) 0x00,
>                 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
> (byte) 0x00, (byte) 0x00,
>                 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
> (byte) 0x00, (byte) 0x00 };
>
>         System.out.println("Sending 30 bytes");
>         int returnCode = pipe.syncSubmit(data);
>         System.out.println("return code (expected=30,actual=" +
> returnCode + ")");
>         assertEquals("check return code from syncSubmit", 30, returnCode);
>     }
>
>     public List<UsbDevice> findAddressableDevices(UsbDevice parent) {
>         List<UsbDevice> devices = new ArrayList<UsbDevice>();
>         if (parent.isUsbHub()) {
>             List children = ((UsbHub) parent).getAttachedUsbDevices();
>             Iterator it = children.iterator();
>             while (it.hasNext()) {
>                 UsbDevice child = (UsbDevice) it.next();
>                 List<UsbDevice> childsDevices =
> findAddressableDevices(child);
>                 Iterator childIterator = childsDevices.iterator();
>                 while (childIterator.hasNext()) {
>                     UsbDevice d = (UsbDevice) childIterator.next();
>                     if (!d.isUsbHub())
>                         devices.add(d);
>                 }
>             }
>         } else {
>             devices.add(parent);
>         }
>         return Collections.unmodifiableList(devices);
>     }
> }
>
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> javax-usb-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
>

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
javax-usb-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/javax-usb-devel

Reply via email to