5 Replies Latest reply on Dec 15, 2017 3:32 AM by vartika.s_2281106

    Not able to receive complete data using UART

    vartika.s_2281106

      Hi,

       

      I am using MicroController CY8C4246LTIDM405. I am trying to receive command from Server using USSD and Sim868 GSM module is being used. My problem is if I am sending two data from Server with a time difference of even 1 second, I am able to receive only one data at a time not the other one but I need to receive both of them.  So, I am actually polling for UART data and the logic is something like this:

      while((c = UART_SIM868_UartGetChar()))

                      ATCC_receiveChar(&SIM868, c);

       

      The ATCC_receiveChar function looks something like this:

      void ATCC_receiveChar(ATCC_t *atcc, char c)

      {

      if (atcc->AT_inputPos < ATCC_BUFFER_INPUT)

      atcc->AT_input[atcc->AT_inputPos++] = c;

      if (c == '\n' && atcc->AT_inputPos <= 3)

      atcc->AT_inputPos = 0;

      else if (c == '\n')

      ATCC_inputParse(atcc);

      }

       

      So in the above function, the data will break as soon as' \n'. To receive the second command, I first of all tried to see if it is even able to receive the second command and so to rule it out, I actually put a logic that if two '\n's are received then break . I  added this logic in place of

      else if (c == '\n')

      ATCC_inputParse(atcc); and it was able to receive but because of this logic, I am facing problem in sending data to the server. I don't know how to solve this problem and any leads will be appreciated.

       

      Thanks.