Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
loki077 committed Dec 30, 2024
1 parent ba293e5 commit 200928c
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 2 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/carbonix_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,11 @@ jobs:
- name: Run aircraft_config.py
run: |
python Tools/Carbonix_scripts/aircraft_config.py "libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/${{ matrix.xml_file }}.xml" "${{ env.commit_id }}"
ls -la final-output/*/ || echo "No files found"
# Check if the folder exists if not skip the next steps
if [ ! -d "final-output" ]; then
echo "No final-output folder found, skipping the next steps"
exit 0
fi
- name: Install AWS CLI
run: |
Expand Down Expand Up @@ -529,5 +533,7 @@ jobs:
- name: Upload zipped folder to S3
run: |
PATH_TO_S3=${{ needs.setup-s3-path.outputs.s3_path }}
# Remove trailing slash if it exists
PATH_TO_S3=${PATH_TO_S3%/}
echo "Uploading to: $PATH_TO_S3"
aws s3 cp ${{ env.folder_name }}.zip $PATH_TO_S3/${{ env.folder_name }}.zip
27 changes: 26 additions & 1 deletion Tools/Carbonix_scripts/aircraft_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,27 @@ def build_flight_controller_firmware(board_name : str) -> None:
raise RuntimeError(f"Error building firmware for {board_name}")


def check_config_status(xml_file : str) -> bool:
"""Check the status of the aircraft configuration.
Args:
xml_file (str): Path to the XML file.
Returns:
bool: False if the configuration is deprecated, True otherwise.
"""
tree = ET.parse(xml_file)
root = tree.getroot()

aircraft = root.find('aircraft')
if aircraft is None:
raise AssertionError(f"'aircraft' element not found in {xml_file}")

status = aircraft.find('status')
if status is None:
raise AssertionError(f"'status' element not found in the 'aircraft' element of {xml_file}")

return status.text == 'active'

if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('xml_file', help='Path to the XML file')
Expand All @@ -240,7 +261,11 @@ def build_flight_controller_firmware(board_name : str) -> None:

print('XML file:', args.xml_file)
print('Commit ID:', args.commit_id)


if not check_config_status(args.xml_file):
print('Aircraft configuration is deprecated. No further action needed.')
exit(0)

xml_file = copy_configuration_file(args.xml_file, args.commit_id)
copy_lua_scripts(xml_file)
fc_board_name = get_flight_controller_board_name(xml_file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
CAN Airspeed,
CAN Battery Monitor
</model_description>
<status>deprecated</status>
<configuration_version>1</configuration_version>
</aircraft>
<flight_controller>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
CAN Airspeed,
CAN Battery Monitor
</model_description>
<status>active</status>
<configuration_version>1</configuration_version>
</aircraft>
<flight_controller>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
Non Crystal CPNs,
CAN Airspeed
</model_description>
<status>active</status>
<configuration_version>1</configuration_version>
</aircraft>
<flight_controller>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
CAN GPS,
CAN Airspeed
</model_description>
<status>active</status>
<configuration_version>1</configuration_version>
</aircraft>
<flight_controller>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
CAN GPS,
CAN Airspeed
</model_description>
<status>active</status>
<configuration_version>1</configuration_version>
</aircraft>
<flight_controller>
Expand Down

0 comments on commit 200928c

Please sign in to comment.