Skip to content

Commit 4d1b4d2

Browse files
committed
Merge changes for Kotlin
2 parents fc4cee8 + 77d4f1b commit 4d1b4d2

File tree

97 files changed

+2801
-1080
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+2801
-1080
lines changed

.github/workflows/continuous-integration.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,15 @@ jobs:
4646
- name: Example "enumerate"
4747
run: ./mvnw $MAVEN_ARGS clean compile
4848
working-directory: ./examples/enumerate
49+
- name: Example "enumerate" (Kotlin)
50+
run: ./mvnw $MAVEN_ARGS clean compile
51+
working-directory: ./examples/enumerate_kotlin
4952
- name: Example "monitor"
5053
run: ./mvnw $MAVEN_ARGS clean compile
5154
working-directory: ./examples/monitor
55+
- name: Example "monitor" (Kotlin)
56+
run: ./mvnw $MAVEN_ARGS clean compile
57+
working-directory: ./examples/monitor_kotlin
5258
- name: Example "stm_dfu"
5359
run: ./mvnw $MAVEN_ARGS clean compile
5460
working-directory: ./examples/stm_dfu

examples/bulk_transfer/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<dependency>
2222
<groupId>net.codecrete.usb</groupId>
2323
<artifactId>java-does-usb</artifactId>
24-
<version>0.6.1</version>
24+
<version>0.7.0-SNAPSHOT</version>
2525
</dependency>
2626
</dependencies>
2727

