// SLIP parse a single character static void ICACHE_FLASH_ATTR slip_parse_char(char c) { if (!slip_inpkt) { if (c == SLIP_START) { if (slip_len > 0) console_process(slip_buf, slip_len); slip_reset(); slip_inpkt = true; DBG("SLIP: start\n"); return; } } else if (slip_escaped) { // prev char was SLIP_REPL c = SLIP_ESC(c); slip_escaped = false; } else { switch (c) { case SLIP_REPL: slip_escaped = true; return; case SLIP_END: // end of packet, process it and get ready for next one if (slip_len > 0) slip_process(); slip_reset(); return; case SLIP_START: os_printf("SLIP: got SLIP_START while in packet?\n"); //os_printf("SLIP: rcv %d:", slip_len); //for (int i=0; i<slip_len; i++) os_printf(" %02x", slip_buf[i]); //os_printf("\n"); slip_reset(); return; } } if (slip_len < SLIP_MAX) slip_buf[slip_len++] = c; }
static void ICACHE_FLASH_ATTR CMD_ProtoWrite(uint8_t data) { switch(data){ case SLIP_START: case SLIP_END: case SLIP_REPL: uart0_write_char(SLIP_REPL); uart0_write_char(SLIP_ESC(data)); break; default: uart0_write_char(data); } }
void ESP::write(uint8_t data) { switch(data){ case SLIP_START: case SLIP_END: case SLIP_REPL: _serial->write(SLIP_REPL); _serial->write(SLIP_ESC(data)); break; default: _serial->write(data); } }