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 from Java. 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.
8
-
9
-
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 tested with Java 19 Early Access (with preview features enabled).
10
-
11
-
12
-
## Prerequisite
13
-
14
-
- Java 19, preview features enabled (available at https://www.azul.com/downloads/?package=jdk)
15
-
- Windows (x86 64-bit), macOS (x86 64-bit, ARM 64-bit) or Linux 64 bit (x86 64-bit, ARM 64-bit)
16
-
17
-
It has been tested with Azul Zulu 19.0.77 EA 34.
5
+
*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.)
18
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 tested with Java 19 (with preview features enabled).
19
8
20
9
21
10
## Features
22
11
23
-
### Implemented
24
-
25
12
- Single API for all operating systems (similar to WebUSB API)
26
13
- Enumeration of USB devices
27
14
- Control, bulk and interrupt transfers (optionally with timeout)
@@ -30,7 +17,7 @@ It has been tested with Azul Zulu 19.0.77 EA 34.
30
17
- Support for alternate interface settings, composite devices and interface association
31
18
- Published on Maven Central
32
19
33
-
### To do
20
+
### Planned
34
21
35
22
- Isochronous transfer
36
23
@@ -41,29 +28,84 @@ It has been tested with Azul Zulu 19.0.77 EA 34.
41
28
- Providing information about USB buses, controllers and hubs
42
29
43
30
44
-
## Platform-specific considerations
31
+
## Getting Started
32
+
33
+
The library is available at Maven Central. To use it, just add it to your Maven or Gradle project.
34
+
35
+
If you are using Maven, add the below dependency to your pom.xml:
36
+
37
+
```xml
38
+
<dependency>
39
+
<groupId>net.codecrete.usb</groupId>
40
+
<artifactId>java-does-usb</artifactId>
41
+
<version>0.4.0</version>
42
+
</dependency>
43
+
```
44
+
45
+
If you are using Gradle, add the below dependency to your build.gradle file:
-[Bulk Transfer](examples/bulk_transfer/) demonstrates how to find a USB device, open it and communicate using bulk transfer.
75
+
-[Enumeration](examples/enumerate/) lists all connected USB devices and displays information about interfaces and endpoints.
76
+
-[Monitor](examples/monitor/) lists the connected USB devices and then monitors for USB devices being connected and disconnnected.
77
+
78
+
79
+
## Prerequisite
80
+
81
+
- Java 19, preview features enabled (available at https://www.azul.com/downloads/?package=jdk)
82
+
- Windows (x86 64-bit), macOS (x86 64-bit, ARM 64-bit) or Linux 64 bit (x86 64-bit, ARM 64-bit)
83
+
84
+
85
+
86
+
## Platform-specific Considerations
45
87
46
88
47
89
### macOS
48
90
49
-
No special considerations apply. Using this library, a Java application can connect to any USB device and claim any interfaces that aren't claimed by an operating system driver or another application.
91
+
No special considerations apply. Using this library, a Java application can connect to any USB device and claim any interfaces that isn't claimed by an operating system driver or another application.
50
92
51
93
52
94
### Linux
53
95
54
96
*libudev* is used to discover and monitor USB devices. It is closely tied to *systemd*. So the library only runs on Linux distributions with *systemd* and the related libraries. The majority of Linux distributions suitable for desktop computing (as opposed to distributions optimized for containers) fulfill this requirement.
55
97
56
-
Similar to macOS, a Java application can connect to any USB device and claim any interfaces that aren't claimed by an operating system driver or another application.
98
+
Similar to macOS, a Java application can connect to any USB device and claim any interfaces that isn't claimed by an operating system driver or another application.
57
99
58
-
Most Linux distributions by default set up user accounts without the permission to access USB devices directly. The *udev* system daemon is responsible for assigning permissions to USB devices. It can be configured to assign specific permissions or ownership.
100
+
Most Linux distributions by default set up user accounts without the permission to access USB devices directly. The *udev* system daemon is responsible for assigning permissions to USB devices. It can be configured to assign specific permissions or ownership:
59
101
60
102
Create a file called `/etc/udev/rules.d/80-javadoesusb-udev.rules` with the below content:
0 commit comments