examples/bulk_transfer/src/main/java/net/codecrete/usb/examples/BulkTransfer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class BulkTransfer {
2727
private static final int ENDPOINT_IN = 2;
2828

2929
public static void main(String[] args) {
30-
var optionalDevice = USB.getDevice(VID, PID);
30+
var optionalDevice = Usb.findDevice(VID, PID);
3131
if (optionalDevice.isEmpty()) {
3232
System.out.printf("No USB device with VID=0x%04x and PID=0x%04x found.%n", VID, PID);
3333
return;

examples/enumerate/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<dependency>
2222
<groupId>net.codecrete.usb</groupId>
2323
<artifactId>java-does-usb</artifactId>
24-
<version>0.6.1</version>
24+
<version>0.7.0-SNAPSHOT</version>
2525
</dependency>
2626
<dependency>
2727
<groupId>org.tinylog</groupId>

examples/enumerate/src/main/java/net/codecrete/usb/examples/Enumerate.java

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,32 @@ public class Enumerate {
1919

2020
public static void main(String[] args) {
2121
// display the already present USB devices
22-
for (var device : USB.getAllDevices())
22+
for (var device : Usb.getDevices())
2323
printDevice(device);
2424
}
2525

26-
private static void printDevice(USBDevice device) {
26+
private static void printDevice(UsbDevice device) {
2727
System.out.println("Device:");
28-
System.out.printf(" VID: 0x%04x%n", device.vendorId());
29-
System.out.printf(" PID: 0x%04x%n", device.productId());
30-
if (device.manufacturer() != null)
31-
System.out.printf(" Manufacturer: %s%n", device.manufacturer());
32-
if (device.product() != null)
33-
System.out.printf(" Product name: %s%n", device.product());
34-
if (device.serialNumber() != null)
35-
System.out.printf(" Serial number: %s%n", device.serialNumber());
36-
System.out.printf(" Device class: 0x%02x", device.classCode());
37-
printInParens(USBClassInfo.lookupClass(device.classCode()));
38-
System.out.printf(" Device subclass: 0x%02x", device.subclassCode());
39-
printInParens(USBClassInfo.lookupSubclass(device.classCode(), device.subclassCode()));
40-
System.out.printf(" Device protocol: 0x%02x", device.protocolCode());
41-
printInParens(USBClassInfo.lookupProtocol(device.classCode(), device.subclassCode(), device.protocolCode()));
42-
43-
for (var intf: device.interfaces())
28+
System.out.printf(" VID: 0x%04x%n", device.getVendorId());
29+
System.out.printf(" PID: 0x%04x%n", device.getProductId());
30+
if (device.getManufacturer() != null)
31+
System.out.printf(" Manufacturer: %s%n", device.getManufacturer());
32+
if (device.getProduct() != null)
33+
System.out.printf(" Product name: %s%n", device.getProduct());
34+
if (device.getSerialNumber() != null)
35+
System.out.printf(" Serial number: %s%n", device.getSerialNumber());
36+
System.out.printf(" Device class: 0x%02x", device.getClassCode());
37+
printInParens(USBClassInfo.lookupClass(device.getClassCode()));
38+
System.out.printf(" Device subclass: 0x%02x", device.getSubclassCode());
39+
printInParens(USBClassInfo.lookupSubclass(device.getClassCode(), device.getSubclassCode()));
40+
System.out.printf(" Device protocol: 0x%02x", device.getProtocolCode());
41+
printInParens(USBClassInfo.lookupProtocol(device.getClassCode(), device.getSubclassCode(), device.getProtocolCode()));
42+
43+
for (var intf: device.getInterfaces())
4444
printInterface(intf);
4545

46-
printRawDescriptor("Device descriptor", device.deviceDescriptor());
47-
printRawDescriptor("Configuration descriptor", device.configurationDescriptor());
46+
printRawDescriptor("Device descriptor", device.getDeviceDescriptor());
47+
printRawDescriptor("Configuration descriptor", device.getConfigurationDescriptor());
4848

4949
System.out.println();
5050
System.out.println();
@@ -59,36 +59,36 @@ private static void printInParens(Optional<String> text) {
5959
}
6060
}
6161

62-
private static void printInterface(USBInterface intf) {
63-
for (var alt : intf.alternates())
64-
printAlternate(alt, intf.number(), alt == intf.alternate());
62+
private static void printInterface(UsbInterface intf) {
63+
for (var alt : intf.getAlternates())
64+
printAlternate(alt, intf.getNumber(), alt == intf.getCurrentAlternate());
6565
}
6666

67-
private static void printAlternate(USBAlternateInterface alt, int intferaceNumber, boolean isDefault) {
67+
private static void printAlternate(UsbAlternateInterface alt, int intferaceNumber, boolean isDefault) {
6868
System.out.println();
6969
if (isDefault) {
7070
System.out.printf(" Interface %d%n", intferaceNumber);
7171
} else {
72-
System.out.printf(" Interface %d (alternate %d)%n", intferaceNumber, alt.number());
72+
System.out.printf(" Interface %d (alternate %d)%n", intferaceNumber, alt.getNumber());
7373
}
7474

75-
System.out.printf(" Interface class: 0x%02x", alt.classCode());
76-
printInParens(USBClassInfo.lookupClass(alt.classCode()));
77-
System.out.printf(" Interface subclass: 0x%02x", alt.subclassCode());
78-
printInParens(USBClassInfo.lookupProtocol(alt.classCode(), alt.subclassCode(), alt.protocolCode()));
79-
System.out.printf(" Interface protocol: 0x%02x", alt.protocolCode());
80-
printInParens(USBClassInfo.lookupProtocol(alt.classCode(), alt.subclassCode(), alt.protocolCode()));
75+
System.out.printf(" Interface class: 0x%02x", alt.getClassCode());
76+
printInParens(USBClassInfo.lookupClass(alt.getClassCode()));
77+
System.out.printf(" Interface subclass: 0x%02x", alt.getSubclassCode());
78+
printInParens(USBClassInfo.lookupProtocol(alt.getClassCode(), alt.getSubclassCode(), alt.getProtocolCode()));
79+
System.out.printf(" Interface protocol: 0x%02x", alt.getProtocolCode());
80+
printInParens(USBClassInfo.lookupProtocol(alt.getClassCode(), alt.getSubclassCode(), alt.getProtocolCode()));
8181

82-
for (var endpoint : alt.endpoints())
82+
for (var endpoint : alt.getEndpoints())
8383
printEndpoint(endpoint);
8484
}
8585

86-
private static void printEndpoint(USBEndpoint endpoint) {
86+
private static void printEndpoint(UsbEndpoint endpoint) {
8787
System.out.println();
88-
System.out.printf(" Endpoint %d%n", endpoint.number());
89-
System.out.printf(" Direction: %s%n", endpoint.direction().name());
90-
System.out.printf(" Transfer type: %s%n", endpoint.transferType().name());
91-
System.out.printf(" Packet size: %d bytes%n", endpoint.packetSize());
88+
System.out.printf(" Endpoint %d%n", endpoint.getNumber());
89+
System.out.printf(" Direction: %s%n", endpoint.getDirection().name());
90+
System.out.printf(" Transfer type: %s%n", endpoint.getTransferType().name());
91+
System.out.printf(" Packet size: %d bytes%n", endpoint.getPacketSize());
9292
}
9393

9494
private static void printRawDescriptor(String title, byte[] descriptor) {
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
target/
2+
!.mvn/wrapper/maven-wrapper.jar
3+
!**/src/main/**/target/
4+
!**/src/test/**/target/
5+
6+
### IntelliJ IDEA ###
7+
.idea/modules.xml
8+
.idea/jarRepositories.xml
9+
.idea/compiler.xml
10+
.idea/libraries/
11+
*.iws
12+
*.iml
13+
*.ipr
14+
15+
### Eclipse ###
16+
.apt_generated
17+
.classpath
18+
.factorypath
19+
.project
20+
.settings
21+
.springBeans
22+
.sts4-cache
23+
24+
### NetBeans ###
25+
/nbproject/private/
26+
/nbbuild/
27+
/dist/
28+
/nbdist/
29+
/.nb-gradle/
30+
build/
31+
!**/src/main/**/build/
32+
!**/src/test/**/build/
33+
34+
### VS Code ###
35+
.vscode/
36+
37+
### Mac OS ###
38+
.DS_Store
61.1 KB
Binary file not shown.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
18+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar

0 commit comments

Comments
 (0)