Skip to content

Commit

Permalink
Merge pull request #17 from oresat/si-restart
Browse files Browse the repository at this point in the history
si41xx restart and beacon
  • Loading branch information
ryanpdx authored Jan 6, 2024
2 parents 90f6bea + dfdbce7 commit 7ca55f6
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion oresat_c3/services/radios.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ def __init__(self, mock_hw: bool = False):
)

# gpio pins
self._si41xx_nlock_gpio = Gpio("LBAND_LO_nLOCKED", mock_hw)
self._uhf_tot_ok_gpio = Gpio("UHF_TOT_OK", mock_hw)
if mock_hw:
self._si41xx_nlock_gpio._mock_value = 0
self._uhf_tot_ok_gpio._mock_value = 1
self._uhf_tot_clear_gpio = Gpio("UHF_TOT_CLEAR", mock_hw)
self._radio_enable_gpio = Gpio("RADIO_ENABLE", mock_hw)
Expand Down Expand Up @@ -74,7 +76,10 @@ def on_loop(self):
logger.error("tot okay was low, resetting radios")
self.disable()
self.enable()

if not self.is_si41xx_locked:
logger.error("si41xx unlocked, resetting lband synth")
self._si41xx.stop()
self._si41xx.start()
recv = self._recv_edl_request()
if recv:
self.recv_queue.append(recv)
Expand Down Expand Up @@ -124,6 +129,15 @@ def is_uhf_tot_okay(self) -> bool:

return bool(self._uhf_tot_ok_gpio.value)

@property
def is_si41xx_locked(self) -> bool:
"""bool: check if the si41xx is locked."""

# si41xx_nlock is active low
state = not bool(self._si41xx_nlock_gpio.value)
self.node.od["lband"]["synth_lock"].value = state
return state

def send_beacon(self, message: bytes):
"""Send a beacon."""

Expand Down

0 comments on commit 7ca55f6

Please sign in to comment.