Originally Posted by
MiniComa
Could you tell me what is wrong with this code:
What did you expect? What error messages you get?
Code:
unsigned char data[4]={0x00,0x00,0x01,0xb3}; //byte pattern
int i = 0;
while(m->data_len > 100)
{
if (m->payload[i] != 0x00)
{
i++;
} //skipping through bytes until I find 0x00
else
{
if (memcmp(&m->payload[i],data,sizeof(data)) == 0)
{
printf("I frame");
break;
}
}
}
You never change m->data_len inside your while-loop thus you loop infinitely if m->data_len is greater than 100 and never find the pattern you want.
And you should learn to indent your code properly.
Bye, Andreas