summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorLoïc Guégan <manzerbredes@mailbox.org>2025-03-24 09:53:41 +0100
committerLoïc Guégan <manzerbredes@mailbox.org>2025-03-24 09:53:41 +0100
commit0aa44015f4501f618280f095b4a4c477e69b3541 (patch)
tree63e1ed4be133e9bffc593c75503d391d5eba9d65 /src/main.c
parent7741f014456df395b655b72d9ebb848af72cc37e (diff)
Clean codeHEADmain
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/main.c b/src/main.c
index b26543d..051449c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -12,10 +12,13 @@ char cmd[64];
char *cmdptr=cmd;
// Execute command from cmd buffer
+// This is a test function which is buggy
void exec(){
- if(!strncmp(cmd, "blink", strlen("exit")))
+ if(cmd == cmdptr)
+ return;
+ else if(!strncmp(cmd, "blink", 5))
gpio_blink_led(1);
- else if(!strncmp(cmd, "help", strlen("help")))
+ else if(!strncmp(cmd, "help", 4))
tty_putstr(HELP);
else if(cmdptr != cmd)
tty_putstr("Unknown command (see help)\n\r");
@@ -30,6 +33,8 @@ void main(){
// REPL
+ // TODO: Handling arrows etc.
+ // Pressing arrow freezes the shell
char c=tty_getchar();
tty_putstr(MOTD);
tty_putstr(PROMPT);
@@ -47,14 +52,12 @@ void main(){
cmdptr--;
}
}
- else{
+ else if(c>=32 && c <= 127){ // Printable char
*cmdptr=c;
cmdptr++;
tty_putchar(c);
}
}
-
-
return;
}