Skip to content

Commit c981c59

Browse files
committed
Add STR_GET_VALID
1 parent 9cbf9e4 commit c981c59

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/fmt_def.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ extern "C" {
2424
#endif
2525

2626
/* Firmament version information */
27-
#define FMT_VERSION "v1.1.0"
27+
#define FMT_VERSION "v1.1.0"
2828

2929
/* Thread Prority */
3030
#define VEHICLE_THREAD_PRIORITY 3
@@ -89,14 +89,16 @@ typedef int bool;
8989
} \
9090
} while (false)
9191

92-
#define OS_ENTER_CRITICAL rt_enter_critical()
93-
#define OS_EXIT_CRITICAL rt_exit_critical()
94-
#define OS_MALLOC(size) rt_malloc(size)
95-
#define OS_FREE(ptr) rt_free(ptr)
92+
#define OS_ENTER_CRITICAL rt_enter_critical()
93+
#define OS_EXIT_CRITICAL rt_exit_critical()
94+
#define OS_MALLOC(size) rt_malloc(size)
95+
#define OS_FREE(ptr) rt_free(ptr)
9696

97-
#define FMT_ASSERT(exp) RT_ASSERT((exp))
98-
#define FMT_CHECK(func) RT_ASSERT(func == FMT_EOK)
99-
#define RT_CHECK(func) RT_ASSERT(func == RT_EOK)
97+
#define FMT_ASSERT(exp) RT_ASSERT((exp))
98+
#define FMT_CHECK(func) RT_ASSERT(func == FMT_EOK)
99+
#define RT_CHECK(func) RT_ASSERT(func == RT_EOK)
100+
101+
#define STR_GET_VALID(_arr, _idx) (_idx < sizeof(_arr) / sizeof(_arr[0]) ? _arr[_idx] : "invalid")
100102

101103
typedef enum {
102104
FMT_EOK = 0, /**< There is no error */

src/model/fms/mc_fms/fms_interface.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ static int fms_output_echo(void* param)
243243
printf("vel cmd: %.2f %.2f %.2f\n", fms_out.u_cmd, fms_out.v_cmd, fms_out.w_cmd);
244244
printf("throttle cmd: %u\n", fms_out.throttle_cmd);
245245
printf("act cmd: %u %u %u %u\n", fms_out.actuator_cmd[0], fms_out.actuator_cmd[1], fms_out.actuator_cmd[2], fms_out.actuator_cmd[3]);
246-
printf("status:%s state:%s ctrl_mode:%s\n", fms_status[fms_out.status], fms_state[fms_out.state], fms_ctrl_mode[fms_out.ctrl_mode]);
247-
printf("mode:%s reset:%d\n", fms_mode[fms_out.mode], fms_out.reset);
246+
printf("status:%s state:%s ctrl_mode:%s\n", STR_GET_VALID(fms_status, fms_out.status), STR_GET_VALID(fms_state, fms_out.state), STR_GET_VALID(fms_ctrl_mode, fms_out.ctrl_mode));
247+
printf("mode:%s reset:%d\n", STR_GET_VALID(fms_mode, fms_out.mode), fms_out.reset);
248248
printf("wp_current:%d wp_consume:%d\n", fms_out.wp_current, fms_out.wp_consume);
249249
printf("home: xyz(m) %.2f %.2f %.2f yaw(deg) %.2f\n", fms_out.home[0], fms_out.home[1], fms_out.home[2], RAD2DEG(fms_out.home[3]));
250250
printf("lcoal psi:%f\n", fms_out.local_psi);

0 commit comments

Comments
 (0)