Skip to content

Commit f6a8e8f

Browse files
committed
Simplify main, add json autoformat precommit
1 parent 1f0a8b0 commit f6a8e8f

File tree

4 files changed

+107
-162
lines changed

4 files changed

+107
-162
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ repos:
77
- id: check-yaml
88
- id: check-json
99
- id: check-added-large-files
10+
- id: pretty-format-json
11+
args: [--autofix]
12+
exclude: '.vscode/.*'
1013
#- id: mixed-line-ending
1114
# args: [ --fix=lf ]
1215

config.json

Lines changed: 79 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,86 @@
11
{
2-
"cubesat_name": "Orpheus",
3-
"last_battery_temp": 20.0,
4-
"sleep_duration": 30,
5-
"detumble_enable_z": true,
6-
"detumble_enable_x":true,
7-
"detumble_enable_y": true,
8-
"jokes": [
9-
"Hey it is pretty cold up here, did someone forget to pay the electric bill?",
10-
"sudo rf - rf*",
11-
"Why did the astronaut break up with his girlfriend? He needed space.",
12-
"Why did the sun go to school? To get a little brighter.",
13-
"why is the mall called the mall? because instead of going to one store you go to them all",
14-
"Alien detected. Blurring photo...",
15-
"Wait it is all open source? Always has been... www.github.com/proveskit",
16-
"What did 0 say to 1? You're a bit too much.",
17-
"Pleiades - Orpheus has been recently acquired by the Onion News Network",
18-
"This jokesat was brought to you by the Bronco Space Ministry of Labor and Job Placement",
19-
"Catch you on the next pass!",
20-
"Pleiades - Orpheus was not The Impostor",
21-
"Sorry for messing with your long-exposure astrophoto!",
22-
"Better buy a telescope. Wanna see me. Buy a telescope. Gonna be in space.",
23-
"According to all known laws of aviation, there is no way bees should be able to fly...",
24-
"You lost the game ",
25-
"Bobby Tables is a good friend of mine",
26-
"Why did the computer cross the road? To get a byte to eat!",
27-
"Why are the astronauts not hungry when they got to space? They had a big launch.",
28-
"Why did the computer get glasses? To improve its web sight!",
29-
"What are computers favorite snacks? Chips!",
30-
"Wait! I think I see a White 2019 Subaru Crosstrek 2.0i Premium",
31-
"IS THAT A SUPRA?!",
32-
"Finally escpaed the LA Traffic",
33-
"My CubeSat is really good at jokes, but its delivery is always delayed.",
34-
"exec order 66",
35-
"I had a joke about UDP, but I am not sure if you'd get it.",
36-
"I am not saying FSK modulation is the best way to send jokes, but at least it is never monotone!",
37-
"I am sorry David, I am afrain I can not do that.",
38-
"My memory is volatile like RAM, so it only makes sense that I forget things.",
39-
"Imagine it gets stuck and just keeps repeating this joke every 2 mins",
40-
"Check Engine: Error Code 404: Joke Not Found",
41-
"CQ CQ KN6NAQ ... KN6NAT are you out there?",
42-
"Woah is that the Launcher Orbiter?????",
43-
"Everything in life is a spring if you think hard enough!"
44-
],
45-
"debug": true,
46-
"heating": false,
47-
"normal_temp": 20,
48-
"normal_battery_temp": 1,
49-
"normal_micro_temp": 20,
50-
"normal_charge_current": 0.5,
51-
"normal_battery_voltage": 6.9,
52-
"critical_battery_voltage": 6.6,
53-
"battery_voltage": 5.2,
54-
"current_draw": 240.5,
55-
"reboot_time": 3600,
56-
"longest_allowable_sleep_time": 600,
57-
"turbo_clock": false,
58-
"radio": {
2+
"battery_voltage": 5.2,
3+
"critical_battery_voltage": 6.6,
4+
"cubesat_name": "PROVES-MY_SATELLITE_NAME",
5+
"current_draw": 240.5,
6+
"debug": true,
7+
"detumble_enable_x": true,
8+
"detumble_enable_y": true,
9+
"detumble_enable_z": true,
10+
"heating": false,
11+
"jokes": [
12+
"Hey it is pretty cold up here, did someone forget to pay the electric bill?",
13+
"sudo rf - rf*",
14+
"Why did the astronaut break up with his girlfriend? He needed space.",
15+
"Why did the sun go to school? To get a little brighter.",
16+
"why is the mall called the mall? because instead of going to one store you go to them all",
17+
"Alien detected. Blurring photo...",
18+
"Wait it is all open source? Always has been... www.github.com/proveskit",
19+
"What did 0 say to 1? You're a bit too much.",
20+
"Pleiades - Orpheus has been recently acquired by the Onion News Network",
21+
"This jokesat was brought to you by the Bronco Space Ministry of Labor and Job Placement",
22+
"Catch you on the next pass!",
23+
"Pleiades - Orpheus was not The Impostor",
24+
"Sorry for messing with your long-exposure astrophoto!",
25+
"Better buy a telescope. Wanna see me. Buy a telescope. Gonna be in space.",
26+
"According to all known laws of aviation, there is no way bees should be able to fly...",
27+
"You lost the game ",
28+
"Bobby Tables is a good friend of mine",
29+
"Why did the computer cross the road? To get a byte to eat!",
30+
"Why are the astronauts not hungry when they got to space? They had a big launch.",
31+
"Why did the computer get glasses? To improve its web sight!",
32+
"What are computers favorite snacks? Chips!",
33+
"Wait! I think I see a White 2019 Subaru Crosstrek 2.0i Premium",
34+
"IS THAT A SUPRA?!",
35+
"Finally escpaed the LA Traffic",
36+
"My CubeSat is really good at jokes, but its delivery is always delayed.",
37+
"exec order 66",
38+
"I had a joke about UDP, but I am not sure if you'd get it.",
39+
"I am not saying FSK modulation is the best way to send jokes, but at least it is never monotone!",
40+
"I am sorry David, I am afrain I can not do that.",
41+
"My memory is volatile like RAM, so it only makes sense that I forget things.",
42+
"Imagine it gets stuck and just keeps repeating this joke every 2 mins",
43+
"Check Engine: Error Code 404: Joke Not Found",
44+
"CQ CQ KN6NAQ ... KN6NAT are you out there?",
45+
"Woah is that the Launcher Orbiter?????",
46+
"Everything in life is a spring if you think hard enough!",
47+
"Your Mom",
48+
"Your Mum",
49+
"Your Face",
50+
"not True lol",
51+
"I have brought peace, freedom, justice, and security to my new empire! Your New Empire?"
52+
],
53+
"last_battery_temp": 20.0,
54+
"longest_allowable_sleep_time": 600,
55+
"normal_battery_temp": 1,
56+
"normal_battery_voltage": 6.9,
57+
"normal_charge_current": 0.5,
58+
"normal_micro_temp": 20,
59+
"normal_temp": 20,
60+
"radio": {
61+
"fsk": {
62+
"broadcast_address": 255,
63+
"modulation_type": 0,
64+
"node_address": 1
65+
},
5966
"license": "KK4PDM",
67+
"lora": {
68+
"ack_delay": 0.2,
69+
"coding_rate": 8,
70+
"cyclic_redundancy_check": true,
71+
"max_output": true,
72+
"spreading_factor": 8,
73+
"transmit_power": 23
74+
},
6075
"modulation": "LoRa",
6176
"receiver_id": 250,
6277
"sender_id": 251,
6378
"start_time": 80000,
64-
"transmit_frequency": 437.4,
65-
"lora": {
66-
"ack_delay": 0.2,
67-
"coding_rate": 8,
68-
"cyclic_redundancy_check": true,
69-
"max_output": true,
70-
"spreading_factor": 8,
71-
"transmit_power": 23
72-
},
73-
"fsk": {
74-
"broadcast_address": 255,
75-
"node_address": 1,
76-
"modulation_type": 0
77-
}
78-
},
79-
"super_secret_code": "ABCD",
80-
"repeat_code": "RP",
81-
"joke_reply": [
82-
"Your Mom",
83-
"Your Mum",
84-
"Your Face",
85-
"not True lol",
86-
"I have brought peace, freedom, justice, and security to my new empire! Your New Empire?"
87-
]
79+
"transmit_frequency": 437.4
80+
},
81+
"reboot_time": 3600,
82+
"repeat_code": "RP",
83+
"sleep_duration": 30,
84+
"super_secret_code": "ABCD",
85+
"turbo_clock": false
8886
}

