Thanks, you are rightRoberthh wrote: ↑Wed Aug 10, 2022 1:20 pmTo explain that problem. This is the interrupt handler:mp_interrupt_char is a signed int. param.buf is declared at signed char*. So a 0xff in the buffer expands in a comparison with an int to -1. That might explain, why 0xff is missing when mp_interrupt_char is -1. Usually the receive buffer would be set to an unsigned data type. In that case 0xff is expanded to 255, and the compare with -1 fails.Code: Select all
static void uart_rx_intr_handler(UART_Callback_Param_t param) { // handles rx interrupts ringbuf_t *ringbuf = uart_ringbuf + param.port - 1; int* to_dupterm = uart_attached_to_dupterm + param.port - 1; for (uint32_t i=0; i<param.length; i++) { if (param.buf[i] == mp_interrupt_char) { if (*to_dupterm) mp_keyboard_interrupt(); } else ringbuf_put(ringbuf, param.buf[i]); } }
But that is only the first part of the problem. The other part consist in the path of "if (*to_dupterm)...". If that is true, an keyboard interrupt is raised. If that is false, the character from the buffer is NOT put into the ring buffer, but simply discarded.
Actually, at first \x03 are missing and by setting micropython.kbd_intr(-1) helps to get back \x03. but unknowingly, it makes me missed the \xff.
SO I am fixing one problem while creating another problem. By trying micropython.kbd_intr(-2), I missed \xFE. What is your suggestion? I have recompile the python build?