Skip to content

Commit

Permalink
Merge pull request #38 from oresat/fix/kaitai
Browse files Browse the repository at this point in the history
Fix generator bugs
  • Loading branch information
dmitri-mcguckin authored Aug 16, 2024
2 parents e7be40a + c9abc15 commit 4fcec8d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions oresat_configs/scripts/gen_kaitai.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def write_kaitai(config: OreSatConfig, dir_path: str = ".") -> None:
"id": "rpt_instance",
"type": "repeaters",
"repeat": "until",
"repeat-until": "_.rpt_ssid_raw.ssid_mask & 0x01 == 1",
"repeat-until": "((_.rpt_ssid_raw.ssid_mask & 0x1) == 0x1)",
"doc": "Repeat until no repeater flag is set!",
}
]
Expand All @@ -158,7 +158,7 @@ def write_kaitai(config: OreSatConfig, dir_path: str = ".") -> None:
"seq": [
{
"id": "callsign_ror",
"process": "repeaters",
"process": "ror(1)",
"size": 6,
"type": "callsign",
}
Expand Down Expand Up @@ -190,7 +190,7 @@ def write_kaitai(config: OreSatConfig, dir_path: str = ".") -> None:
"id": "pid",
"type": "u1",
},
{"id": "ax25_info", "type": "ax25_info_data", "size-eos": True},
{"id": "ax25_info", "type": "ax25_info_data", "size": -1},
]
},
"ui_frame": {
Expand All @@ -199,14 +199,16 @@ def write_kaitai(config: OreSatConfig, dir_path: str = ".") -> None:
"id": "pid",
"type": "u1",
},
{"id": "ax25_info", "type": "ax25_info_data", "size-eos": True},
{"id": "ax25_info", "type": "ax25_info_data", "size": -1},
]
},
"ax25_info_data": {"seq": []},
},
}

# Append field types for each field
payload_size = 0

for obj in config.beacon_def:
name = (
"_".join([obj.parent.name, obj.name])
Expand All @@ -223,9 +225,16 @@ def write_kaitai(config: OreSatConfig, dir_path: str = ".") -> None:
new_var["encoding"] = "ASCII"
if obj.access_type == "const":
new_var["size"] = len(obj.default)
payload_size += new_var["size"] * 8
else:
payload_size += len(obj)

kaitai_data["types"]["ax25_info_data"]["seq"].append(new_var)

payload_size //= 8
kaitai_data["types"]["i_frame"]["seq"][1]["size"] = payload_size
kaitai_data["types"]["ui_frame"]["seq"][1]["size"] = payload_size

# Write kaitai to output file
with open(f"{dir_path}/{filename}.ksy", "w+") as file:
dump(kaitai_data, file)
Expand Down

0 comments on commit 4fcec8d

Please sign in to comment.