mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-10-29 17:54:14 +08:00
Merge pull request #329 from DrDoof/feat/cmd-output
httpd: answer /cmd with what the command printed, and show it in the console tab
This commit is contained in:
7 files changed
+63
-6
No files matched your search
+21
-3
@@ -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_no_syslog() */
|
||||
extern __code uint8_t * __code hex;
|
||||
extern __code struct f_data f_data[];
|
||||
extern __code char * __code mime_strings[];
|
||||
@@ -625,12 +626,29 @@ static void handle_firmware_fragment(__xdata uint8_t *p)
|
||||
|
||||
static void run_cmd_body(__xdata uint8_t *body)
|
||||
{
|
||||
uint16_t hdr_len = strtox(outbuf, HTTP_RESPONCE_TXT);
|
||||
|
||||
slen = hdr_len;
|
||||
cmd_capture = 1;
|
||||
execute_commands(body);
|
||||
if (cmd_capture == 2)
|
||||
slen += strtox(outbuf + slen, CMD_TRUNCATED);
|
||||
cmd_capture = 0;
|
||||
/* Commands that configure something print nothing at all. Saying
|
||||
* so beats an empty body, which reads the same as "nothing ran".
|
||||
* Only on success: a silent failure must not answer with "OK". */
|
||||
if (err_status == ERR_OK && slen == hdr_len)
|
||||
slen += strtox(outbuf + slen, "OK\n");
|
||||
/* On a parse error keep what the parser printed, because that text
|
||||
* is the explanation, and only restate the status. "400 NO" is as
|
||||
* long as "200 OK", so the header does not have to be rebuilt. */
|
||||
if (err_status != ERR_OK) {
|
||||
send_bad_request();
|
||||
return;
|
||||
outbuf[9] = '4';
|
||||
outbuf[10] = '0';
|
||||
outbuf[11] = '0';
|
||||
outbuf[13] = 'N';
|
||||
outbuf[14] = 'O';
|
||||
}
|
||||
send_ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user