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
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user