mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-10-29 17:54:14 +08:00
httpd: return what a command printed over /cmd
POST /cmd runs the command and answers with an empty 200, so a caller cannot tell "done" from "nothing happened", and whatever the command prints only reaches the serial console. Reading a register over the network needs a second channel just to see the answer. write_char() is the one funnel every console helper goes through, and it already tees into the syslog buffer. A third sink, live only while the httpd runs a command that arrived over the network, puts the same bytes into the response behind the header. Serial and syslog keep getting their copy. The capture stops at the end of the response buffer, so a long listing is truncated rather than overrunning it. BANK1 grows 39 bytes and the common area 52. One byte of xdata, BANK2 unchanged.
This commit is contained in:
1 parent
4c8e0ce975
commit
81af3a29a2
2 files changed
+14
-1
No files matched your search
+5
-1
@@ -21,6 +21,7 @@
|
||||
|
||||
extern volatile __xdata uint8_t sfr_data[4];
|
||||
extern volatile __xdata uint32_t ticks;
|
||||
extern __xdata uint8_t cmd_capture; /* owned by rtlplayground.c, see write_char() */
|
||||
extern __code uint8_t * __code hex;
|
||||
extern __code struct f_data f_data[];
|
||||
extern __code char * __code mime_strings[];
|
||||
@@ -625,12 +626,15 @@ static void handle_firmware_fragment(__xdata uint8_t *p)
|
||||
|
||||
static void run_cmd_body(__xdata uint8_t *body)
|
||||
{
|
||||
slen = strtox(outbuf, "HTTP/1.1 200 OK\r\nConnection: close\r\n" \
|
||||
"Content-Type: text/plain\r\n\r\n");
|
||||
cmd_capture = 1;
|
||||
execute_commands(body);
|
||||
cmd_capture = 0;
|
||||
if (err_status != ERR_OK) {
|
||||
send_bad_request();
|
||||
return;
|
||||
}
|
||||
send_ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user