Skip to content

Commit 1aa0bf4

Browse files
committed
Project layout and architecture changes
1 parent d6b558b commit 1aa0bf4

28 files changed

Lines changed: 868 additions & 2681 deletions

File tree

Cargo.lock

Lines changed: 42 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
[package]
2-
name = "CanOpenDataViewer"
3-
version = "0.1.0"
4-
edition = "2024"
1+
[workspace]
2+
resolver = "2"
3+
members = [
4+
"canopen-viewer",
5+
"canopen-common",
6+
"mock-canopen-node",
7+
]
58

6-
[dependencies]
7-
configparser = "3.1.0"
8-
eframe = "0.31.0"
9-
rfd = "0.15.4"
10-
egui_plot = "0.31.0"
11-
image = "0.25.1"
12-
chrono = "0.4.41"
9+
# Shared dependencies across workspace (optional but reduces duplication)
10+
[workspace.dependencies]
11+
socketcan = "3.5.0"
1312
tokio = { version = "1.47.1", features = ["full"] }
1413
rand = "0.9.2"
15-
socketcan = "3.5.0"
14+
serde = { version = "1.0", features = ["derive"] }
15+
16+
# This is now a workspace root, not a package
17+
# The actual binaries are in the member crates

README.md

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
# CANopen Real-time Monitor & Plotter
22

3+
A high-performance, real-time CANopen diagnostics tool written in Rust, featuring dynamic plotting and configurable SDO polling.
34

4-
A high-performance, real-time CANopen diagnostics tool written in Rust, featuring dynamic plotting, configurable SDO polling, and selective TPDO monitoring.
5+
## 📁 Project Structure
6+
7+
This is a Rust workspace containing multiple crates:
8+
9+
```
10+
CanOpenDataViewer/
11+
├── canopen-viewer/ # Main GUI application
12+
├── canopen-common/ # Shared CANopen protocol library
13+
├── mock-canopen-node/ # Mock CANopen node for testing
14+
└── examples/ # Example binaries and EDS files
15+
```
16+
17+
- **canopen-viewer**: The main application with GUI built using `egui`
18+
- **canopen-common**: Shared library for SDO protocol (used by both viewer and mock node)
19+
- **mock-canopen-node**: Simulated CANopen device for testing without real hardware
520

621

722
## Core Features
@@ -81,15 +96,37 @@ This ensures the user is always presented with information in its most useful fo
8196

8297
1. Clone the repository:
8398
```bash
84-
git clone [https://github.com/erdemsimsek/CanOpenDataViewer.git](https://github.com/erdemsimsek/CanOpenDataViewer.git)
99+
git clone https://github.com/erdemsimsek/CanOpenDataViewer.git
85100
cd CanOpenDataViewer
86101
```
87102

88-
2. Build and run the application:
103+
2. Build the workspace:
89104
```bash
90-
cargo run --release
105+
# Build everything
106+
cargo build --workspace --release
107+
108+
# Or build just the viewer
109+
cargo build -p canopen-viewer --release
91110
```
92111

112+
3. Run the mock node (for testing without hardware):
113+
```bash
114+
# Terminal 1: Start mock CANopen node
115+
cargo run -p mock-canopen-node --release -- --interface vcan0 --node-id 4
116+
```
117+
118+
4. Run the viewer:
119+
```bash
120+
# Terminal 2: Start the viewer application
121+
cargo run -p canopen-viewer --release
122+
```
123+
124+
Then in the GUI:
125+
- Select CAN interface: `vcan0`
126+
- Enter Node ID: `4`
127+
- Select EDS file (or skip for testing)
128+
- Click "Start" and subscribe to SDOs
129+
93130
## Roadmap
94131

95132
* []

canopen-common/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "canopen-common"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
socketcan = { workspace = true }
8+
tokio = { workspace = true }

canopen-common/src/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//! # CANopen Common Library
2+
//!
3+
//! Shared CANopen protocol implementation used by both the viewer application
4+
//! and the mock CANopen node for testing.
5+
//!
6+
//! This library provides:
7+
//! - SDO (Service Data Object) protocol encoding/decoding
8+
//! - Common data types and error handling
9+
//! - Frame parsing utilities
10+
11+
pub mod sdo;
12+
13+
// Re-export commonly used types for convenience
14+
pub use sdo::{
15+
SdoRequest, SdoResponse, SdoResponseData, SdoDataType, SdoError,
16+
create_sdo_request_frame, parse_sdo_response, parse_payload,
17+
get_abort_code_description, SdoCommand
18+
};

canopen-viewer/Cargo.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "canopen-viewer"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
# Use workspace dependencies
8+
socketcan = { workspace = true }
9+
tokio = { workspace = true }
10+
rand = { workspace = true }
11+
12+
# UI dependencies
13+
configparser = "3.1.0"
14+
eframe = "0.31.0"
15+
rfd = "0.15.4"
16+
egui_plot = "0.31.0"
17+
image = "0.25.1"
18+
chrono = "0.4.41"
19+
20+
# This will use the shared CANopen protocol code
21+
canopen-common = { path = "../canopen-common" }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use tokio::task::JoinHandle;
88
use std::error::Error;
99
use std::fmt;
1010

11-
use crate::canopen::sdo::{SdoRequest, SdoResponse, SdoError, create_sdo_request_frame, parse_sdo_response};
11+
use canopen_common::{SdoRequest, SdoResponse, SdoError, create_sdo_request_frame, parse_sdo_response};
1212

1313
#[derive(Debug)]
1414
pub enum CANopenError {

canopen-viewer/src/canopen/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Connection management is still local to the viewer
2+
pub mod connect;
3+
4+
// SDO protocol is now in the common library
5+
// Re-export from canopen-common for backwards compatibility
6+
pub use canopen_common::{
7+
SdoRequest, SdoResponse, SdoResponseData, SdoDataType, SdoError,
8+
create_sdo_request_frame, parse_sdo_response, parse_payload,
9+
get_abort_code_description, SdoCommand
10+
};
11+
12+
pub use connect::{CANopenConnection, CANopenNodeHandle, CANopenError};
13+

0 commit comments

Comments
 (0)