Skip to content

Commit

Permalink
#20 Seperate Yaml Files
Browse files Browse the repository at this point in the history
  • Loading branch information
Peyton-McKee committed Jan 11, 2024
1 parent 7a08642 commit 4586ead
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 74 deletions.
4 changes: 2 additions & 2 deletions oxy/RustSynth.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class RustSynth:
}
"""

def parse_messages(self, msgs: Messages) -> Result:
def parse_messages(self, msgs: [CANMsg]) -> Result:
result = Result("", "")
result.decode_data += self.ignore_clippy
result.decode_data += self.decode_data_import
Expand All @@ -54,7 +54,7 @@ def parse_messages(self, msgs: Messages) -> Result:
result.master_mapping += self.message_info
result.master_mapping += self.master_mapping_signature

for msg in msgs.msgs:
for msg in msgs:
result.decode_data += self.synthesize(msg) + "\n"
result.master_mapping += self.map_msg_to_decoder(msg)

Expand Down
2 changes: 1 addition & 1 deletion oxy/YAMLParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ def __init__(self):
self.yaml.register_class(decoding)


def parse(self, file: Any) -> CANMsg:
def parse(self, file: Any) -> Messages:
return self.yaml.load(file)
10 changes: 9 additions & 1 deletion oxy/typedpoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@
decode_data = open("../src/decode_data.rs", "w")
master_mapping = open("../src/master_mapping.rs", "w")

result = RustSynth().parse_messages(YAMLParser().parse(open("mapping.yaml", "r")))
bms_messages = YAMLParser().parse(open("yaml/bms.yaml", "r"))
mpu_messages = YAMLParser().parse(open("yaml/mpu.yaml", "r"))
wheel_messages = YAMLParser().parse(open("yaml/wheel.yaml", "r"))


bms_messages.msgs.extend(mpu_messages.msgs)
bms_messages.msgs.extend(wheel_messages.msgs)

result = RustSynth().parse_messages(bms_messages.msgs)

decode_data.write(result.decode_data)
decode_data.close()
Expand Down
70 changes: 0 additions & 70 deletions oxy/mapping.yaml → oxy/yaml/bms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -241,73 +241,3 @@ msgs:
decodings:
- !TwosComplement
bits: 8

# MPU BROADCAST
- !CANMsg
id: "0x500"
desc: "NERduino Acceleromter"
fields:
- !CANField
name: "MPU/Accel/X"
unit: "g"
size: 2
decodings:
- !BigEndian
bits: 8
format: "acceleration"
- !CANField
name: "MPU/Accel/Y"
unit: "g"
size: 2
decodings:
- !BigEndian
bits: 8
format: "acceleration"
- !CANField
name: "MPU/Accel/Z"
unit: "g"
size: 2
decodings:
- !BigEndian
bits: 8
format: "acceleration"

- !CANMsg
id: "0x501"
desc: "MPU Status"
fields:
- !CANField
name: "MPU/State/Mode"
unit: ""
size: 1
- !CANField
name: "MPU/State/Torque_Limit_Percentage"
unit: ""
size: 1
- !CANField
name: "MPU/State/Regen_Strength"
unit: ""
size: 1
- !CANField
name: "MPU/State/Traction_Control"
unit: ""
size: 1


#STEERINGWHEEL
- !CANMsg
id: "0x680"
desc: "Wheel State"
fields:
- !CANField
name: "WHEEL/Buttons/1"
unit: ""
size: 1
- !CANField
name: "WHEEL/Buttons/2"
unit: ""
size: 1




51 changes: 51 additions & 0 deletions oxy/yaml/mpu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
!Messages
msgs:
- !CANMsg
id: "0x500"
desc: "NERduino Acceleromter"
fields:
- !CANField
name: "MPU/Accel/X"
unit: "g"
size: 2
decodings:
- !BigEndian
bits: 8
format: "acceleration"
- !CANField
name: "MPU/Accel/Y"
unit: "g"
size: 2
decodings:
- !BigEndian
bits: 8
format: "acceleration"
- !CANField
name: "MPU/Accel/Z"
unit: "g"
size: 2
decodings:
- !BigEndian
bits: 8
format: "acceleration"

- !CANMsg
id: "0x501"
desc: "MPU Status"
fields:
- !CANField
name: "MPU/State/Mode"
unit: ""
size: 1
- !CANField
name: "MPU/State/Torque_Limit_Percentage"
unit: ""
size: 1
- !CANField
name: "MPU/State/Regen_Strength"
unit: ""
size: 1
- !CANField
name: "MPU/State/Traction_Control"
unit: ""
size: 1
14 changes: 14 additions & 0 deletions oxy/yaml/wheel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
!Messages
msgs:
- !CANMsg
id: "0x680"
desc: "Wheel State"
fields:
- !CANField
name: "WHEEL/Buttons/1"
unit: ""
size: 1
- !CANField
name: "WHEEL/Buttons/2"
unit: ""
size: 1

0 comments on commit 4586ead

Please sign in to comment.