-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Got Rust autogeneration working with Rust prebuild hook! (#33)
* Got Rust autogeneration working with Rust prebuild hook! * Adding in git admin for adding in autogen * Adding in a more verbose failure for autogen * Add automatic reconnect --------- Co-authored-by: Peyton-McKee <[email protected]>
- Loading branch information
Showing
23 changed files
with
70 additions
and
973 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,5 @@ __pycache__/ | |
build/ | ||
dist/ | ||
logs/ | ||
master_mapping.rs | ||
decode_data.rs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "Embedded-Base"] | ||
path = Embedded-Base | ||
url = [email protected]:Northeastern-Electric-Racing/Embedded-Base.git |
Submodule Embedded-Base
added at
0c828d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use std::process::Command; | ||
|
||
/* Prebuild script */ | ||
fn main() { | ||
println!("cargo:rerun-if-env-changed=ALWAYS_RUN"); | ||
|
||
match Command::new("python3").arg("./calypsogen.py").status() { | ||
Ok(status) if status.success() => { | ||
println!("Python script executed successfully"); | ||
}, | ||
Ok(status) => { | ||
eprintln!("Python script exited with status: {}", status); | ||
std::process::exit(1); | ||
}, | ||
Err(e) => { | ||
eprintln!("Failed to execute Python script: {}", e); | ||
std::process::exit(1); | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import importlib.util | ||
import sys | ||
|
||
# Full path to the directory containing the cangen module | ||
EMBEDDED_BASE_PATH = "./Embedded-Base" | ||
module_name = "cangen" | ||
|
||
# Full path to the cangen module file | ||
module_path = f"{EMBEDDED_BASE_PATH}/{module_name}/__init__.py" | ||
|
||
# Add the cangen directory to the system's path | ||
sys.path.append(EMBEDDED_BASE_PATH) | ||
|
||
# Load the module | ||
spec = importlib.util.spec_from_file_location(module_name, module_path) | ||
cangen = importlib.util.module_from_spec(spec) | ||
spec.loader.exec_module(cangen) | ||
|
||
decode_data = open("./src/decode_data.rs", "w") | ||
master_mapping = open("./src/master_mapping.rs", "w") | ||
|
||
bms_messages = cangen.YAMLParser().parse(open(f"{EMBEDDED_BASE_PATH}/{module_name}/can-messages/bms.yaml", "r")) | ||
mpu_messages = cangen.YAMLParser().parse(open(f"{EMBEDDED_BASE_PATH}/{module_name}/can-messages/mpu.yaml", "r")) | ||
wheel_messages = cangen.YAMLParser().parse(open(f"{EMBEDDED_BASE_PATH}/{module_name}/can-messages/wheel.yaml", "r")) | ||
|
||
bms_messages.msgs.extend(mpu_messages.msgs) | ||
bms_messages.msgs.extend(wheel_messages.msgs) | ||
|
||
result = cangen.RustSynth().parse_messages(bms_messages.msgs) | ||
|
||
decode_data.write(result.decode_data) | ||
decode_data.close() | ||
|
||
master_mapping.write(result.master_mapping) | ||
master_mapping.close() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.