This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Best way to parse a UART string with FIFO?

I've got my UART (with fifo) functioning, and now I need to read in a string and determine whether to act upon it or not.

I'm using the s110 softdevice, and I found a BLE/UART example where the UART read into a buffer seems to be done in the main for loop alongside power_manage(). Surely this should be done as a response to a APP_UART_DATA_READY event though?

Basically I'm stuck now. I need to identify this string: $FMS1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 from amongst some other transmissions and extract the first data value from it.

What would be the best way to go about this?

Here's the relevant part of my software so far:

unsigned char buffer[10];
char start= '$';

static void fifo_handler(void)
{
	
	//How would I read the rest of the fifo buffer here?

}

/**
 * @brief UART events handler.
 */
static void uart_events_handler(app_uart_evt_t * p_event)
{

    switch (p_event->evt_type)
    {
        case APP_UART_COMMUNICATION_ERROR:
            APP_ERROR_HANDLER(p_event->data.error_communication);
            break;

        case APP_UART_FIFO_ERROR:
            APP_ERROR_HANDLER(p_event->data.error_code);
            break;
		
		case APP_UART_DATA_READY:
			if(app_uart_get(&buffer[0]) == NRF_SUCCESS)
			{
				if(buffer[0] == start) // Handle the transmission if it begins with $
					fifo_handler();
				}
			// Update SR data
			break;

        default:
            break;		
    }

}
Parents Reply Children
No Data
Related