-
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.
- Loading branch information
1 parent
47b832b
commit 13decd2
Showing
9 changed files
with
123 additions
and
40 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
class Result: | ||
decode_data: str | ||
master_mapping: str | ||
|
||
def __init__(self, decode_data: str, master_mapping: str): | ||
self.decode_data = decode_data | ||
self.master_mapping = master_mapping |
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 |
---|---|---|
@@ -1,8 +1,13 @@ | ||
from YAMLParser import YAMLParser | ||
from RustSynth import RustSynth | ||
|
||
f = open("../src/decode_data.rs", "w") | ||
decode_data = open("../src/decode_data.rs", "w") | ||
master_mapping = open("../src/master_mapping.rs", "w") | ||
|
||
f.write(RustSynth().parse_messages(YAMLParser().parse(open("mapping.yaml", "r")))) | ||
result = RustSynth().parse_messages(YAMLParser().parse(open("mapping.yaml", "r"))) | ||
|
||
f.close() | ||
decode_data.write(result.decode_data) | ||
decode_data.close() | ||
|
||
master_mapping.write(result.master_mapping) | ||
master_mapping.close() |
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
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 |
---|---|---|
|
@@ -3,3 +3,4 @@ pub mod data; | |
pub mod decode_data; | ||
pub mod message; | ||
pub mod mqtt; | ||
pub mod master_mapping; |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use super::decode_data::*; | ||
use super::data::Data; | ||
|
||
pub struct MessageInfo { | ||
pub decoder: fn(data: &[u8]) -> Vec<Data>, | ||
} | ||
|
||
impl MessageInfo { | ||
pub fn new(decoder: fn(data: &[u8]) -> Vec<Data>) -> Self { | ||
Self { | ||
decoder | ||
} | ||
} | ||
} | ||
pub fn get_message_info(id: &u32) -> MessageInfo { | ||
match id { 0x80 => MessageInfo::new(decode_accumulator_status), | ||
0x81 => MessageInfo::new(decode_bms_status), | ||
0x82 => MessageInfo::new(decode_shutdown_control), | ||
0x83 => MessageInfo::new(decode_cell_data), | ||
0x84 => MessageInfo::new(decode_cell_temperatures), | ||
0x85 => MessageInfo::new(decode_segment_temperatures), | ||
0x500 => MessageInfo::new(decode_nerduino_acceleromter), | ||
0x501 => MessageInfo::new(decode_mpu_status), | ||
0x680 => MessageInfo::new(decode_wheel_state), | ||
_ => MessageInfo::new(decode_mock), | ||
} | ||
} |
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