Skip to content

Commit

Permalink
FIX: Small consistency issues fix
Browse files Browse the repository at this point in the history
  • Loading branch information
amilcarlucas committed Jan 28, 2025
1 parent 9903263 commit 472c3a3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
12 changes: 11 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,21 @@
"program": "ardupilot_methodic_configurator/__main__.py",
"args": [
"--allow-editing-template-files",
"--device=none",
"--device=COM6",
"--skip-component-editor",
"--n=7",
"--vehicle-dir=D:\\Projekte\\Multicopter\\MethodicConfigurator\\ardupilot_methodic_configurator\\vehicle_templates\\ArduCopter\\diatone_taycan_mxc\\4.6.x-params"
]
},
{
"name": "Python Debugger: frontend_tkinter_connection_selection.py",
"type": "debugpy",
"request": "launch",
"program": "ardupilot_methodic_configurator/frontend_tkinter_connection_selection.py",
"args": [
"--device=COM6",
"--loglevel=DEBUG"
]
}
]
}
4 changes: 2 additions & 2 deletions ardupilot_methodic_configurator/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def argument_parser() -> argparse.Namespace:
return add_common_arguments_and_parse(parser)


def connect_to_fc_and_read_parameters(args: argparse.Namespace) -> tuple[FlightController, str]:
def connect_to_fc_and_set_vehicle_type(args: argparse.Namespace) -> tuple[FlightController, str]:
flight_controller = FlightController(args.reboot_time)

error_str = flight_controller.connect(args.device, log_errors=False)
Expand Down Expand Up @@ -144,7 +144,7 @@ def main() -> None:
webbrowser_open(url=url, new=0, autoraise=True)

# Connect to the flight controller and read the parameters
flight_controller, vehicle_type = connect_to_fc_and_read_parameters(args)
flight_controller, vehicle_type = connect_to_fc_and_set_vehicle_type(args)

param_default_values = {}
if flight_controller.master is not None or args.device == "test":
Expand Down
5 changes: 4 additions & 1 deletion ardupilot_methodic_configurator/backend_flightcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,10 @@ def __process_autopilot_version(self, m: MAVLink_autopilot_version_message, bann
for i, msg in enumerate(banner_msgs):
if "ChibiOS:" in msg:
os_custom_version = msg.split(" ")[1].strip()
if os_custom_version != self.info.os_custom_version:
hash_len1 = max(7, len(os_custom_version) - 1)
hash_len2 = max(7, len(self.info.os_custom_version) - 1)
hash_len = min(hash_len1, hash_len2)
if os_custom_version[:hash_len] != self.info.os_custom_version[:hash_len]:
logging_warning(
_("ChibiOS version missmatch: %s (BANNER) != % s (AUTOPILOT_VERSION)"),
os_custom_version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def set_usb_vendor_and_product_ids(self, vendor_id: int, product_id: int) -> Non

def set_capabilities(self, capabilities: int) -> None:
self.capabilities = self.__decode_flight_capabilities(capabilities)
self.is_mavftp_supported = capabilities & mavutil.mavlink.MAV_PROTOCOL_CAPABILITY_FTP
self.is_mavftp_supported = bool(capabilities & mavutil.mavlink.MAV_PROTOCOL_CAPABILITY_FTP)

@staticmethod
def __decode_flight_sw_version(flight_sw_version: int) -> tuple[int, int, int, str]:
Expand Down
4 changes: 2 additions & 2 deletions tests/test__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import pytest

from ardupilot_methodic_configurator.__main__ import argument_parser, component_editor, connect_to_fc_and_read_parameters
from ardupilot_methodic_configurator.__main__ import argument_parser, component_editor, connect_to_fc_and_set_vehicle_type


@pytest.fixture
Expand Down Expand Up @@ -49,7 +49,7 @@ def test_connect_to_fc_and_read_parameters(self, mock_flight_controller) -> None
mock_fc.info.firmware_type = "type"

args = argparse.Namespace(device="test_device", vehicle_type="", reboot_time=5)
flight_controller, vehicle_type = connect_to_fc_and_read_parameters(args)
flight_controller, vehicle_type = connect_to_fc_and_set_vehicle_type(args)
assert flight_controller == mock_fc
assert vehicle_type == "quad"

Expand Down

0 comments on commit 472c3a3

Please sign in to comment.