Skip to content

Commit

Permalink
went back to json, working now
Browse files Browse the repository at this point in the history
  • Loading branch information
Alandlt15 committed Jan 3, 2025
1 parent ca207a2 commit 7da06d3
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 53 deletions.
15 changes: 7 additions & 8 deletions FC_Board/cdh.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
import json

commands = commandsConfig.commands
# parses config data from json file & assigns data to variables
with open("config.json", "r") as json_file:
json_data = json_file.read()
parsed_data = json.loads(json_data)

jokereply = parsed_data["jokereply"]
super_secret_code = parsed_data["super_secret_code"].encode("utf-8")
repeat_code = parsed_data["repeat_code"].encode("utf-8")
# parses toml & assigns data to variables
with open("settings.json", "r") as f:
json_data = f.read()
config = json.loads(json_data)
jokereply = config["jokereply"]
super_secret_code = config["super_secret_code"].encode("utf-8")
repeat_code = config["repeat_code"].encode("utf-8")
print(f"Super secret code is: {super_secret_code}")


Expand Down
24 changes: 12 additions & 12 deletions FC_Board/lib/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@ def __init__(self, cubesat: Satellite) -> None:
self.pm: PacketManager = PacketManager(max_packet_size=128)
self.ps: PacketSender = PacketSender(cubesat.radio1, self.pm, max_retries=3)

# parses config data from json file & assigns data to variables
with open("config.json", "r") as json_file:
json_data = json_file.read()
parsed_data = json.loads(json_data)
# parses toml & assigns data to variables
with open("settings.json", "r") as f:
json_data = f.read()
config = json.loads(json_data)

self.cubesatName: str = parsed_data["cubesatName"]
self.cubesatName: str = config["cubesatName"]
self.Errorcount: int = 0
self.facestring: list = [None, None, None, None, None]
self.jokes: list[str] = parsed_data["jokes"]
self.last_battery_temp: float = parsed_data["last_battery_temp"]
self.sleep_duration: int = parsed_data["sleep_duration"]
self.callsign: str = parsed_data["callsign"]
self.jokes: list[str] = config["jokes"]
self.last_battery_temp: float = config["last_battery_temp"]
self.sleep_duration: int = config["sleep_duration"]
self.callsign: str = config["callsign"]
self.state_bool: bool = False
self.face_data_baton: bool = False
self.detumble_enable_z: bool = parsed_data["detumble_enable_z"]
self.detumble_enable_x: bool = parsed_data["detumble_enable_x"]
self.detumble_enable_y: bool = parsed_data["detumble_enable_y"]
self.detumble_enable_z: bool = config["detumble_enable_z"]
self.detumble_enable_x: bool = config["detumble_enable_x"]
self.detumble_enable_y: bool = config["detumble_enable_y"]

"""
Satellite Management Functions
Expand Down
42 changes: 20 additions & 22 deletions FC_Board/lib/pysquared.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,44 +81,42 @@ def error_print(self, statement):
print(co("[pysquared]" + str(statement), "red", "bold"))

def __init__(self):
# parses config data from json file & assigns data to variables
with open("config.json", "r") as json_file:
json_data = json_file.read()
parsed_data = json.loads(json_data)
# parses toml & assigns data to variables
with open("settings.json", "r") as f:
json_data = f.read()
config = json.loads(json_data)

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

"""
Define the normal power modes
"""
self.NORMAL_TEMP = parsed_data["NORMAL_TEMP"]
self.NORMAL_BATT_TEMP = parsed_data[
self.NORMAL_TEMP = config["NORMAL_TEMP"]
self.NORMAL_BATT_TEMP = config[
"NORMAL_BATT_TEMP"
] # Set to 0 BEFORE FLIGHT!!!!!
self.NORMAL_MICRO_TEMP = parsed_data["NORMAL_MICRO_TEMP"]
self.NORMAL_CHARGE_CURRENT = parsed_data["NORMAL_CHARGE_CURRENT"]
self.NORMAL_BATTERY_VOLTAGE = parsed_data["NORMAL_BATTERY_VOLTAGE"] # 6.9
self.CRITICAL_BATTERY_VOLTAGE = parsed_data["CRITICAL_BATTERY_VOLTAGE"] # 6.6
self.vlowbatt = parsed_data["vlowbatt"]
self.battery_voltage = parsed_data[
self.NORMAL_MICRO_TEMP = config["NORMAL_MICRO_TEMP"]
self.NORMAL_CHARGE_CURRENT = config["NORMAL_CHARGE_CURRENT"]
self.NORMAL_BATTERY_VOLTAGE = config["NORMAL_BATTERY_VOLTAGE"] # 6.9
self.CRITICAL_BATTERY_VOLTAGE = config["CRITICAL_BATTERY_VOLTAGE"] # 6.6
self.vlowbatt = config["vlowbatt"]
self.battery_voltage = config[
"battery_voltage"
] # default value for testing REPLACE WITH REAL VALUE
self.current_draw = parsed_data[
self.current_draw = config[
"current_draw"
] # default value for testing REPLACE WITH REAL VALUE
self.REBOOT_TIME = parsed_data["REBOOT_TIME"] # 1 hour
self.turbo_clock = parsed_data["turbo_clock"]
self.REBOOT_TIME = config["REBOOT_TIME"] # 1 hour
self.turbo_clock = config["turbo_clock"]

"""
Setting up data buffers
Expand Down
40 changes: 29 additions & 11 deletions FC_Board/config.json → FC_Board/settings.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"cubesatName": "Orpheus",
"callsign": "KO6AZM",
"last_battery_temp": 20.0,
"sleep_duration": 30,
"detumble_enable_z": true,
"detumble_enable_x": true,
"detumble_enable_y": true,
"jokes": [
"cubesatName": "Orpheus",
"callsign": "KO6AZM",
"last_battery_temp": 20.0,
"sleep_duration": 30,
"detumble_enable_z": true,
"detumble_enable_x":true,
"detumble_enable_y": true,
"jokes": [
"Hey it is pretty cold up here, did someone forget to pay the electric bill?",
"sudo rf - rf*",
"Why did the astronaut break up with his girlfriend? He needed space.",
Expand Down Expand Up @@ -43,9 +43,27 @@
"Woah is that the Launcher Orbiter?????",
"Everything in life is a spring if you think hard enough!"
],
"super_secret_code": "ABCD",
"repeat_code": "RP",
"jokereply": [

"debug": true,
"legacy": false,
"heating": false,
"orpheus":true,
"is_licensed":true,
"NORMAL_TEMP": 20,
"NORMAL_BATT_TEMP": 1,
"NORMAL_MICRO_TEMP": 20,
"NORMAL_CHARGE_CURRENT": 0.5,
"NORMAL_BATTERY_VOLTAGE": 6.9,
"CRITICAL_BATTERY_VOLTAGE": 6.6,
"vlowbatt": 6.0,
"battery_voltage": 3.3,
"current_draw": 255,
"REBOOT_TIME": 3600,
"turbo_clock": false,

"super_secret_code": "ABCD",
"repeat_code": "RP",
"jokereply": [
"Your Mom",
"Your Mum",
"Your Face",
Expand Down

0 comments on commit 7da06d3

Please sign in to comment.