diff options
author | Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com> | 2024-03-05 01:05:31 -0300 |
---|---|---|
committer | Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com> | 2024-03-08 06:51:34 -0300 |
commit | 35c0a4be8776779cf44648db061d7f854627ccc1 (patch) | |
tree | 5626ec6a8596dd497ce198eeee4ad0bcf4858149 /movement/movement.c | |
parent | 592e18bf0eabfa0dd37a53ce66de5ca29ceef747 (diff) | |
parent | 5b762d016841acb3cefa60f05e963711f0a3eb2b (diff) | |
download | Sensor-Watch-35c0a4be8776779cf44648db061d7f854627ccc1.tar.gz Sensor-Watch-35c0a4be8776779cf44648db061d7f854627ccc1.tar.bz2 Sensor-Watch-35c0a4be8776779cf44648db061d7f854627ccc1.zip |
Merge branch 'usb-improvements' into advanced
- Change newline prints to also send carriage return
- Introduce shell module for serial shell with argument parsing
- Introduce shell command list for compile time command registration
- Refactor file system commands for shell subsystem
- Introduce new shell commands:
- 'help' command
- 'flash' command to reset into bootloader
- 'stress' tests CDC serial writes of various lengths
- optional delay parameter
- Harden USB handling
- Hangs less
- Drops fewer inputs
- Circular buffers for both reads and writes
Reported-by: Edward Shin <contact@edwardsh.in>
Tested-by: Edward Shin <contact@edwardsh.in>
Tested-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Tested-on-hardware-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Reviewed-by: James Haggerty <james@gruemail.com>
Reviewed-by: Wesley Aptekar-Cassels <me@wesleyac.com>
Reviewed-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Signed-off-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/344
Diffstat (limited to 'movement/movement.c')
-rw-r--r-- | movement/movement.c | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/movement/movement.c b/movement/movement.c index d780a2f3..dd9270df 100644 --- a/movement/movement.c +++ b/movement/movement.c @@ -33,6 +33,7 @@ #include "watch.h" #include "filesystem.h" #include "movement.h" +#include "shell.h" #ifndef MOVEMENT_FIRMWARE #include "movement_config.h" @@ -561,30 +562,9 @@ bool app_loop(void) { } } - // if we are plugged into USB, handle the file browser tasks + // if we are plugged into USB, handle the serial shell if (watch_is_usb_enabled()) { - char line[256] = {0}; -#if __EMSCRIPTEN__ - // This is a terrible hack; ideally this should be handled deeper in the watch library. - // Alas, emscripten treats read() as something that should pop up an input box, so I - // wasn't able to implement this over there. I sense that this relates to read() being - // the wrong way to read data from USB (like we should be using fgets or something), but - // until I untangle that, this will have to do. - char *received_data = (char*)EM_ASM_INT({ - var len = lengthBytesUTF8(tx) + 1; - var s = _malloc(len); - stringToUTF8(tx, s, len); - return s; - }); - memcpy(line, received_data, min(255, strlen(received_data))); - free(received_data); - EM_ASM({ - tx = ""; - }); -#else - read(0, line, 256); -#endif - if (strlen(line)) filesystem_process_command(line); + shell_task(); } event.subsecond = 0; |