projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos: Compute "real" RSSI value in radio code as needed
[fw/altos]
/
src
/
core
/
ao_cmd.c
diff --git
a/src/core/ao_cmd.c
b/src/core/ao_cmd.c
index 14cb7569b5df9b0e9840afc8d494cccd5f1386ba..6eed08d91931a401da9d4c325e9f3f34b247eb1a 100644
(file)
--- a/
src/core/ao_cmd.c
+++ b/
src/core/ao_cmd.c
@@
-28,20
+28,26
@@
static __xdata char cmd_line[CMD_LEN];
static __pdata uint8_t cmd_len;
static __pdata uint8_t cmd_i;
static __pdata uint8_t cmd_len;
static __pdata uint8_t cmd_i;
-
static
void
-put_string(__code char *s)
+void
+
ao_
put_string(__code char *s)
{
char c;
while ((c = *s++))
putchar(c);
}
{
char c;
while ((c = *s++))
putchar(c);
}
+static void
+backspace(void)
+{
+ ao_put_string ("\010 \010");
+}
+
static void
readline(void)
{
static void
readline(void)
{
-
__pdata
char c;
+ char c;
if (ao_echo())
if (ao_echo())
- put_string("> ");
+
ao_
put_string("> ");
cmd_len = 0;
for (;;) {
flush();
cmd_len = 0;
for (;;) {
flush();
@@
-50,7
+56,7
@@
readline(void)
if (c == '\010' || c == '\177') {
if (cmd_len != 0) {
if (ao_echo())
if (c == '\010' || c == '\177') {
if (cmd_len != 0) {
if (ao_echo())
-
put_string("\010 \010"
);
+
backspace(
);
--cmd_len;
}
continue;
--cmd_len;
}
continue;
@@
-60,7
+66,7
@@
readline(void)
if (c == '\025') {
while (cmd_len != 0) {
if (ao_echo())
if (c == '\025') {
while (cmd_len != 0) {
if (ao_echo())
-
put_string("\010 \010"
);
+
backspace(
);
--cmd_len;
}
continue;
--cmd_len;
}
continue;
@@
-76,11
+82,8
@@
readline(void)
break;
}
break;
}
- if (cmd_len >= CMD_LEN - 2) {
- if (ao_echo())
- putchar('\007');
+ if (cmd_len >= CMD_LEN - 2)
continue;
continue;
- }
cmd_line[cmd_len++] = c;
if (ao_echo())
putchar(c);
cmd_line[cmd_len++] = c;
if (ao_echo())
putchar(c);
@@
-107,6
+110,22
@@
putnibble(uint8_t v)
putchar(v + ('a' - 10));
}
putchar(v + ('a' - 10));
}
+uint8_t
+ao_getnibble(void)
+{
+ char c;
+
+ c = getchar();
+ if ('0' <= c && c <= '9')
+ return c - '0';
+ if ('a' <= c && c <= 'f')
+ return c - ('a' - 10);
+ if ('A' <= c && c <= 'F')
+ return c - ('A' - 10);
+ ao_cmd_status = ao_cmd_lex_error;
+ return 0;
+}
+
void
ao_cmd_put16(uint16_t v)
{
void
ao_cmd_put16(uint16_t v)
{
@@
-246,16
+265,34
@@
ao_reboot(void)
static void
version(void)
{
static void
version(void)
{
- printf("manufacturer %s\n", ao_manufacturer);
- printf("product %s\n", ao_product);
- printf("serial-number %u\n", ao_serial_number);
+ printf("manufacturer %s\n"
+ "product %s\n"
+ "serial-number %u\n"
+#if HAS_FLIGHT
+ "current-flight %u\n"
+#endif
+#if HAS_LOG
+ "log-format %u\n"
+#endif
+ , ao_manufacturer
+ , ao_product
+ , ao_serial_number
+#if HAS_FLIGHT
+ , ao_flight_number
+#endif
#if HAS_LOG
#if HAS_LOG
- printf("log-format %u\n", ao_log_format);
+ , ao_log_format
+#endif
+ );
+#if HAS_MS5607
+ ao_ms5607_info();
#endif
printf("software-version %s\n", ao_version);
}
#endif
printf("software-version %s\n", ao_version);
}
+#ifndef NUM_CMDS
#define NUM_CMDS 11
#define NUM_CMDS 11
+#endif
static __code struct ao_cmds *__xdata (ao_cmds[NUM_CMDS]);
static __pdata uint8_t ao_ncmds;
static __code struct ao_cmds *__xdata (ao_cmds[NUM_CMDS]);
static __pdata uint8_t ao_ncmds;
@@
-263,16
+300,25
@@
static __pdata uint8_t ao_ncmds;
static void
help(void)
{
static void
help(void)
{
- register uint8_t cmds;
- register uint8_t cmd;
- register __code struct ao_cmds * cs;
+ __pdata uint8_t cmds;
+ __pdata uint8_t cmd;
+ __code struct ao_cmds * __pdata cs;
+ __code const char *h;
+ uint8_t e;
for (cmds = 0; cmds < ao_ncmds; cmds++) {
cs = ao_cmds[cmds];
for (cmds = 0; cmds < ao_ncmds; cmds++) {
cs = ao_cmds[cmds];
- for (cmd = 0; cs[cmd].func; cmd++)
- printf("%-45s %s\n",
- cs[cmd].help,
- cs[cmd].help+1+strlen(cs[cmd].help));
+ for (cmd = 0; cs[cmd].func; cmd++) {
+ h = cs[cmd].help;
+ ao_put_string(h);
+ e = strlen(h);
+ h += e + 1;
+ e = 45 - e;
+ while (e--)
+ putchar(' ');
+ ao_put_string(h);
+ putchar('\n');
+ }
}
}
}
}
@@
-300,7
+346,7
@@
ao_cmd_register(__code struct ao_cmds *cmds)
void
ao_cmd(void)
{
void
ao_cmd(void)
{
- char c;
+
__pdata
char c;
uint8_t cmd, cmds;
__code struct ao_cmds * __xdata cs;
void (*__xdata func)(void);
uint8_t cmd, cmds;
__code struct ao_cmds * __xdata cs;
void (*__xdata func)(void);
@@
-336,8
+382,8
@@
__xdata struct ao_task ao_cmd_task;
__code struct ao_cmds ao_base_cmds[] = {
{ help, "?\0Help" },
__code struct ao_cmds ao_base_cmds[] = {
{ help, "?\0Help" },
- { ao_task_info, "T\0
Show t
asks" },
- { echo, "E <0 off, 1 on>\0
Set echo mode
" },
+ { ao_task_info, "T\0
T
asks" },
+ { echo, "E <0 off, 1 on>\0
Echo
" },
{ ao_reboot, "r eboot\0Reboot" },
{ version, "v\0Version" },
{ 0, NULL },
{ ao_reboot, "r eboot\0Reboot" },
{ version, "v\0Version" },
{ 0, NULL },