STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
test_mode_core.c
Go to the documentation of this file.
1/* mode_core: what is powered in each state, where commands go. */
2#include <stdio.h>
3#include <stdlib.h>
4
5#include "mode_core.h"
6
7#define CHECK(c) \
8 do { \
9 if (!(c)) { \
10 fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, #c); \
11 exit(1); \
12 } \
13 } while (0)
14
17 CHECK(!o.sensors && !o.gps && !o.ethernet);
18 CHECK(o.idle_loop);
19 CHECK(o.radio_sniff); /* Idle saves power: the radio duty-cycles */
20}
21
25 for (unsigned i = 0; i < 3; ++i) {
27 CHECK(o.sensors && o.gps && o.ethernet && !o.idle_loop);
28 CHECK(!o.radio_sniff); /* armed: listen all the time */
29 }
31 CHECK(!s.sensors && !s.idle_loop && !s.radio_sniff);
33 CHECK(!bad.sensors && !bad.gps && !bad.idle_loop);
34}
35
36static void test_commands(void) {
38 /* In Idle the Idle loop (PR #162) owns Arm. */
41 /* Armed: Un-arm goes back to Idle; a second Arm is ignored. */
44 CHECK(next == FLIGHT_IDLE);
46 /* After launch an Un-arm is ignored (flight_state table). */
49}
50
51int main(void) {
55 puts("mode_core: all tests passed");
56 return 0;
57}
flight_state_t
@ FLIGHT_RECOVERY
@ FLIGHT_SELF_TEST
@ FLIGHT_ARMED
@ FLIGHT_IDLE
@ FLIGHT_LAUNCHED
@ FLIGHT_STATE_COUNT
return o
Definition json.hpp:13897
mode_route_t mode_route_command(flight_state_t state, mode_command_t command, flight_state_t *next)
Definition mode_core.c:23
mode_outputs_t mode_outputs(flight_state_t state)
Definition mode_core.c:3
@ MODE_TRANSITION
Definition mode_core.h:47
@ MODE_TO_IDLE_LOOP
Definition mode_core.h:46
@ MODE_IGNORE
Definition mode_core.h:48
@ MODE_CMD_DISARM
Definition mode_core.h:43
@ MODE_CMD_ARM
Definition mode_core.h:43
int main()
#define CHECK(c)
static void test_idle_keeps_only_the_radio(void)
static void test_armed_onwards_runs_everything(void)
static void test_commands(void)