Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix generator bugs #38

Merged
merged 2 commits into from
Aug 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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