This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

StrCmp function



I'll try another question - I'm sure it's silly. I have been using the cmdline.c  of driverlib/utils for the concerto F28M35 control card I have, and it doesn't seem to work on user input (although it does when I feed it a static string). I'm fairly sure it must be something to do with the unsigned char v. char casting going on from the uartstdio functions I've been using to get input (UARTgetc()). I've been using the following. It should print out 0 when a result is found. So I iterate through all the characters to see it home in on the correct character, which it does up to -1 or 1, but then gives a spurious number when the cases are equal (instead of zero). Any ideas?

case READ:
//Wait until some user input becomes available
 if (iRxBuf > 0) {
  test = (char) UARTgetc();
  UARTFlushRx();
  g_eState = WRITE;
  UARTprintf((char*) "You entered: \tUCh: %c \tCH: %c \tInt: %d \n\r",
          (unsigned char) test, (char) test, test);
 }
 break;
 case WRITE:
 //Compare entered value to requested value and print out strcmp results
 //Only print out if enough data in buffer
  if (iTxBuf > 100) {
   while (i < 255) {
    res = strcmp(&test, (char*) &i);
    UARTprintf((char*) "Res: %d\t It:%c\t%c\t%d\n\r", res,
            (unsigned char) i, (char) i, i);
    i++;
}

Thanks,

Rik

  • Rik Aspinall said:
      if (iTxBuf > 100) {
       while (i < 255) {
        res = strcmp(&test, (char*) &i);
        UARTprintf((char*) "Res: %d\t It:%c\t%c\t%d\n\r", res,
                (unsigned char) i, (char) i, i);
        i++;
    }

    That doesn't look right at all!

    What is i ?

    What is iTxBuf   ?