Usb4Java Isochronous Transfer

24 views
Skip to first unread message

Peter Stoiber

unread,
Nov 11, 2018, 11:08:06 AM11/11/18
to usb4java
Hello,

I'm trying to get an Isotransfer to work with Usb4Java.

With Claimed Interface and setted Interface AltSetting i'm executing following code:


public void usb4javaIsotransfer()  {
   
   
    submitCallback = new TransferCallback(){
           
            @Override
            public void processTransfer(Transfer transfer){
                System.out.println(transfer.actualLength() + " bytes sent");
                submitUsb4Java( submitCallback);
                LibUsb.freeTransfer(transfer);
        }

        };
   // camDeviceConnection.setConfiguration(dhandle, bConfigurationValue);
    camDeviceConnection.setInterfaceAltSetting(dhandle, camStreamingInterfaceNum, camStreamingAltSetting);
   
      
       
        submitUsb4Java(submitCallback);
       
}

public void submitUsb4Java(TransferCallback callback){
   
   
            ByteBuffer buffer = BufferUtils.allocateByteBuffer(maxPacketSize);
           
            Transfer transfer = camDeviceConnection.allocTransfer(packetsPerRequest);
           
            System.out.println("LibUSB API Level: " +camDeviceConnection.getApiVersion());
           
          //  transfer.setLength(maxPacketSize);
            camDeviceConnection.fillIsoTransfer(transfer, dhandle, (byte) ep_addr, buffer, packetsPerRequest, callback, null, 1000);
            camDeviceConnection.setIsoPacketLengths(transfer, maxPacketSize);
           
            int result = camDeviceConnection.submitTransfer(transfer);
            if (result != LibUsb.SUCCESS) throw new LibUsbException("Konnte den Isotransfer nicht durchführen: ", result);
            else { 
            System.out.println("Übertragung erfolgreich gestartet: "+ result + "  -----  " + transfer.actualLength() + " bytes sent");
          
            byte [] userdata = new byte [maxPacketSize];
            ByteBuffer buf = ByteBuffer.allocateDirect( maxPacketSize);
            buf = transfer.buffer();
           
           
            userdata = new byte[buf.remaining()];
            buf.get(userdata);
            System.out.println("Der VideoBuffer hat folgenden Wert: " + Arrays.toString(userdata));
            }
           
}

So far everything is working and the result of "submitTransfer(transfer)" is 0.
But the Callback function is not called, when I submit the Transfer and the Bytebuffer of the Transfer is also empty.


And here is the Log:

run:
Bibliothek wird geladen
USB devices count = 5
Bus 002, Device 001:Bus 001, Device 004:Bus 001, Device 003:Der Dateiname lautet: /dev/bus/usb/001/003
Kamera = FoxLink
Der Kameratyp = foxlink - wurde gewählt
 
LIST DEVICE
 
Es wurden   2   Interfaces gezählt.

[ -Interface 1 - ] [: id=1 ] [ class=14 ] [ subclass=2 ] [ protocol=0 ]

[- Altsetting: 0] [: Endpunktadresse = 0x83] [Length= 7] [ attrs= 3] [ interval = 6] [ maxPacketSize = 16 ] [ type = 5]

[ -Interface 2 - ] [: id=0 ] [ class=14 ] [ subclass=1 ] [ protocol=0 ]

[- Altsetting: 1] [: Endpunktadresse = 0x81] [Length= 7] [ attrs= 5] [ interval = 1] [ maxPacketSize = 128 ] [ type = 5]
[- Altsetting: 2] [: Endpunktadresse = 0x81] [Length= 7] [ attrs= 5] [ interval = 1] [ maxPacketSize = 512 ] [ type = 5]
[- Altsetting: 3] [: Endpunktadresse = 0x81] [Length= 7] [ attrs= 5] [ interval = 1] [ maxPacketSize = 1024 ] [ type = 5]
[- Altsetting: 4] [: Endpunktadresse = 0x81] [Length= 7] [ attrs= 5] [ interval = 1] [ maxPacketSize = 2816 ] [ type = 5]
[- Altsetting: 5] [: Endpunktadresse = 0x81] [Length= 7] [ attrs= 5] [ interval = 1] [ maxPacketSize = 3072 ] [ type = 5]
[- Altsetting: 6] [: Endpunktadresse = 0x81] [Length= 7] [ attrs= 5] [ interval = 1] [ maxPacketSize = 4992 ] [ type = 5]
[- Altsetting: 7] [: Endpunktadresse = 0x81] [Length= 7] [ attrs= 5] [ interval = 1] [ maxPacketSize = 5120 ] [ type = 5]
Endpointadresse gesetzt: 0x81
 
OPEN CAM
 
camControlInterfaceNum = 0
camStreamingInterfaceNum = 1
Kontrollinterface erfolgreich eingehängt. Rückmelung = 0
Streaminterface erfolgreich eingehängt. Rückmelung = 0
 
Zu initialisierende Videoflussparameter: hint=0x0 format=1 frame=1 frameInterval=333333 keyFrameRate=0 pFrameRate=0 compQuality=0 compWindowSize=0 delay=0 maxVideoFrameSize=0 maxPayloadTransferSize=0
Camera initialization success, len=26.
Sondierte Videoflussparameter: hint=0x0 format=1 frame=1 frameInterval=333333 keyFrameRate=0 pFrameRate=0 compQuality=0 compWindowSize=0 delay=32 maxVideoFrameSize=512000 maxPayloadTransferSize=3072
Abschließende Videoflussparameter: hint=0x0 format=1 frame=1 frameInterval=333333 keyFrameRate=0 pFrameRate=0 compQuality=0 compWindowSize=0 delay=32 maxVideoFrameSize=512000 maxPayloadTransferSize=3072
 
LibUSB API Level: 16777474
Übertragung erfolgreich gestartet: 0  -----  0 bytes sent
Der VideoBuffer hat folgenden Wert: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,, ........ ]
BUILD SUCCESSFUL (total time: 9 seconds)


Perhaps someone could help me out.

Thanks,

Peter
Reply all
Reply to author
Forward
0 new messages