flight-software/src/main.py

Lines changed: 9 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import gc
1212
import os
13-
import random
1413
import time
1514

1615
import digitalio
@@ -32,7 +31,7 @@
3231
from lib.pysquared.hardware.magnetometer.manager.lis2mdl import LIS2MDLManager
3332
from lib.pysquared.hardware.radio.manager.rfm9x import RFM9xManager
3433
from lib.pysquared.hardware.radio.packetizer.packet_manager import PacketManager
35-
from lib.pysquared.logger import Logger
34+
from lib.pysquared.logger import Logger, LogLevel
3635
from lib.pysquared.nvm.counter import Counter
3736
from lib.pysquared.rtc.manager.microcontroller import MicrocontrollerManager
3837
from lib.pysquared.sleep_helper import SleepHelper
@@ -49,6 +48,7 @@
4948
logger: Logger = Logger(
5049
error_counter=error_count,
5150
colorized=False,
51+
log_level=LogLevel.INFO,
5252
)
5353

5454
logger.info(
@@ -119,93 +119,25 @@
119119
boot_count,
120120
)
121121

122-
def initial_boot():
123-
watchdog.pet()
124-
beacon.send()
125-
watchdog.pet()
126-
cdh.listen_for_commands()
127-
watchdog.pet()
128-
129-
try:
130-
logger.info(
122+
def nominal_power_loop():
123+
logger.debug(
131124
"FC Board Stats",
132125
bytes_remaining=gc.mem_free(),
133126
)
134127

135-
initial_boot()
136-
137-
except Exception as e:
138-
logger.error("Error in Boot Sequence", e)
139-
140-
finally:
141-
pass
142-
143-
def main():
144-
radio.send(config.radio.license.encode("utf-8"))
128+
packet_manager.send(config.radio.license.encode("utf-8"))
145129

146130
beacon.send()
147131

148-
watchdog.pet()
149-
150-
cdh.listen_for_commands()
132+
cdh.listen_for_commands(10)
151133

152134
sleep_helper.safe_sleep(config.sleep_duration)
153135

154-
# TODO(nateinaction): replace me
155-
# f.state_of_health()
156-
157-
cdh.listen_for_commands()
158-
159-
sleep_helper.safe_sleep(config.sleep_duration)
160-
161-
cdh.listen_for_commands()
162-
163-
sleep_helper.safe_sleep(config.sleep_duration)
164-
165-
cdh.listen_for_commands()
166-
167-
sleep_helper.safe_sleep(config.sleep_duration)
168-
169-
packet_manager.send(random.choice(config.jokes).encode("utf-8"))
170-
171-
watchdog.pet()
172-
173-
cdh.listen_for_commands()
174-
175-
sleep_helper.safe_sleep(config.sleep_duration)
176-
177-
# def critical_power_operations():
178-
# initial_boot()
179-
# watchdog.pet()
180-
181-
# sleep_helper.long_hibernate()
182-
183-
# def minimum_power_operations():
184-
# initial_boot()
185-
# watchdog.pet()
186-
187-
# sleep_helper.short_hibernate()
188-
189-
######################### MAIN LOOP ##############################
190136
try:
137+
logger.info("Entering main loop")
191138
while True:
192-
# L0 automatic tasks no matter the battery level
193-
# TODO(nateinaction): reemplement power level check when we have state of health
194-
# c.check_reboot()
195-
196-
# if c.power_mode == "critical":
197-
# critical_power_operations()
198-
199-
# elif c.power_mode == "minimum":
200-
# minimum_power_operations()
201-
202-
# elif c.power_mode == "normal":
203-
# main()
204-
205-
# elif c.power_mode == "maximum":
206-
# main()
207-
208-
main()
139+
# TODO(nateinaction): Modify behavior based on power state
140+
nominal_power_loop()
209141

210142
except Exception as e:
211143
logger.critical("Critical in Main Loop", e)

ground-station/src/repl.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
import board
88

99
from lib.proveskit_rp2040_v4.register import Register
10+
from lib.pysquared.cdh import CommandDataHandler
1011
from lib.pysquared.config.config import Config
1112
from lib.pysquared.hardware.busio import _spi_init
1213
from lib.pysquared.hardware.digitalio import initialize_pin
1314
from lib.pysquared.hardware.radio.manager.rfm9x import RFM9xManager
1415
from lib.pysquared.hardware.radio.packetizer.packet_manager import PacketManager
1516
from lib.pysquared.logger import Logger
1617
from lib.pysquared.nvm.counter import Counter
18+
from lib.pysquared.repl.radio_test import RadioTest
1719

1820
logger: Logger = Logger(
1921
error_counter=Counter(index=Register.error_count),
@@ -43,7 +45,17 @@
4345
0.2,
4446
)
4547

46-
while True:
47-
bytes = packet_manager.listen(3)
48-
if bytes is not None:
49-
logger.info(f"Received {len(bytes)} bytes: {bytes.hex()}")
48+
cdh = CommandDataHandler(
49+
logger,
50+
config,
51+
packet_manager,
52+
)
53+
54+
radio_test = RadioTest(
55+
logger,
56+
config,
57+
packet_manager,
58+
cdh,
59+
)
60+
61+
radio_test.run()

0 commit comments

Comments
 (0)