AnsweredAssumed Answered

    Read string from uart

Question asked by kanimozhi Raju on May 21, 2017
Latest reply on May 22, 2017 by Kerry Zhou

Hi @ kerry,
         with uart receive interrupt i try to read string and compare the string with constant string and process further.But i sent data from app and i received .I am not getting the data when i sent once i have to send 3 times to receive the printf statement .i will attach my code now

/* * File:  receiving data from app * Purpose:  Main * */

#include "common.h"#include "isr.h"

char data[10]="MEASR_TEMP;char testdata[10];char rec[10];uint8 s_flag=0;uint8 i=0;

void UART1_isr(void){  if (UART1_S1&UART_S1_RDRF_MASK)  {    while(i<10)    {    testdata[i] = UART1_D;    i++;    }   // printf("%c",testdata);  }   strncpy(rec,testdata,10);  if((strncmp(rec,data,10)==0))  {    uint8 s_flag=1;  }}

void main (void){   printf("kiosk implementation\n");   UART1_C2 |= UART_C2_RIE_MASK ;  // UART1_D=testdata;   enable_irq(47);   while(1)   {     if(s_flag==1)     {       printf("spo2");       printf("level:\n");     }   } }