11#include " c_pyro_control_observer.h"
22
3+ #include " f_core/os/n_rtos.h"
4+
35#include < cstdio>
46#include < f_core/n_alerts.h>
57#include < zephyr/logging/log.h>
@@ -9,51 +11,59 @@ LOG_MODULE_REGISTER(CPyroControlObserver);
911
1012static void chargeDisableTimerCallback (k_timer* timer) {
1113 auto * observer = static_cast <CPyroControlObserver*>(timer->user_data );
14+
1215 observer->DisableCallback ();
16+ NRtos::ResumeTask (" Networking Task" );
1317}
1418
1519CPyroControlObserver::CPyroControlObserver () {
16- flightLog.Write (" Pyro Controller Observer initialized" );
20+ // flightLog.Write("Pyro Controller Observer initialized");
1721 chargeDisableTimer = CSoftTimer (chargeDisableTimerCallback);
1822 chargeDisableTimer.SetUserData (this );
1923}
2024
2125
2226void CPyroControlObserver::Notify (void * ctx) {
2327 uint8_t pyroCount = 0 ;
28+ LOG_INF (" Notified" );
2429
2530 switch (*static_cast <NAlerts::AlertType*>(ctx)) {
2631 case NAlerts::NOSEOVER :
2732 LOG_INF (" Noseover detected. Deploying charges in one second." );
28- flightLog.Write (" Noseover detected. Deploying charges in one second." );
33+ // flightLog.Write("Noseover detected. Deploying charges in one second.");
2934 // TODO: Settings library for handling deployment timing
3035 k_sleep (K_SECONDS (1 ));
3136
3237 for (auto & [sense, ctrl, led] : pyroTrios) {
33- if (sense.GetPin () == 1 ) {
38+ // if (sense.GetPin() == 1) {
3439 ctrl.SetPin (1 );
3540 led.SetPin (1 );
3641 LOG_INF (" Deployed charge %d" , pyroCount);
37- }
42+ // }
3843 pyroCount++;
3944 }
40- flightLog.Write (" Finished deploying charges" );
45+ // flightLog.Write("Finished deploying charges");
4146 chargeDisableTimer.StartTimer (3000 );
47+ // Must suspend the networking task. If we get a new event, process after we
48+ // process the last one. Otherwise, we can fault during interrupt handling
49+ NRtos::SuspendCurrentTask ();
4250 break ;
4351 default :
4452 break ;
4553 }
4654
47- flightLog.Sync ();
55+
56+ // flightLog.Sync();
4857}
4958
5059void CPyroControlObserver::DisableCallback () {
60+ chargeDisableTimer.StopTimer ();
5161 int pyroCount = 0 ;
5262 for (auto & [sense, ctrl, led] : pyroTrios) {
5363 ctrl.SetPin (0 );
5464 led.SetPin (0 );
5565 LOG_INF (" Disabled charge %d" , pyroCount);
5666 pyroCount++;
5767 }
58- flightLog.Write (" Finished disabling charges" );
68+ // flightLog.Write("Finished disabling charges");
5969}
0 commit comments