-
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!
- Loading branch information
Showing
19 changed files
with
55 additions
and
971 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
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,16 @@ | ||
use std::process::Command; | ||
|
||
/* Prebuild script */ | ||
fn main() { | ||
println!("cargo:rerun-if-env-changed=ALWAYS_RUN"); | ||
|
||
// Create a new command that runs bash | ||
let mut command = Command::new("python3"); | ||
|
||
// Pass the script name as an argument | ||
command.arg("./calypsogen.py"); | ||
|
||
// Execute the command | ||
// This will download a file called ncbi_dataset.zip in the current directory | ||
command.output().expect("Failed to generate can messages!"); | ||
} |
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.