Skip to content

Commit

Permalink
fix skip
Browse files Browse the repository at this point in the history
  • Loading branch information
jr1221 committed May 19, 2024
1 parent f09ab04 commit 6e9870d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cangen/RustSynth.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ def add_length_check(self, fields: List[CANPoint]) -> str:
field_size = sum(field.get_size_bits() for field in fields) / 8
return f" if data.len() < {int(field_size)} {{ return vec![]; }}"

def decode_field_value(self, field: CANPoint) -> str:
def decode_field_value(self, field: CANPoint, skip=False) -> str:
"""
Parse can point to do conversions on it, and maybe wrap in formatter
"""
return f"{self.format_data(field, self.parse_decoders(field))}"
return f"{self.format_data(field, self.parse_decoders(field, skip))}"

def function_name(self, desc: str) -> str:
"""
Expand Down Expand Up @@ -134,14 +134,14 @@ def finalize_line(self, topic: str, unit: str, val: str, topic_appends_name: Opt
format_topic += ")"
return f' {val}, \n {format_topic}, "{unit}")'

def parse_decoders(self, field: CANPoint, skip=False) -> str:
def parse_decoders(self, field: CANPoint, skip) -> str:
"""
Helper function that parses the decoders for a given CANUnit by applying the
decoders to the data and casting the result to the final type of the CANUnit.
"""

if skip:
return f"reader.skip::({field.size}).unwrap()"
return f"reader.skip({field.size}).unwrap()"

size = field.size
if field.size < 8:
Expand Down

0 comments on commit 6e9870d

Please sign in to comment.