diff --git a/README.md b/README.md new file mode 100644 index 0000000..94def7c --- /dev/null +++ b/README.md @@ -0,0 +1,61 @@ +# Sick Encoder CAN Monitor + +Ứng dụng giám sát encoder Sick qua giao tiếp CAN (PCAN-USB), hiển thị vị trí thời gian thực, trạng thái node, heartbeat, PDO, và hỗ trợ thay đổi bitrate / node ID runtime. + +## 🎯 Mục tiêu chính +- Đọc và hiển thị vị trí encoder Sick (mm) từ PDO TPDO1 theo thời gian thực +- Giám sát trạng thái node (Bootup, Pre-Operational, Operational, Stopped, Timeout) +- Hỗ trợ thay đổi **bitrate** và **Node ID** runtime (bao gồm unlock + save to EEPROM) +- Giao diện web đơn giản, responsive bằng **Blazor** + +## 🏗️ Kiến trúc + ┌─────────────────────┐ + │ Blazor Web App │ (UI: Start/Stop, Bitrate, NodeID, Table frames) + └──────────┬──────────┘ + │ + ▼ + ┌─────────────────────┐ + │ PcanCanService │ (.NET service xử lý PCAN-Basic) + │ - Init/Uninit │ + │ - Read loop │ + │ - NMT commands │ + │ - Apply bitrate │ + │ - Apply node ID │ + └──────────┬──────────┘ + │ + ▼ + ┌─────────────┐ + │ Sick Encoder│ CAN (PCAN-USB) + └─────────────┘ + +## 🚀 Công nghệ sử dụng +- **Backend**: .NET 10 (LTS) +- **Frontend**: Blazor Web App (Server hoặc WebAssembly tùy chọn) +- **CAN Driver**: Peak PCAN-Basic (PCAN-USB) +- **Dependency Injection**: Microsoft.Extensions.Options +- **OS hỗ trợ**: Windows (PC phát triển), có thể port sang Linux (mono hoặc .NET runtime) + +## 📂 Cấu trúc thư mục (hiện tại) + SickBlazorApp/ + ├── SickBlazorApp/ # Project Blazor chính + │ ├── Components/ # (nếu có reusable components) + │ ├── Models/ # PositionPdo, CanFrame, CanNodeState, ... + │ ├── Options/ # CanBusOptions + │ ├── Services/ # PcanCanService + interface + │ ├── Pages/ # sick.razor (trang chính) + │ └── Program.cs + ├── docs/ # Tài liệu + └── README.md + +## 🚦 Trạng thái hiện tại +- Đã hoàn thành: + - Kết nối PCAN-USB + đọc CAN frame liên tục + - Parse heartbeat (node state + auto resume) + - Xử lý Position PDO (raw → mm) + - Thay đổi bitrate runtime (unlock + save EEPROM + reset) + - Thay đổi Node ID runtime (unlock + save + reset) + - UI Blazor hiển thị bảng frame, trạng thái node, vị trí mm +- Đang phát triển: + - Cải thiện UI/UX (loading state, error message, reconnect) + - Thêm logging chi tiết + - Hỗ trợ nhiều channel PCAN (nếu cần) \ No newline at end of file diff --git a/SickEncoderDocument.pdf b/SickEncoderDocument.pdf new file mode 100644 index 0000000..0d93888 Binary files /dev/null and b/SickEncoderDocument.pdf differ