Skip to content
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

Implemented config files #64

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Implemented config files #64

wants to merge 7 commits into from

Conversation

Alandlt15
Copy link

commandsConfig.py: holds dictionary of commands

config.json: holds other configuration data (eg. cubesat name, radio callsign, jokes, etc)

@Mikefly123
Copy link
Member

Mikefly123 commented Dec 28, 2024

Looks like a good start to me! I think that these init variables from pysquared.py should be next up to be added to the config files:

        """
        Big init routine as the whole board is brought up. Starting with config variables.
        """
        self.debug = True  # Define verbose output here. True or False
        self.legacy = False  # Define if the board is used with legacy or not
        self.heating = False  # Currently not used
        self.orpheus = True  # Define if the board is used with Orpheus or not
        self.is_licensed = True

        """
        Define the normal power modes
        """
        self.NORMAL_TEMP = 20
        self.NORMAL_BATT_TEMP = 1  # Set to 0 BEFORE FLIGHT!!!!!
        self.NORMAL_MICRO_TEMP = 20
        self.NORMAL_CHARGE_CURRENT = 0.5
        self.NORMAL_BATTERY_VOLTAGE = 6.9  # 6.9
        self.CRITICAL_BATTERY_VOLTAGE = 6.6  # 6.6
        self.vlowbatt = 6.0
        self.battery_voltage = 3.3  # default value for testing REPLACE WITH REAL VALUE
        self.current_draw = 255  # default value for testing REPLACE WITH REAL VALUE
        self.REBOOT_TIME = 3600  # 1 hour
        self.turbo_clock = False

You may also want to take a look at how CircuitPython has tried to natively introduce the use of a settings.toml:
https://docs.circuitpython.org/en/latest/docs/environment.html

@Mikefly123 Mikefly123 linked an issue Dec 28, 2024 that may be closed by this pull request
@Alandlt15
Copy link
Author

Ended up finishing the toml file for configuration. But when I connect to the board and the countdown starts, I get a "module named 'tomllib' not found" error.

I did some digging and found that tomllib, which is a library I need to parse data from the config file, was introduced in Python 3.11, which I know the actual board is about 6 versions behind.

My question is, would I be able to use a third party library called 'toml' I would simply need to run the command pip install toml I think, and parse exactly how I was attempting with the 'tomllib'. But I'm not too sure if that's a valid solution to this.

Otherwise, I believe my only option is to keep using json.

@Mikefly123
Copy link
Member

Hey @Alandlt15 I think this one of those things that is a mismatch between mainstream Python and CircuitPython.

It would appear from the CircuitPython docs that they only natively support accessing a settings.toml using the os module. This is the example that they give:

import os

print(os.getenv("test_variable"))

I'm not sure if this allows us to actually write values to the settings.toml during runtime or if it treats these variables as static. You may want to do some tests with your own board! If the implementation ends up being too clunky compared to using a .json then we can just go back to doing that.

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.

Move all Orpheus code/hard coded strings into config file options
2 participants