mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
Defer cmd execution for console and via http POST
This commit is contained in:
@@ -48,6 +48,7 @@ __xdata uint8_t hexvalue[4] = { 0 };
|
|||||||
|
|
||||||
// Buffer for writing to flash 0x1fd000, copy to 0x1fe000
|
// Buffer for writing to flash 0x1fd000, copy to 0x1fe000
|
||||||
__xdata uint8_t cmd_buffer[SBUF_SIZE];
|
__xdata uint8_t cmd_buffer[SBUF_SIZE];
|
||||||
|
__xdata uint8_t cmd_available;
|
||||||
|
|
||||||
__xdata uint8_t l;
|
__xdata uint8_t l;
|
||||||
__xdata uint8_t line_ptr;
|
__xdata uint8_t line_ptr;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "rtl837x_common.h"
|
#include "rtl837x_common.h"
|
||||||
|
|
||||||
extern __xdata uint8_t cmd_buffer[SBUF_SIZE];
|
extern __xdata uint8_t cmd_buffer[SBUF_SIZE];
|
||||||
|
extern __xdata uint8_t cmd_available;
|
||||||
|
|
||||||
uint8_t cmd_tokenize(void) __banked;
|
uint8_t cmd_tokenize(void) __banked;
|
||||||
void cmd_parser(void) __banked;
|
void cmd_parser(void) __banked;
|
||||||
|
|||||||
+2
-3
@@ -288,9 +288,8 @@ void handle_post(void)
|
|||||||
while (*p && *p != '\n' && *p != '\r')
|
while (*p && *p != '\n' && *p != '\r')
|
||||||
cmd_buffer[i++] = *p++;
|
cmd_buffer[i++] = *p++;
|
||||||
cmd_buffer[i] = '\0';
|
cmd_buffer[i] = '\0';
|
||||||
|
if (i)
|
||||||
if (i && !cmd_tokenize())
|
cmd_available = 1;
|
||||||
cmd_parser();
|
|
||||||
} else if (is_word(request_path, "upload")) {
|
} else if (is_word(request_path, "upload")) {
|
||||||
print_string("POST upload request\n");
|
print_string("POST upload request\n");
|
||||||
if (!boundary[0]) {
|
if (!boundary[0]) {
|
||||||
|
|||||||
+17
-4
@@ -67,7 +67,6 @@ __xdata volatile uint8_t sbuf_ptr;
|
|||||||
__xdata uint8_t sbuf[SBUF_SIZE];
|
__xdata uint8_t sbuf[SBUF_SIZE];
|
||||||
__xdata uint8_t sfr_data[4];
|
__xdata uint8_t sfr_data[4];
|
||||||
|
|
||||||
extern __xdata uint8_t cmd_buffer[SBUF_SIZE];
|
|
||||||
extern __xdata uint8_t gpio_last_value[8];
|
extern __xdata uint8_t gpio_last_value[8];
|
||||||
|
|
||||||
extern __xdata struct flash_region_t flash_region;
|
extern __xdata struct flash_region_t flash_region;
|
||||||
@@ -1021,6 +1020,13 @@ void idle(void)
|
|||||||
stp_clock--;
|
stp_clock--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Check whether a command is waiting in the cmd_buffer and execute
|
||||||
|
if (cmd_available) {
|
||||||
|
cmd_available = 0;
|
||||||
|
if (!cmd_tokenize())
|
||||||
|
cmd_parser();
|
||||||
|
print_string("\n> ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1805,8 +1811,12 @@ void bootloader(void)
|
|||||||
// printed out the entered characters
|
// printed out the entered characters
|
||||||
__xdata uint8_t l = sbuf_ptr; // We have printed out entered characters until l
|
__xdata uint8_t l = sbuf_ptr; // We have printed out entered characters until l
|
||||||
__xdata uint8_t line_start = sbuf_ptr; // This is where the current line starts
|
__xdata uint8_t line_start = sbuf_ptr; // This is where the current line starts
|
||||||
|
cmd_available = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
while (l != sbuf_ptr) {
|
while (l != sbuf_ptr) {
|
||||||
|
// If the command buffer is currently in use, we cannot copy to it
|
||||||
|
if (cmd_available)
|
||||||
|
break;
|
||||||
write_char(sbuf[l]);
|
write_char(sbuf[l]);
|
||||||
// Check whether there is a full line:
|
// Check whether there is a full line:
|
||||||
if (sbuf[l] == '\n' || sbuf[l] == '\r') {
|
if (sbuf[l] == '\n' || sbuf[l] == '\r') {
|
||||||
@@ -1819,9 +1829,12 @@ void bootloader(void)
|
|||||||
line_start++;
|
line_start++;
|
||||||
line_start &= (SBUF_SIZE - 1);
|
line_start &= (SBUF_SIZE - 1);
|
||||||
cmd_buffer[i] = '\0';
|
cmd_buffer[i] = '\0';
|
||||||
if (i && !cmd_tokenize())
|
// If there is a command we print the prompt after execution
|
||||||
cmd_parser();
|
// otherwise immediately because there is nothing to execute
|
||||||
print_string("\n> ");
|
if (i)
|
||||||
|
cmd_available = 1;
|
||||||
|
else
|
||||||
|
print_string("\n> ");
|
||||||
}
|
}
|
||||||
l++;
|
l++;
|
||||||
l &= (SBUF_SIZE - 1);
|
l &= (SBUF_SIZE - 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user