You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*Java Does USB* is a library for working with USB devices. It allows to query information about all conntected USB devices and to communicate with USB devices using custom / vendor specific protocols. (It is not intended for communication with standard types of USB devices such as mass storage devices, keyboards etc.)
5
+
*Java Does USB* is a Java library for working with USB devices. It allows to query information about all conntected USB devices and to communicate with USB devices using custom / vendor specific protocols. (It is not intended for communication with standard types of USB devices such as mass storage devices, keyboards etc.)
6
+
7
+
The library uses the [Foreign Function & Memory API](https://github.com/openjdk/panama-foreign) to access native APIs of the underlying operating system. It only uses Java code and does not need JNI or any native third-party library. The *Foreign Function & Memory API* (aka as project Panama) is in preview and will be introduced in a future Java version. Currently, it can be used with Java 19 or Java 20 (with preview features enabled).
8
8
9
-
The library uses the [Foreign Function & Memory API](https://github.com/openjdk/panama-foreign) to access native APIs of the underlying operating system. It only uses Java code and does not need JNI or any native third-party library. The *Foreign Function & Memory API* (aka as project Panama) is in preview and will be introduced in a future Java version. Currently, it can be used with Java 19 (with preview features enabled).
9
+
*Note: The main branch and published versions ≥ 0.5.0 work with JDK 20 only. For JDK 19, use version 0.4.x.*
10
10
11
11
12
12
## Features
@@ -16,12 +16,12 @@ The library uses the [Foreign Function & Memory API](https://github.com/openjdk/
16
16
- Control, bulk and interrupt transfers (optionally with timeout)
17
17
- Notifications about connected/disconnected devices
18
18
- Descriptive information about interfaces, settings and endpoints
19
+
- High-throughput input/output streams
19
20
- Support for alternate interface settings, composite devices and interface association
20
21
- Published on Maven Central
21
22
22
23
### Planned
23
24
24
-
- High-throughput input/output streams
25
25
- Isochronous transfer
26
26
27
27
### Not planned
@@ -41,7 +41,7 @@ If you are using Maven, add the below dependency to your pom.xml:
41
41
<dependency>
42
42
<groupId>net.codecrete.usb</groupId>
43
43
<artifactId>java-does-usb</artifactId>
44
-
<version>0.4.1</version>
44
+
<version>0.5.0</version>
45
45
</dependency>
46
46
```
47
47
@@ -85,7 +85,7 @@ public class EnumerateDevices {
85
85
- Java 20, preview features enabled (available at https://www.azul.com/downloads/?package=jdk)
86
86
- Windows (x86 64-bit), macOS (x86 64-bit, ARM 64-bit) or Linux 64 bit (x86 64-bit, ARM 64-bit)
87
87
88
-
For a version compatible with JDK 20, see the branch `jdk20`.
88
+
For JDK 19, use the latest published version 0.4.x.
89
89
90
90
91
91
## Platform-specific Considerations
@@ -126,7 +126,7 @@ The library has not been tested on Windows for ARM64. It might or might not work
126
126
127
127
### 32-bit versions
128
128
129
-
The Foreign Function & Memory API has not been implemented for 32-bit operating systems / JDKs. So it does not support them (and likely never will).
129
+
The Foreign Function & Memory API has not been implemented for 32-bit operating systems / JDKs(and likely never will be).
Copy file name to clipboardExpand all lines: java-does-usb/jextract/README.md
+8-2Lines changed: 8 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,11 @@ The resulting code is then committed to the source code repository. Before the c
13
13
14
14
## General limitations
15
15
16
-
- Binaries of *jextract* can be downloaded from https://jdk.java.net/jextract/. x64 binaries are available but no ARM64 binaries. According to the mailing list, cross-compiling is not possible, i.e. ARM64 binaries are needed on macOS with Apple Silicon. But so far, the x64 binaries (using the Rosetta2 emulation) have worked without problems.
16
+
- The binaries for *jextract* on https://jdk.java.net/jextract/ have not been updated for JDK 20. So it must be built from source. Instructions can be found at [Building & Testing](https://github.com/openjdk/jextract#building--testing).
17
+
18
+
- According to the jextract mailing list, it would be required to create separate code form Intel x64 and ARM64 architecture. And jextract would need to be run on each architecture separately (no cross-compilation). Fortunately, this doesn't seem to be the case. Linux code generated on Intel x64 also runs on ARM64 without change. The same holds for macOS. However, jextract needs to be run on each operating system separately.
19
+
20
+
- JDK 20 introduced a new feature for saving the thread-specific error values (`GetLastError()` on Windows, `errno` on Linux). To use it, an additional parameter must be added to function calls. Unfortuntely, this is not yet supported by jextract. So with the JDK 20 updates, more code is written manually and less is generated by jextract.
Most of the required native functions on macOS are part of a framework. Framework internally have a more complex file organization of header and binary files than appears on the outside. Thus they require a special logic to locate framework header files. *clang* supports it with the `-F`. *jextract* allows to specify the options via `compiler_flags.txt` file. Since the file must be in the local directory and since it does not apply to Linux and Windows, separate directories must be used for the operating systems.
71
+
Most of the required native functions on macOS are part of a framework. Frameworks internally have a more complex file organization of header and binary files than appears from the outside. Thus they require a special logic to locate framework header files. *clang* supports it with the `-F`. *jextract* allows to specify the options via `compiler_flags.txt` file. Since the file must be in the local directory and since it does not apply to Linux and Windows, separate directories must be used for the operating systems.
68
72
69
73
The generated code has the same problem as the Linux code for *udev*. It must be manually changed to use `SymbolLookup.libraryLookup()` for the libraries `CoreFoundation.framework/CoreFoundation` and `IOKit.framework/IOKit` respectively.
70
74
@@ -73,6 +77,8 @@ The generated code has the same problem as the Linux code for *udev*. It must be
73
77
74
78
Most Windows SDK header files are not independent. They require that `Windows.h` is included first. So instead of specifying the target header files directly, a helper header file (`windows_headers.h` in this directory) is specified.
75
79
80
+
Compared to Linux and macOS, the code generation on Windows is very slow (about 1 min vs 3 seconds). And jextract crashes sometimes.
81
+
76
82
The known limitations are:
77
83
78
84
- Variable size `struct`: Several Windows struct are of variable size. The last member is an array. The `struct` definition specifies array length 1. But you are expected to allocate more space depending on the actual array size you need. *jextract* generates code for array length 1 and when access array members, the length is checked. So the generated code is difficult to use. Variable size `struct`s are a pain - in any language.
0 commit comments