Skip to content

autopilot_manager: check if we are running on a pi4 for NavigatorPì4 #3204

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Williangalvani
Copy link
Member

@Williangalvani Williangalvani commented Mar 17, 2025

This will make it so the detection doesn't run on pi3 and other boards
waiting for CI to test it

Summary by Sourcery

Add Raspberry Pi 4 detection method for NavigatorPi4 flight controller

New Features:

  • Implement a method to detect Raspberry Pi 4 specifically in the flight controller detection logic

Enhancements:

  • Modify the detection logic to explicitly check for Raspberry Pi 4 hardware

Copy link

sourcery-ai bot commented Mar 17, 2025

Reviewer's Guide by Sourcery

This pull request modifies the NavigatorPi4 class to only run the i2c device check on Raspberry Pi 4. It adds a function to detect if the system is running on a Raspberry Pi 4 and modifies the detect function to only run the i2c device check if the system is a Raspberry Pi 4.

Sequence diagram for NavigatorPi4.detect()

sequenceDiagram
  participant NavigatorPi4
  NavigatorPi4->>NavigatorPi4: is_pi4()
  alt is_pi4() == True
    NavigatorPi4->>NavigatorPi4: check_for_i2c_device(bus, address) for each device
    NavigatorPi4->>NavigatorPi4: all(check_for_i2c_device)
  else is_pi4() == False
    NavigatorPi4-->>NavigatorPi4: return False
  end
Loading

Updated class diagram for NavigatorPi4

classDiagram
  class NavigatorPi4 {
    -devices: Dict[int, Tuple[int, int]]
    +__init__(self, i2c: I2C)
    +get_release(self) string
    +get_serials(self) List[Serial]
    +is_pi5() bool
    +is_pi4() bool
    +detect() bool
    +check_for_i2c_device(self, bus: int, address: int) bool
  }
  note for NavigatorPi4 "detect() now checks if the system is a Raspberry Pi 4 before running the i2c device check."
Loading

File-Level Changes

Change Details Files
Added a function to detect if the system is running on a Raspberry Pi 4.
  • Added the is_pi4 function that reads /proc/cpuinfo and returns true if the system is a Raspberry Pi 4.
core/services/ardupilot_manager/flight_controller_detector/linux/navigator.py
Modified the detect function to only run the i2c device check on Raspberry Pi 4.
  • The detect function now checks if the system is a Raspberry Pi 4 before running the i2c device check.
  • The i2c device check is skipped if the system is not a Raspberry Pi 4.
core/services/ardupilot_manager/flight_controller_detector/linux/navigator.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@Williangalvani Williangalvani marked this pull request as ready for review April 14, 2025 19:43
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Williangalvani - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider extracting the file reading logic into a separate helper function to avoid repetition in is_pi5 and is_pi4.
  • It might be clearer to rename detect to is_present or is_supported to better reflect its purpose.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

This will make it so the detection doesn't run on pi3 and other boards
@@ -1,7 +1,7 @@
import platform
from typing import Any, List

from commonwealth.utils.commands import load_file
from commonwealth.utils.commands import CpuType, get_cpu_type, load_file
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that get_cpu_type and CpuType are in .general

Suggested change
from commonwealth.utils.commands import CpuType, get_cpu_type, load_file
from commonwealth.utils.commands import load_file
from commonwealth.utils.general import CpuType, get_cpu_type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants