initial command shell implementation
almost all commands are not yet implemented. actual communication hooks are not yet implemented.
This commit is contained in:
33
gat_stand_fw/user/console/commands/about.h
Normal file
33
gat_stand_fw/user/console/commands/about.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* cons_about.h
|
||||
*
|
||||
* Created on: Nov 6, 2024
|
||||
* Author: true
|
||||
*/
|
||||
|
||||
#ifndef USER_SHELL_COMMANDS_ABOUT_H_
|
||||
#define USER_SHELL_COMMANDS_ABOUT_H_
|
||||
|
||||
|
||||
|
||||
static const char about[] = "true's GAT Stand\n"
|
||||
"a device for displaying badge addons\n"
|
||||
"compatible with GAT, SAOv1, SAOv1.69bis standards\n\n"
|
||||
"code and hardware design by true\n"
|
||||
"manual and info at https://basic.truecontrol.org\n\n";
|
||||
|
||||
|
||||
|
||||
void cons_about(int argc, char **argv)
|
||||
{
|
||||
if (!argc) {
|
||||
CONS_PRINT("...just do it.");
|
||||
return;
|
||||
}
|
||||
|
||||
CONS_PRINT(about);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* USER_SHELL_COMMANDS_ABOUT_H_ */
|
||||
25
gat_stand_fw/user/console/commands/cls.h
Normal file
25
gat_stand_fw/user/console/commands/cls.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* cons_cls.h
|
||||
*
|
||||
* Created on: Nov 6, 2024
|
||||
* Author: true
|
||||
*/
|
||||
|
||||
#ifndef USER_SHELL_COMMANDS_CLS_H_
|
||||
#define USER_SHELL_COMMANDS_CLS_H_
|
||||
|
||||
|
||||
|
||||
void cons_cls(int argc, char **argv)
|
||||
{
|
||||
if (!argc) {
|
||||
CONS_PRINT("...clears the screen. just try it.");
|
||||
return;
|
||||
}
|
||||
|
||||
CONS_PRINT("\x1B[2J\x1B[0;0H");
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* USER_SHELL_COMMANDS_CLS_H_ */
|
||||
65
gat_stand_fw/user/console/commands/help.h
Normal file
65
gat_stand_fw/user/console/commands/help.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* cons_help.h
|
||||
*
|
||||
* Created on: Nov 6, 2024
|
||||
* Author: true
|
||||
*/
|
||||
|
||||
#ifndef USER_SHELL_COMMANDS_HELP_H_
|
||||
#define USER_SHELL_COMMANDS_HELP_H_
|
||||
|
||||
|
||||
|
||||
void cons_help_real(int argc, char **argv, command_table_t *p)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (argc < 2) {
|
||||
// print help list
|
||||
if ((shell_flags & 0x02) == 0) {
|
||||
CONS_PRINT("Tip: You only need to use the first two characters ");
|
||||
CONS_PRINT("of a command.\r\n\r\n");
|
||||
shell_flags |= 0x02;
|
||||
}
|
||||
|
||||
while (p->cmd != 0) {
|
||||
if (strlen(p->desc)) {
|
||||
strcpy( console_line, "* ");
|
||||
strncat(console_line, p->cmd, 12);
|
||||
for (i = strlen(console_line); i <= 12; i++) {
|
||||
console_line[i] = 0x20;
|
||||
}
|
||||
console_line[i] = 0x00;
|
||||
strncat(console_line, p->desc, 77);
|
||||
strncat(console_line, "\r\n", 79);
|
||||
console_line[63] = 0;
|
||||
CONS_PRINT(console_line);
|
||||
}
|
||||
p++;
|
||||
}
|
||||
} else {
|
||||
while (p->cmd != 0) {
|
||||
// calling the callback with argc/argv set to 0 should instruct it to print help/usage
|
||||
if (strcmp(argv[1], p->cmd) == 0) {
|
||||
p->go(0, (char **)0);
|
||||
return;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
|
||||
// looks like the command wasn't found
|
||||
strcpy( console_line, "* no help found for command called '");
|
||||
strncat(console_line, argv[1], 60);
|
||||
strncat(console_line, "'\r\n", 62);
|
||||
CONS_PRINT(console_line);
|
||||
}
|
||||
}
|
||||
|
||||
void cons_help(int argc, char **argv)
|
||||
{
|
||||
cons_help_real(argc, argv, (command_table_t *)console_cmdlist);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* USER_SHELL_COMMANDS_HELP_H_ */
|
||||
Reference in New Issue
Block a user