Skip to content

Commit

Permalink
just use 32 bit
Browse files Browse the repository at this point in the history
  • Loading branch information
jr1221 committed May 19, 2024
1 parent e22d3cf commit a7cdb21
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions cangen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Ex. If there are 5 messages of size one (booleans), add a 3 bit filler before ad
4. Message totals should be byte aligned, meaning total bit size of a message should be a power of 8
5. **Signed messages must be 8,16,or 32 bits!**
6. **Little endian messages must be 8,16, or 32 bits!**
7. Maximum size of a sent message (default, aka send=True), is 32 bits

Message guide:
1. Use previous examples for most things
Expand Down
10 changes: 4 additions & 6 deletions cangen/RustSynth.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,14 @@ def parse_decoders(self, field: CANPoint, skip) -> str:
if skip:
return f"reader.skip({field.size}).unwrap()"

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

if field.endianness == "big":
if field.signed:
base = f"reader.read_signed::<i{size}>({field.size}).unwrap()"
# doesnt need exact sign bit as it is in big endian form, the form of the native stream
base = f"reader.read_signed::<i32>({field.size}).unwrap()"
else:
base = f"reader.read::<u{size}>({field.size}).unwrap()"
base = f"reader.read::<u32>({field.size}).unwrap()"
elif field.endianness == "little":
# use the read_as_to, which requires byte sized data to get the correct sign bit
if field.signed:
base = f"reader.read_as_to::<LittleEndian, i{field.size}>().unwrap()"
else:
Expand Down

0 comments on commit a7cdb21

Please sign in to comment.