flipped '\n' and char storing statement, to not write '\n' into buffer and then overwriting it with '\0'

This commit is contained in:
ti_mo
2026-06-05 00:41:30 +02:00
parent bb0afd41a3
commit ea308bac29
2 changed files with 12 additions and 10 deletions
+8 -7
View File
@@ -73,6 +73,14 @@ static void read_serial_line_task(void *params){
continue;
}
if(c == '\n'){
buf[it] = '\0';
it = 0;
xQueueSendToBack(serial_queue, buf, portMAX_DELAY);
continue;
}
if(it < MAX_COMMAND_LENGTH - 1){
buf[it++] = (char)c;
}
@@ -80,13 +88,6 @@ static void read_serial_line_task(void *params){
printf_sync("Command too long, discarding\n");
it = 0;
}
if(c == '\n'){
buf[it] = '\0';
it = 0;
xQueueSendToBack(serial_queue, buf, portMAX_DELAY);
}
}
}