|
41 | 41 | */ |
42 | 42 | public class UsbDevice { |
43 | 43 |
|
44 | | - private final UsbManager manager; |
| 44 | + public final UsbManager manager; |
45 | 45 | final @NotNull String name; |
46 | 46 | final @Nullable String manufacturerName; |
47 | 47 | final @Nullable String productName; |
@@ -717,8 +717,9 @@ public int controlTransfer(int requestType, int request, int value, int index, b |
717 | 717 | public int controlTransfer(int requestType, int request, int value, int index, byte[] buffer, int offset, |
718 | 718 | int length, int timeout) { |
719 | 719 | checkBounds(buffer, offset, length); |
720 | | - return nativeControlRequest(getNativeObject(), requestType, request, value, index, buffer, offset, |
721 | | - length, timeout); |
| 720 | + // TODO: safely reimplement blocking transfer based on async transfer, in a real-time safe |
| 721 | + // way. most likely blocking on condition variable in native and setting it from callback. |
| 722 | + throw new UnsupportedOperationException(); |
722 | 723 | } |
723 | 724 |
|
724 | 725 | /** |
@@ -755,7 +756,9 @@ public int bulkTransfer(UsbEndpoint endpoint, byte[] buffer, int length, int tim |
755 | 756 | */ |
756 | 757 | public int bulkTransfer(UsbEndpoint endpoint, byte[] buffer, int offset, int length, int timeout) { |
757 | 758 | checkBounds(buffer, offset, length); |
758 | | - return nativeBulkRequest(getNativeObject(), endpoint.getAddress(), buffer, offset, length, timeout); |
| 759 | + // TODO: safely reimplement blocking transfer based on async transfer, in a real-time safe |
| 760 | + // way. most likely blocking on condition variable in native and setting it from callback. |
| 761 | + throw new UnsupportedOperationException(); |
759 | 762 | } |
760 | 763 |
|
761 | 764 | /** |
@@ -792,7 +795,9 @@ public int interruptTransfer(UsbEndpoint endpoint, byte[] buffer, int length, in |
792 | 795 | */ |
793 | 796 | public int interruptTransfer(UsbEndpoint endpoint, byte[] buffer, int offset, int length, int timeout) { |
794 | 797 | checkBounds(buffer, offset, length); |
795 | | - return nativeInterruptRequest(getNativeObject(), endpoint.getAddress(), buffer, offset, length, timeout); |
| 798 | + // TODO: safely reimplement blocking transfer based on async transfer, in a real-time safe |
| 799 | + // way. most likely blocking on condition variable in native and setting it from callback. |
| 800 | + throw new UnsupportedOperationException(); |
796 | 801 | } |
797 | 802 |
|
798 | 803 | /** |
@@ -822,6 +827,9 @@ public LibusbError asyncTransfer(@NotNull AsyncTransfer transfer) { |
822 | 827 | throw new IllegalArgumentException("Transfer callback should be set"); |
823 | 828 | } |
824 | 829 | @NonNull ByteBuffer buffer = transfer.getBuffer(); |
| 830 | + manager.onTransferAdded(transfer.getNativeObject()); |
| 831 | + // TODO: add dispatch to handler in real-time-safe way (if no dispatch and not blocking, it |
| 832 | + // may use real-time-unsafe in place callback) |
825 | 833 | return LibusbError.fromNative(nativeRequestAsync(getNativeObject(), transfer, |
826 | 834 | buffer, buffer.position(), buffer.remaining())); |
827 | 835 | } |
@@ -872,20 +880,11 @@ private static void checkBounds(byte[] buffer, int start, int length) { |
872 | 880 |
|
873 | 881 | private native int nativeSetConfiguration(long device, int configurationID); |
874 | 882 |
|
875 | | - private native int nativeControlRequest(long device, int requestType, int request, int value, |
876 | | - int index, byte[] buffer, int offset, int length, int timeout); |
877 | | - |
878 | 883 | private native int nativeRequestAsync(long device, @NotNull AsyncTransfer transfer, |
879 | 884 | @NotNull ByteBuffer buffer, int offset, int length); |
880 | 885 |
|
881 | 886 | private native int nativeCancelAsync(long transfer); |
882 | 887 |
|
883 | | - private native int nativeBulkRequest(long device, int endpoint, byte[] buffer, int offset, |
884 | | - int length, int timeout); |
885 | | - |
886 | | - private native int nativeInterruptRequest(long device, int endpoint, byte[] buffer, int offset, |
887 | | - int length, int timeout); |
888 | | - |
889 | 888 | private native int nativeResetDevice(long device); |
890 | 889 |
|
891 | 890 | } |
0 commit comments