AnsweredAssumed Answered

The best way to compare two buffers

Question asked by Deer90 on Mar 30, 2013
Latest reply on Apr 5, 2013 by petre.mihai
Hello, I´m begineer in programming in C and microcontrollers, so I´m sorry for stupid question. I receive commands via USART. What is the best way to compare RxBuffer with command saved in memory? Now I use comparing single bytes (1.byte with 1.byte, 2.byte with 2.byte,...), but this isn´t good solution(big code,...). Thanks for answers.

uint8_t RxBuffer[100]; // for example RxBuffer[0]=82, RxBuffer[1]=83,
                                      // RxBuffer[2]=84, RxBuffer[3]=10 ...RST\n 
uint8_t IDNcommand[] = "IDN\n";
uint8_t RSTcommand[] = "RST\n"; 
// how to smartly compare these buffers?
// problem: they have different size