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
@@ -240,6 +240,12 @@ void isr_serial(void) __interrupt(4)
|
||||
}
|
||||
|
||||
|
||||
/* Set by the httpd while it runs a command that arrived over the network, so
|
||||
* that everything the command prints lands in the response as well. */
|
||||
__xdata uint8_t cmd_capture;
|
||||
extern __xdata uint8_t outbuf[TCP_OUTBUF_SIZE];
|
||||
extern __xdata uint16_t slen;
|
||||
|
||||
void write_char_no_syslog(char c)
|
||||
{
|
||||
do {
|
||||
@@ -256,6 +262,9 @@ void write_char_no_syslog(char c)
|
||||
|
||||
void write_char(char c)
|
||||
{
|
||||
if (cmd_capture && slen < TCP_OUTBUF_SIZE - 1)
|
||||
outbuf[slen++] = c;
|
||||
|
||||
write_char_no_syslog(c);
|
||||
|
||||
if (syslog_state.enabled) {
|
||||
|
||||
Reference in new issue
Block a user