Skip to content

Commit a3c18bc

Browse files
committed
Test program: log output
1 parent ac83331 commit a3c18bc

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

java-does-usb/src/test/java/net/codecrete/usb/special/Continuous.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import net.codecrete.usb.UsbException;
66

77
import java.io.IOException;
8+
import java.time.LocalDateTime;
9+
import java.time.format.DateTimeFormatter;
810
import java.util.Random;
911

1012
public class Continuous {
@@ -30,7 +32,7 @@ public static void main(String[] args) throws IOException {
3032
@SuppressWarnings({"java:S2925", "BusyWait"})
3133
private static void sendData(UsbDevice device) {
3234
var random = new Random();
33-
var buffer = new byte[80];
35+
var buffer = new byte[40];
3436

3537
while (true) {
3638
random.nextBytes(buffer);
@@ -46,9 +48,11 @@ private static void sendData(UsbDevice device) {
4648
}
4749

4850
private static void readData(UsbDevice device) {
51+
var formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
4952
while (true) {
5053
try {
51-
device.transferIn(2);
54+
var packet = device.transferIn(2);
55+
System.out.printf("%s packet of %d bytes received\n", LocalDateTime.now().format(formatter), packet.length);
5256
} catch (UsbException e) {
5357
return;
5458
}

test-devices/loopback-stm32/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ The device can be put into suspend mode by the host. It will go into a low-power
5252

5353
A MacBook with macOS usually puts the device into suspend mode about 1 minuate after is has gone to sleep if it is not connected to a power supply. The device will wake up when the MacBook is woken up.
5454

55+
On Windows, the device is put to sleep immediately when the Windows computer is put to sleep.
56+
5557

5658
## Building the firmware
5759

0 commit comments

Comments
 (0)