diff --git a/examples/FlintIO/Can/.vscode/launch.json b/examples/FlintIO/Can/.vscode/launch.json new file mode 100644 index 0000000..f2cb159 --- /dev/null +++ b/examples/FlintIO/Can/.vscode/launch.json @@ -0,0 +1,21 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "type": "flint-debug", + "request": "launch", + "name": "Debug with FlintJVM", + "cwd": "${workspaceFolder}", + "port": "COM5", + "install": true, + "mainClass": "Main", + "classPath": "bin", + "sourcePath": "src", + "modulePath": [ + "../../../jdk/flint.io.jar", + "../../../jdk/java.base.jar" + ], + "preLaunchTask": "build" + } + ] +} diff --git a/examples/FlintIO/Can/.vscode/tasks.json b/examples/FlintIO/Can/.vscode/tasks.json new file mode 100644 index 0000000..42ea62c --- /dev/null +++ b/examples/FlintIO/Can/.vscode/tasks.json @@ -0,0 +1,54 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "type": "shell", + "command": "javac", + "osx": {"args": [ + "-g", + "--module-path=\"../../../jdk/java.base.jar:../../../jdk/flint.io.jar\"", + "--add-modules=flint.io", "-XDstringConcat=inline", + "--system=none", "-d", "bin", "src/*.java" + ]}, + "linux": {"args": [ + "-g", + "--module-path=\"../../../jdk/java.base.jar:../../../jdk/flint.io.jar\"", + "--add-modules=flint.io", "-XDstringConcat=inline", + "--system=none", "-d", "bin", "src/*.java" + ]}, + "windows": {"args": [ + "-g", + "--module-path=\"../../../jdk/java.base.jar;../../../jdk/flint.io.jar\"", + "--add-modules=flint.io", "-XDstringConcat=inline", + "--system=none", "-d", "bin", "src/*.java" + ]}, + "presentation": { + "echo": false, + "reveal": "always", + "showReuseMessage": false, + "clear": true + }, + "options": { + "cwd": "${workspaceFolder}", + }, + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": { + "owner": "java", + "fileLocation": ["relative", "${workspaceFolder}"], + "pattern": [ + { + "regexp": "^(.*\\.java):(\\d+):\\s(error|warning):\\s(.*)$", + "file": 1, + "line": 2, + "severity": 3, + "message": 4 + } + ] + } + } + ] +} \ No newline at end of file diff --git a/examples/FlintIO/Can/src/Main.java b/examples/FlintIO/Can/src/Main.java new file mode 100644 index 0000000..602a5a5 --- /dev/null +++ b/examples/FlintIO/Can/src/Main.java @@ -0,0 +1,53 @@ +import flint.machine.Can; +import flint.machine.CanMessage; +import flint.machine.CanStatus; +import flint.machine.Can.CanMode; // Thêm import này + +import java.util.Arrays; +import java.io.IOException; + +public class Main { + public static void main(String[] args) throws Exception { + // CAN0 – main bus + Can can0 = new Can("CAN0", 0, 500_000) + .setTxPin(21) + .setRxPin(22) + .setMode(CanMode.NORMAL); + + // CAN1 – sniffer / debug + Can can1 = new Can("CAN1", 1, 250_000) + .setTxPin(25) + .setRxPin(26) + .setMode(CanMode.LISTEN_ONLY); + + can0.open(); + // can1.open(); // Not supported on some platforms + + can0.start(); + // can1.start(); // Not supported on some platforms + + // Send + can0.writeMessage( + CanMessage.of(0x123, new byte[]{0x11,0x22}), + 1000 + ); + + // Receive on sniffer + CanMessage rx = can1.receiveMessage(1000); + if (rx != null) { + System.out.println("Sniffed: " + rx); + } + + // Check status + CanStatus status = can0.getStatus(); + if (status != null) { + System.out.println("Status: " + status); + } + + can0.stop(); + // can1.stop(); // Not supported on some platforms + + can0.close(); + // can1.close(); // Not supported on some platforms + } +} \ No newline at end of file diff --git a/jdk/flint.io.jar b/jdk/flint.io.jar index 2587844..1f89d19 100644 Binary files a/jdk/flint.io.jar and b/jdk/flint.io.jar differ diff --git a/jdk/flint.net.jar b/jdk/flint.net.jar index 113e2ca..ad4cba4 100644 Binary files a/jdk/flint.net.jar and b/jdk/flint.net.jar differ diff --git a/jdk/java.base.jar b/jdk/java.base.jar index 76014e9..5121b54 100644 Binary files a/jdk/java.base.jar and b/jdk/java.base.jar differ