Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions examples/FlintIO/Can/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
54 changes: 54 additions & 0 deletions examples/FlintIO/Can/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
}
]
}
53 changes: 53 additions & 0 deletions examples/FlintIO/Can/src/Main.java
Original file line number Diff line number Diff line change
@@ -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
}
}
Binary file modified jdk/flint.io.jar
Binary file not shown.
Binary file modified jdk/flint.net.jar
Binary file not shown.
Binary file modified jdk/java.base.jar
Binary file not shown.