uart: feed rx data to both lua console and on-data callback

This commit is contained in:
Joo Aun Saw 2022-08-29 16:19:46 +10:00 committed by Johny Mattsson
parent a3712ac990
commit 01b94f31dc
2 changed files with 6 additions and 1 deletions

View File

@ -10,6 +10,10 @@
static lua_State *gL = NULL;
bool uart_has_on_data_cb(unsigned id){
return uart_status[id].receive_rf != LUA_NOREF;
}
bool uart_on_data_cb(unsigned id, const char *buf, size_t len){
if(!buf || len==0)
return false;

View File

@ -65,6 +65,7 @@ uart_status_t uart_status[NUM_UART];
task_handle_t uart_event_task_id = 0;
SemaphoreHandle_t sem = NULL;
extern bool uart_has_on_data_cb(unsigned id);
extern bool uart_on_data_cb(unsigned id, const char *buf, size_t len);
extern bool uart_on_error_cb(unsigned id, const char *buf, size_t len);
@ -81,7 +82,7 @@ void uart_event_task( task_param_t param, task_prio_t prio ) {
unsigned used = feed_lua_input(post->data + i, post->size - i);
i += used;
}
else {
if (uart_has_on_data_cb(id)) {
char ch = post->data[i];
us->line_buffer[us->line_position] = ch;
us->line_position++;