Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion app/backplane/deployment_module/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,19 @@
#include "c_deployment_module.h"

#include <f_core/os/n_rtos.h>
#ifdef CONFIG_ARCH_POSIX
#include <signal.h>
#include <nsi_main.h>
#endif

LOG_MODULE_REGISTER(main);

#ifdef CONFIG_ARCH_POSIX
static volatile sig_atomic_t shutdownRequested = 0;

static void NativeSimSignalHandler(int) { shutdownRequested = 1; }
#endif

int main() {
static CDeploymentModule deploymentModule{};

Expand All @@ -19,9 +29,16 @@ int main() {
NRtos::StartRtos();

#ifdef CONFIG_ARCH_POSIX
k_sleep(K_SECONDS(900));
signal(SIGINT, NativeSimSignalHandler);
signal(SIGTERM, NativeSimSignalHandler);

while (!shutdownRequested) {
k_sleep(K_MSEC(100));
}

NRtos::StopRtos();
deploymentModule.Cleanup();
nsi_exit(0);
#endif

return 0;
Expand Down
20 changes: 18 additions & 2 deletions app/backplane/power_module/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,19 @@
#include <f_core/os/c_task.h>
#include <f_core/os/n_rtos.h>
#include <n_autocoder_network_defs.h>
#ifdef CONFIG_ARCH_POSIX
#include <signal.h>
#include <nsi_main.h>
#endif

LOG_MODULE_REGISTER(main);

#ifdef CONFIG_ARCH_POSIX
static volatile sig_atomic_t shutdownRequested = 0;

static void NativeSimSignalHandler(int) { shutdownRequested = 1; }
#endif

int main() {
static CPowerModule powerModule{};

Expand All @@ -22,10 +32,16 @@ int main() {
NRtos::StartRtos();

#ifdef CONFIG_ARCH_POSIX
k_sleep(K_SECONDS(300));
signal(SIGINT, NativeSimSignalHandler);
signal(SIGTERM, NativeSimSignalHandler);

while (!shutdownRequested) {
k_sleep(K_MSEC(100));
}

NRtos::StopRtos();
powerModule.Cleanup();
k_sleep(K_FOREVER);
nsi_exit(0);
#endif

return 0;
Expand Down
19 changes: 18 additions & 1 deletion app/backplane/radio_module/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,19 @@

#include <f_core/os/c_task.h>
#include <f_core/os/n_rtos.h>
#ifdef CONFIG_ARCH_POSIX
#include <signal.h>
#include <nsi_main.h>
#endif

LOG_MODULE_REGISTER(main);

#ifdef CONFIG_ARCH_POSIX
static volatile sig_atomic_t shutdownRequested = 0;

static void NativeSimSignalHandler(int) { shutdownRequested = 1; }
#endif

int main() {
#ifdef CONFIG_LICENSED_FREQUENCY
LOG_INF("Radio module boot: 433 MHz build, callsign=%s", CONFIG_RADIO_MODULE_CALLSIGN);
Expand All @@ -28,8 +38,15 @@ int main() {
NRtos::StartRtos();

#ifdef CONFIG_ARCH_POSIX
k_sleep(K_SECONDS(300));
signal(SIGINT, NativeSimSignalHandler);
signal(SIGTERM, NativeSimSignalHandler);

while (!shutdownRequested) {
k_sleep(K_MSEC(100));
}

NRtos::StopRtos();
nsi_exit(0);
#endif

return 0;
Expand Down
9 changes: 8 additions & 1 deletion app/backplane/sensor_module/boards/sensor_hw_sim.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ CONFIG_OPENROCKET_SENSORS=y
CONFIG_OPENROCKET_DATA_FILE="../../../data/orksim_csv/l1.csv"
CONFIG_OPENROCKET_MS_BEFORE_LAUNCH=10000
CONFIG_OPENROCKET_SCALAR_TYPE_DOUBLE=y
CONFIG_OPENROCKET_EVENT_LOG=n
CONFIG_OPENROCKET_EVENT_LOG=y
CONFIG_OPENROCKET_IMU=y
CONFIG_OPENROCKET_BAROMETER=y
CONFIG_OPENROCKET_MANUAL_LAUNCH_TRIGGER=y

CONFIG_CONSOLE=y
CONFIG_CONSOLE_SUBSYS=y
CONFIG_SERIAL=y
CONFIG_UART_CONSOLE=y

1 change: 0 additions & 1 deletion app/backplane/sensor_module/core.conf
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@ CONFIG_EVENTS=y
CONFIG_I2C=y
CONFIG_SPI=y
CONFIG_SENSOR=y
CONFIG_LSM6DSL_ACCEL_FS=16
24 changes: 24 additions & 0 deletions app/backplane/sensor_module/include/c_ork_toggle_tenant.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include <f_core/net/network/c_ipv4.h>
#include <f_core/net/transport/c_udp_socket.h>
#include <f_core/os/c_runnable_tenant.h>

class COrkToggleTenant : public CRunnableTenant {
public:
/**
* @param name Tenant name
* @param ipStr IP address to bind the UDP socket to
* @param port UDP port used to receive launch trigger packets
*/
COrkToggleTenant(const char* name, const char* ipStr, int port);

/**
* See parent docs
*/
void Run() override;

private:
CUdpSocket udp;
int port;
};
9 changes: 9 additions & 0 deletions app/backplane/sensor_module/include/c_sensor_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

#include "c_sensing_tenant.h"
#include "flight.hpp"
#ifdef CONFIG_OPENROCKET_MANUAL_LAUNCH_TRIGGER
#include "c_ork_toggle_tenant.h"
#endif

// F-Core Includes
#include <f_core/c_project_configuration.h>
Expand Down Expand Up @@ -50,6 +53,9 @@ class CSensorModule : public CProjectConfiguration {
static constexpr int telemetryBroadcastPort = NNetworkDefs::SENSOR_MODULE_TELEMETRY_PORT;
static constexpr int telemetryDownlinkPort = NNetworkDefs::SENSOR_MODULE_DOWNLINK_DATA_PORT;
static constexpr int alertPort = NNetworkDefs::ALERT_PORT;
#ifdef CONFIG_OPENROCKET_MANUAL_LAUNCH_TRIGGER
static constexpr int orkLaunchTriggerPort = NNetworkDefs::SENSOR_MODULE_ORK_LAUNCH_TRIGGER_PORT;
#endif

// Devices
CRtc rtc{*DEVICE_DT_GET(DT_ALIAS(rtc))};
Expand Down Expand Up @@ -82,6 +88,9 @@ class CSensorModule : public CProjectConfiguration {
sensorDataLogMessagePort,
K_SECONDS(3),
64};
#ifdef CONFIG_OPENROCKET_MANUAL_LAUNCH_TRIGGER
COrkToggleTenant orkLaunchTriggerTenant{"Ork Toggle Tenant", ipAddrStr.c_str(), orkLaunchTriggerPort};
#endif

// Tasks
CTask networkTask{"Networking Task", 15, 3072, 10};
Expand Down
2 changes: 1 addition & 1 deletion app/backplane/sensor_module/sim.conf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Sensors
CONFIG_OPENROCKET_SENSORS=y
CONFIG_OPENROCKET_DATA_FILE="../../../data/orksim_csv/l1.csv"
CONFIG_OPENROCKET_MS_BEFORE_LAUNCH=10000
CONFIG_OPENROCKET_SCALAR_TYPE_DOUBLE=y
CONFIG_OPENROCKET_EVENT_LOG=y
CONFIG_OPENROCKET_IMU=y
CONFIG_OPENROCKET_BAROMETER=y
CONFIG_OPENROCKET_MANUAL_LAUNCH_TRIGGER=y

CONFIG_RTC=y
CONFIG_RTC_EMUL=y
Expand Down
28 changes: 28 additions & 0 deletions app/backplane/sensor_module/src/c_ork_toggle_tenant.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "c_ork_toggle_tenant.h"

#include <errno.h>

#include <f_core/device/openrocket_launch.h>
#include <zephyr/logging/log.h>

LOG_MODULE_REGISTER(COrkToggleTenant);

COrkToggleTenant::COrkToggleTenant(const char* name, const char* ipStr, const int port)
: CRunnableTenant(name), udp(CIPv4(ipStr), port, port), port(port) {}

void COrkToggleTenant::Run() {
uint8_t trigger = 0;
const int ret = udp.ReceiveAsynchronous(&trigger, sizeof(trigger));
if (ret <= 0) {
return;
}

const int err = ork_trigger_launch();
if (err == 0) {
LOG_INF("Received OpenRocket launch trigger on UDP port %d", port);
} else if (err == -EALREADY) {
LOG_WRN("Ignoring duplicate OpenRocket launch trigger on UDP port %d", port);
} else {
LOG_ERR("Failed to trigger OpenRocket launch (%d)", err);
}
}
3 changes: 3 additions & 0 deletions app/backplane/sensor_module/src/c_sensor_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ void CSensorModule::AddTenantsToTasks() {
networkTask.AddTenant(broadcastTenant);
networkTask.AddTenant(downlinkTelemTenant);
networkTask.AddTenant(udpAlertTenant);
#ifdef CONFIG_OPENROCKET_MANUAL_LAUNCH_TRIGGER
networkTask.AddTenant(orkLaunchTriggerTenant);
#endif

// Sensing
sensingTask.AddTenant(sensingTenant);
Expand Down
19 changes: 18 additions & 1 deletion app/backplane/sensor_module/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@
#include "c_sensor_module.h"

#include <f_core/os/n_rtos.h>
#ifdef CONFIG_ARCH_POSIX
#include <signal.h>
#include <nsi_main.h>
#endif

#ifdef CONFIG_ARCH_POSIX
static volatile sig_atomic_t shutdownRequested = 0;

static void NativeSimSignalHandler(int) { shutdownRequested = 1; }
#endif

int main() {
static CSensorModule sensorModule{};
Expand All @@ -17,9 +27,16 @@ int main() {
NRtos::StartRtos();

#ifdef CONFIG_ARCH_POSIX
k_sleep(K_SECONDS(900));
signal(SIGINT, NativeSimSignalHandler);
signal(SIGTERM, NativeSimSignalHandler);

while (!shutdownRequested) {
k_sleep(K_MSEC(100));
}

NRtos::StopRtos();
sensorModule.Cleanup();
nsi_exit(0);
#endif

return 0;
Expand Down
19 changes: 18 additions & 1 deletion app/ground/receiver_module/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,19 @@
#include <f_core/os/n_rtos.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/logging/log.h>
#ifdef CONFIG_ARCH_POSIX
#include <signal.h>
#include <nsi_main.h>
#endif

LOG_MODULE_REGISTER(main);

#ifdef CONFIG_ARCH_POSIX
static volatile sig_atomic_t shutdownRequested = 0;

static void NativeSimSignalHandler(int) { shutdownRequested = 1; }
#endif

int main() {
LOG_INF("Receiver starting");
static CReceiverModule receiverModule{};
Expand All @@ -25,8 +35,15 @@ int main() {
NRtos::StartRtos();

#ifdef CONFIG_ARCH_POSIX
k_sleep(K_SECONDS(300));
signal(SIGINT, NativeSimSignalHandler);
signal(SIGTERM, NativeSimSignalHandler);

while (!shutdownRequested) {
k_sleep(K_MSEC(100));
}

NRtos::StopRtos();
nsi_exit(0);
#endif

return 0;
Expand Down
2 changes: 1 addition & 1 deletion app/payload/control_freak/flight-software/sample.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sample:
description: control_freak
description: Control Freak flight software
name: control_freak
common:
build_only: true
Expand Down
2 changes: 2 additions & 0 deletions data/autocoder_inputs/network_defs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ modules:
id: 3
base_port: 13000
port_offsets:
ork_launch_trigger:
port_number: 999
downlink_data:
port_number: 20
telemetry:
Expand Down
12 changes: 11 additions & 1 deletion drivers/sensor/openrocket/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,21 @@ if OPENROCKET_SENSORS

config OPENROCKET_MS_BEFORE_LAUNCH
int "OpenRocket ms before launch"
depends on OPENROCKET_SENSORS
depends on OPENROCKET_SENSORS && !OPENROCKET_MANUAL_LAUNCH_TRIGGER
default 1000
help
Milliseconds to delay the launch from the device booting.

config OPENROCKET_MANUAL_LAUNCH_TRIGGER
bool "OpenRocket Manual Launch Trigger"
depends on OPENROCKET_SENSORS
default n
help
When enabled, the simulation does not start on a fixed delay after boot.
Instead, sensor reads return pad values until or_trigger_launch() is called
(e.g. from a ground station command). The event log thread also waits for
the trigger before beginning.

config OPENROCKET_NOISE
bool "OpenRocket Sensor Noise"
depends on OPENROCKET_SENSORS
Expand Down
Loading
Loading