Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 5, 2025

Enables mission operators to change the satellite's startup code file using CircuitPython's supervisor.set_next_code_file() API, supporting safer over-the-air updates by allowing fallback to known-good code.

Implementation

cdh.py

  • Added set_next_code_file command that validates filename argument, calls supervisor.set_next_code_file(), and triggers automatic reset
  • Follows existing command pattern (change_radio_modulation)

Testing

  • Created supervisor mock for CPython test environment
  • 4 unit tests covering success, validation, error handling, and integration paths

Demo

  • examples/watchdog_demo.py - minimal demonstration script that prints status every 1 second
  • examples/README.md - usage documentation

Usage

{
  "password": "<password>",
  "name": "<satellite_name>",
  "command": "set_next_code_file",
  "args": ["watchdog_demo.py"]
}

Satellite responds with acknowledgement, resets, and executes specified file instead of default code.py.

References

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • astral.sh
    • Triggering command: curl -LsSf REDACTED (dns block)
  • https://api.github.com/repos/adafruit/adafruit_circuitpython_asyncio/commits/1.3.3
    • Triggering command: tools/uv-0.8.14/uv pip install --requirement pyproject.toml (http block)
  • https://api.github.com/repos/proveskit/Adafruit_CircuitPython_TCA9548A/commits/1.1.0
    • Triggering command: tools/uv-0.8.14/uv pip install --requirement pyproject.toml (http block)
  • https://api.github.com/repos/proveskit/CircuitPython_SX1280/commits/1.0.4
    • Triggering command: tools/uv-0.8.14/uv pip install --requirement pyproject.toml (http block)
  • https://api.github.com/repos/proveskit/micropySX126X/commits/1.0.0
    • Triggering command: tools/uv-0.8.14/uv pip install --requirement pyproject.toml (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[FEATURE] Add Command to cdh.py to Reset the Satellite with a New Initial Code File</issue_title>
<issue_description>

Story

  • As a mission operator
  • I want to change what is the first code file executed on startup
  • So that over the air updates can be commanded.

Acceptance Criteria

  • Adds a command to cdh.py
  • New command function in cdh.py that wraps a supervisor.set_next_code_file(str agrs) call
  • Demo of command being accepted by software and changing to a temp file that starts petting the watchdog at a 1s interval.

Technical Details

When we upload new code to the satellite, one of the safer ways to try running that update is to use the built in CircuitPython supervisor module. This module allows you to define what code file will execute after a reset (instead of the default code.py or main.py.

In this feature request, we want to just demo some barebones functionality of using this module, where we add a command to cdh.py that will accept a string augment that is then passed to a supervisor.set_next_code_file() call.

See the API docs at this link:
https://docs.circuitpython.org/en/latest/shared-bindings/supervisor/index.html#supervisor.set_next_code_file

The original PR that introduced this feature to the supervisor module might be helpful as well!
adafruit/circuitpython#3454</issue_description>

Comments on the Issue (you are @copilot in this section)

@Mikefly123 Hey @blakejameson I'm not super adamant, we can change it to be some other demonstration if it makes more sense.

In the screenshot you shared how is that initial file being called? Is the code just being reloaded or does it go through a full reset? If somehow pysquared is sticking around when the new neopixel file is called I can see how you'd get an "in use" error.</comment_new>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits November 5, 2025 08:16
Co-authored-by: Mikefly123 <61564344+Mikefly123@users.noreply.github.com>
Co-authored-by: Mikefly123 <61564344+Mikefly123@users.noreply.github.com>
Co-authored-by: Mikefly123 <61564344+Mikefly123@users.noreply.github.com>
Copilot AI changed the title [WIP] Add command to reset the satellite in cdh.py Add set_next_code_file command for over-the-air code updates via supervisor module Nov 5, 2025
Copilot AI requested a review from Mikefly123 November 5, 2025 08:26
Copilot finished work on behalf of Mikefly123 November 5, 2025 08:26
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
56.1% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

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.

[FEATURE] Add Command to cdh.py to Reset the Satellite with a New Initial Code File

2 participants