Skip to content

Commit

Permalink
change reset in state service to stop watchdog daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanpdx committed Jan 8, 2024
1 parent 1e5e649 commit 4db00d0
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions oresat_c3/services/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
This handles the main C3 state machine and saving state.
"""

import subprocess
from time import time

import canopen
Expand Down Expand Up @@ -96,6 +97,20 @@ def _on_write_tx_enable(self, data: bool):
logger.info("disabling tx")
self._last_tx_enable_obj.value = 0

def _reset(self):
logger.info("system reset")

result = subprocess.run(
["systemctl", "stop", "oresat-c3-watchdog"],
shell=True,
check=True,
capture_output=True
)

if result.returncode == 0:
logger.error("stopping watchdog app failed, doing a hard reset")
self.node.stop(NodeStop.HARD_RESET)

def _pre_deploy(self):
"""PRE_DEPLOY state method."""

Expand Down Expand Up @@ -135,7 +150,7 @@ def _standby(self):
if self.has_edl_timed_out:
self._c3_state_obj.value = C3State.EDL.value
elif self.has_reset_timed_out:
self.node.stop(NodeStop.HARD_RESET)
self._reset()
elif not self.has_tx_timed_out and self.is_bat_lvl_good:
self._c3_state_obj.value = C3State.BEACON.value

Expand All @@ -145,7 +160,7 @@ def _beacon(self):
if self.has_edl_timed_out:
self._c3_state_obj.value = C3State.EDL.value
elif self.has_reset_timed_out:
self.node.stop(NodeStop.HARD_RESET)
self._reset()
elif self.has_tx_timed_out or not self.is_bat_lvl_good:
self._c3_state_obj.value = C3State.STANDBY.value

Expand Down

0 comments on commit 4db00d0

Please sign in to comment.