Zephyr doesn't have a function that return the number of bytes in the input serial buffer
The feature updateCoefficient requires an end of line character. The actual code handles LF or CR but doesn't handle CRLF. In order to hande CRLF, a function that return the number of bytes in the input serial buffer (like serial.Available in arduino) is required. After looking in the console.h and the zephyr documentation it appears that the only way to do so is to use a UART instance, detailled here : https://docs.zephyrproject.org/latest/hardware/peripherals/uart.html#uart-polling-api An example of NOT TESTED code generated with chatGPT :
#include <zephyr.h>
#include <device.h>
#include <drivers/uart.h>
#define UART_DEVICE_NAME "UART_0"
void main(void)
{
struct device *uart_dev;
bool data_ready;
uint8_t buffer[32];
uart_dev = device_get_binding(UART_DEVICE_NAME);
if (!uart_dev) {
printk("Failed to get UART device\n");
return;
}
data_ready = uart_irq_rx_ready(uart_dev);
if (data_ready) {
int bytes_read = uart_fifo_read(uart_dev, buffer, sizeof(buffer));
printk("Read %d bytes from the serial port\n", bytes_read);
} else {
printk("No data available in the serial buffer\n");
}
}