Skip to content

Commit

Permalink
core:services:autopilot_manager: SERVICE_NAME to config
Browse files Browse the repository at this point in the history
* Move SERVICE_NAME from settings.py to config.py
* Update places that use SERVICE_NAME or settings.app_name to use
  SERVICE_NAME from config.py
  • Loading branch information
JoaoMario109 committed Dec 16, 2024
1 parent 5721587 commit e883dfb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
21 changes: 11 additions & 10 deletions core/services/ardupilot_manager/autopilot_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from elftools.elf.elffile import ELFFile
from loguru import logger

from config import SERVICE_NAME
from exceptions import (
AutoPilotProcessKillFail,
NoDefaultFirmwareAvailable,
Expand Down Expand Up @@ -212,7 +213,7 @@ async def start_linux_board(self, board: LinuxFlightController) -> None:
# ArduPilot process will connect as a client on the UDP server created by the mavlink router
master_endpoint = Endpoint(
name="Master",
owner=self.settings.app_name,
owner=SERVICE_NAME,
connection_type=EndpointType.UDPServer,
place="127.0.0.1",
argument=8852,
Expand Down Expand Up @@ -269,7 +270,7 @@ async def start_serial(self, board: FlightController) -> None:
await self.start_mavlink_manager(
Endpoint(
name="Master",
owner=self.settings.app_name,
owner=SERVICE_NAME,
connection_type=EndpointType.Serial,
place=board.path,
argument=baudrate,
Expand Down Expand Up @@ -324,7 +325,7 @@ async def start_sitl(self) -> None:
# ArduPilot SITL binary will bind TCP port 5760 (server) and the mavlink router will connect to it as a client
master_endpoint = Endpoint(
name="Master",
owner=self.settings.app_name,
owner=SERVICE_NAME,
connection_type=EndpointType.TCPClient,
place="127.0.0.1",
argument=5760,
Expand Down Expand Up @@ -353,7 +354,7 @@ async def start_mavlink_manager(self, device: Endpoint) -> None:
default_endpoints = [
Endpoint(
name="GCS Server Link",
owner=self.settings.app_name,
owner=SERVICE_NAME,
connection_type=EndpointType.UDPServer,
place="0.0.0.0",
argument=14550,
Expand All @@ -362,7 +363,7 @@ async def start_mavlink_manager(self, device: Endpoint) -> None:
),
Endpoint(
name="GCS Client Link",
owner=self.settings.app_name,
owner=SERVICE_NAME,
connection_type=EndpointType.UDPClient,
place="192.168.2.1",
argument=14550,
Expand All @@ -371,7 +372,7 @@ async def start_mavlink_manager(self, device: Endpoint) -> None:
),
Endpoint(
name="MAVLink2RestServer",
owner=self.settings.app_name,
owner=SERVICE_NAME,
connection_type=EndpointType.UDPServer,
place="127.0.0.1",
argument=14001,
Expand All @@ -380,7 +381,7 @@ async def start_mavlink_manager(self, device: Endpoint) -> None:
),
Endpoint(
name="MAVLink2Rest",
owner=self.settings.app_name,
owner=SERVICE_NAME,
connection_type=EndpointType.UDPClient,
place="127.0.0.1",
argument=14000,
Expand All @@ -390,7 +391,7 @@ async def start_mavlink_manager(self, device: Endpoint) -> None:
),
Endpoint(
name="Zenoh Deamon",
owner=self.settings.app_name,
owner=SERVICE_NAME,
connection_type=EndpointType.Zenoh,
place="0.0.0.0",
argument=7117,
Expand All @@ -399,7 +400,7 @@ async def start_mavlink_manager(self, device: Endpoint) -> None:
),
Endpoint(
name="Internal Link",
owner=self.settings.app_name,
owner=SERVICE_NAME,
connection_type=EndpointType.TCPServer,
place="127.0.0.1",
argument=5777,
Expand All @@ -409,7 +410,7 @@ async def start_mavlink_manager(self, device: Endpoint) -> None:
),
Endpoint(
name="Ping360 Heading",
owner=self.settings.app_name,
owner=SERVICE_NAME,
connection_type=EndpointType.UDPServer,
place="0.0.0.0",
argument=14660,
Expand Down
5 changes: 5 additions & 0 deletions core/services/ardupilot_manager/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file is used to define general configurations for the app

SERVICE_NAME = "autopilot-manager"

__all__ = ["SERVICE_NAME"]
2 changes: 1 addition & 1 deletion core/services/ardupilot_manager/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from args import CommandLineArgs
from autopilot_manager import AutoPilotManager
from flight_controller_detector.Detector import Detector as BoardDetector
from settings import SERVICE_NAME
from config import SERVICE_NAME

logging.basicConfig(handlers=[InterceptHandler()], level=0)
init_logger(SERVICE_NAME)
Expand Down
6 changes: 2 additions & 4 deletions core/services/ardupilot_manager/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
import appdirs
from loguru import logger

from config import SERVICE_NAME
from typedefs import SITLFrame

SERVICE_NAME = "ardupilot-manager"


class Settings:
app_name = SERVICE_NAME
settings_path = Path(appdirs.user_config_dir(app_name))
settings_path = Path(appdirs.user_config_dir(SERVICE_NAME))
settings_file = Path.joinpath(settings_path, "settings.json")
firmware_folder = Path.joinpath(settings_path, "firmware")
user_firmware_folder = Path("/usr/blueos/userdata/firmware")
Expand Down

0 comments on commit e883dfb

Please sign in to comment.