I’m receiving bytes from the USART and put them in the memory register. The bytes are the commands I have to read and reply with messages accordingly. As I know how to compare a single byte, would suggest me an algorithm to compare multiple bytes.
For example, the received bytes looks like this in hex 16 04 32 01 00 32. They are with different length, so the comparison would be more difficult.
You only need to compare enough bytes to distinctly recognize what kind of message it is (the actual data payload you don’t need to care about in this first step). For most serial protocols it’s just a single byte at a specified position.
By looking at your example message, I’m guessing the first byte is the message type and the second the length of the data payload. If that’s the case then you don’t need to check more than that first byte and jump accordingly. This is mostly done through a jump-table indexed with the message type (that first byte).
The function handling the actual message data payload can do whatever it want to do with the data, but you don’t need to check the complete message just to find out what to do with the message.