AnsweredAssumed Answered

SCI Reading(more than 1 char) problem

Question asked by Aaron Lee on Aug 23, 2017
Latest reply on Sep 4, 2017 by Alice_Yang

Hi,

I using AS1_OnRxChar() to read 1char. It work fine.

void AS1_OnRxChar(void)
{
   AS1_TComData ReceiveChar;
// Write your code here ...
   AS1_RecvChar(&ReceiveChar);
   Switch(ReceiveChar)
   {
   case 'C':
      Pin_RCK_Power = 0; // RCK POWER OFF
      break;
   case 'O':
      Pin_RCK_Power = 1; // RCK POWER ON
      break;
   default:
      break;
   }
 return;

}

Now, I want to read more than 1 char. But it still read 1st char only.

void AS1_OnRxCharExt(AS1_TComData Chr)
{
 uint8_tRxStatus;
 uint16_t  ReadSize=128, ReceiveLength, CompareCount, CheckInCount;

   static uint8_t   CheckIn[10]= {0x2f, 0xae, 0x22, 0x1e, 0x8d, 0x01, 0x0d, 0x6e, 0xcb, 0xf0};

 

/* Write your code here ... */
   ReceiveLength = AS1_GetCharsInRxBuf();                     ==> Always return 1, Why?
   RxStatus = AS1_RecvBlock(&Chr, ReadSize, &ReceiveLength);            ==> Retuen 10 (ERR_RXEMPTY)                                                                                                               Chr receive 1st char and ReceiveLength=1 Why?

 

   CompareCount=0;
   CheckInCount=0;
   while(CompareCount<10)
   {
      if(CheckIn[CompareCount++] == Chr++)
         CheckInCount++;
      else
         CompareCount = 10;
   }

 

   if(CompareCount == CheckInCount)
      Pin_RCK_Power = 1; // RCK POWER ON

}

Do you have any recommend?

 

Best Regards,

Aaron

Outcomes