Fixes to serial handling in scripts

master
Martin Ger 2018-02-01 09:34:42 +01:00
rodzic b00189ecb5
commit 129476f2d7
6 zmienionych plików z 11 dodań i 9 usunięć

Wyświetl plik

@ -119,7 +119,7 @@ This event happens when the time-of-day stored in the alarm with the given numbe
```
serial
```
This event happens when the "system_output" mode is set to 0 and a carriage return (CR)-terminated string has been received from the serial input. Instead of interpreting it as cli command it is forwarded to the scripting engine. The input value is availabe via the special variable _$this_serial_.
This event happens when the "system_output" mode is set to 0 and a newline (NL)-terminated string has been received from the serial input. Instead of interpreting it as cli command it is forwarded to the scripting engine. The input value witout the trailing newline char is availabe via the special variable _$this_serial_.
```
gpio_interrupt <num> (pullup|nopullup)

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -1,2 +1,2 @@
c08f223b081e1c36aae2ffc8b2ab79ad1949d665 0x00000.bin
11a30e04e0f5e6f04ca7447177992134f7f63976 0x10000.bin
02d95626d108c50c19ec02713b22d6d198edae69 0x00000.bin
7baeec4d28782d8c97a82da9e3be163f641603a0 0x10000.bin

Wyświetl plik

@ -1924,7 +1924,7 @@ int ICACHE_FLASH_ATTR interpreter_serial_input(const char *data, int data_len) {
if (!script_enabled)
return -1;
lang_debug("interpreter_topic_received\r\n");
lang_debug("interpreter_serial_input\r\n");
interpreter_status = SERIAL_INPUT;
interpreter_serial_data = (char *)data;

Wyświetl plik

@ -291,8 +291,9 @@ void ICACHE_FLASH_ATTR con_print(uint8_t *str) {
}
void ICACHE_FLASH_ATTR serial_out(uint8_t *str) {
ringbuf_memcpy_into(console_tx_buffer, str, os_strlen(str));
system_os_post(user_procTaskPrio, SIG_SERIAL_TX, (ETSParam) NULL);
UART_Send(0, str, os_strlen(str));
//ringbuf_memcpy_into(console_tx_buffer, str, os_strlen(str));
//system_os_post(user_procTaskPrio, SIG_SERIAL_TX, (ETSParam) NULL);
}
bool ICACHE_FLASH_ATTR delete_retainedtopics() {
@ -513,11 +514,12 @@ static void ICACHE_FLASH_ATTR user_procTask(os_event_t * events) {
struct espconn *pespconn = (struct espconn *)events->par;
if (pespconn == 0 && system_output == SYSTEM_OUTPUT_NONE) {
int bytes_count = ringbuf_bytes_used(console_rx_buffer);
char data[bytes_count+1];
char data[bytes_count];
ringbuf_memcpy_from(data, console_rx_buffer, bytes_count);
data[bytes_count] = '\0';
// overwrite the trailing '\n'
data[bytes_count-1] = '\0';
#ifdef SCRIPTED
interpreter_serial_input(data, bytes_count);
interpreter_serial_input(data, bytes_count-1);
#endif
} else {
console_handle_command(pespconn);