Skip to content

Commit

Permalink
conditional pi5/4 in ardupilotmanager
Browse files Browse the repository at this point in the history
  • Loading branch information
Williangalvani committed May 16, 2024
1 parent c9804de commit 38e0403
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions core/services/ardupilot_manager/ArduPilotManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ def update_serials(self, serials: List[Serial]) -> None:
self.settings.save(self.configuration)

def get_serials(self) -> List[Serial]:
is_pi5 = False
with open("/proc/cpuinfo", "r") as f:
if "Raspberry Pi 5" in f.read():
is_pi5 = True

# The mapping of serial ports works as in the following table:
#
# | ArduSub | Navigator |
Expand All @@ -157,13 +162,23 @@ def get_serials(self) -> List[Serial]:
# The first column comes from https://ardupilot.org/dev/docs/sitl-serial-mapping.html

if "serials" not in self.configuration:
return [
# updated for bookworm/pi5
Serial(port="C", endpoint="/dev/ttyAMA0"),
Serial(port="B", endpoint="/dev/ttyAMA2"),
Serial(port="E", endpoint="/dev/ttyAMA3"),
Serial(port="F", endpoint="/dev/ttyAMA4"),
]
if is_pi5:
return [
# updated for bookworm/pi5
Serial(port="C", endpoint="/dev/ttyAMA0"),
Serial(port="B", endpoint="/dev/ttyAMA2"),
Serial(port="E", endpoint="/dev/ttyAMA3"),
Serial(port="F", endpoint="/dev/ttyAMA4"),
]
else:
return [
# updated for bookworm/pi5
Serial(port="C", endpoint="/dev/ttyS0"),
Serial(port="B", endpoint="/dev/ttyAMA3"),
Serial(port="E", endpoint="/dev/ttyAMA4"),
Serial(port="F", endpoint="/dev/ttyAMA5"),
]

serials = []
for entry in self.configuration["serials"]:
try:
Expand Down

0 comments on commit 38e0403

Please sign in to comment.