Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
shell_arch.c
Go to the documentation of this file.
1/*
2 * Copyright (C) Alexandre Bustico <alexandre.bustico@enac.fr>
3 *
4 * This file is part of paparazzi
5 *
6 * paparazzi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * paparazzi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with paparazzi; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 */
20
26#include "modules/core/shell.h"
28#include "mcu_periph/uart.h"
29#include "printf.h"
30#include "modules/core/abi.h"
32
33/*************************
34 * Basic static commands *
35 *************************/
36
37static void cmd_mem(BaseSequentialStream *lchp, int argc, const char *const argv[])
38{
39 size_t n, total, largest, core_free;
40
41 (void)argv;
42 if (argc > 0) {
43 chprintf(lchp, "Usage: mem\r\n");
44 return;
45 }
48 chprintf(lchp, "core free memory : %u bytes\r\n", core_free);
49 chprintf(lchp, "heap fragments : %u\r\n", n);
50 chprintf(lchp, "heap free total : %u bytes\r\n", total);
51 chprintf(lchp, "heap free largest: %u bytes\r\n", largest);
52}
53
54static void cmd_abi(BaseSequentialStream *lchp, int argc, const char *const argv[])
55{
56 (void)argv;
57 if (argc > 0) {
58 chprintf(lchp, "Usage: abi\r\n");
59 return;
60 }
61
62 chprintf(lchp, "ABI message bindings\r\n");
63 for (int i = 0; i < ABI_MESSAGE_NB; i++) {
64 chprintf(lchp, " msg %d: ", i);
65 if (abi_queues[i] == NULL) {
66 chprintf(lchp, "no bindings\r\n");
67 } else {
68 abi_event *e;
69 ABI_FOREACH(abi_queues[i], e) {
70 chprintf(lchp, "(cb 0x%lx, id %d), ", e->cb, e->id);
71 }
72 chprintf(lchp, "\r\n");
73 }
74 }
75}
76
77static const ShellCommand commands[] = {
78 {"mem", cmd_mem},
79 {"abi", cmd_abi},
80 {NULL, NULL}
81};
82
84 NULL,
86};
87
95
96
100{
101 // This should be called after mcu periph init
103
104 shellInit();
106 if (shelltp == NULL) {
107 chSysHalt("fail starting shell");
108 }
109}
Main include for ABI (AirBorneInterface).
abi_callback cb
Definition abi_common.h:70
uint8_t id
Definition abi_common.h:69
#define ABI_FOREACH(head, el)
Macros for linked list.
Definition abi_common.h:76
Event structure to store callbacks in a linked list.
Definition abi_common.h:68
BaseSequentialStream * sc_channel
I/O channel associated to the shell.
void shellInit(void)
Shell manager initialization.
Custom command entry type.
Shell descriptor type.
void chprintf(BaseSequentialStream *lchp, const char *fmt,...)
Definition printf.c:395
uint16_t foo
Definition main_demo5.c:58
Simple CLI shell header.
Mini printf-like functionality.
void() shell_cmd_t(shell_stream_t *stream, int argc, const char *const argv[])
Command handler.
Definition shell.h:37
void shell_init_arch(void)
Arch init.
Definition shell_arch.c:99
static void cmd_mem(BaseSequentialStream *lchp, int argc, const char *const argv[])
Definition shell_arch.c:37
static const ShellCommand commands[]
Definition shell_arch.c:77
static ShellConfig shell_cfg
Definition shell_arch.c:83
void shell_add_entry(char *cmd_name, shell_cmd_t *cmd)
Add dynamic entry.
Definition shell_arch.c:91
static void cmd_abi(BaseSequentialStream *lchp, int argc, const char *const argv[])
Definition shell_arch.c:54
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
arch independent USB API