UART0 RX interrupt stuck in while loop doesn't allow lwm2m function to run?

Hello,

We want to read external sensor data using uart in lwm2m_client project.

I tried below following code :

static char RX_Data;
static char uart_buf[20];
static char *command1 = "This Is A Test of UART0\r\n";
void uart_cb(struct device *x)
{
uart_irq_update(x);
int data_length = 0;

if (uart_irq_rx_ready(x)) {
data_length = uart_fifo_read(x, uart_buf, sizeof(uart_buf));
uart_buf[data_length] = 0;
printk("%s\r\n", uart_buf);
RX_Data= uart_buf[0];
printk("Recived Data %c\r\n", RX_Data);
}


}

==================================================

struct device *uart = device_get_binding("UART_0");
uart_irq_callback_set(uart, uart_cb);
uart_irq_rx_enable(uart);
printk(" UART0 start!\n");

while (true)
{ //uart_send_str(uart1, command1);
lwm2m_rd_client_start(&client, endpoint_name, flags, rd_client_event);

k_sem_take(&lwm2m_restart, K_FOREVER);

LOG_INF("LwM2M restart requested. The sample will try to"
" re-establish network connection.");

/* Stop the LwM2M engine. */
lwm2m_rd_client_stop(&client, rd_client_event);

/* Try to reconnect to the network. */
ret = lte_lc_offline();
if (ret < 0) {
LOG_ERR("Failed to put LTE link in offline state (%d)", ret);
}

modem_connect();

}

==========================================

In terminal it's waiting for next RX value. which doesn't allow to run other function. how we can run both together?

How we can switch UART0 to UART1? i tried to modified above code but it doesn't work.

Best Regards

Deepak  

Related