Simple C program for detecting the start of a message

Status
Not open for further replies.

tom_hanks

Full Member level 5
Joined
Aug 28, 2003
Messages
243
Helped
14
Reputation
28
Reaction score
1
Trophy points
1,298
Activity points
1,571
Hi,
I want to detect the incoming string with following message......

"01,F0,F1" as a start of message flag....

i am storing the incoming data in
static char comm[128];

can any one, guide me, to detect the start of message ?

TIA,
tom
 

Re: simple C program ?

you can input the message on a character by character basis
using getchar()

and keep a check when is the getchar() first being called
for that case write the printf function with what you wish to display
 

simple C program ?

#include <conio.h>
main()
{
char c=0;
static char comm[128];

c=getche();

if (c==0x01)
{
c=getche();
if (c==0xF0)
{
c=getche();
if (c==0xF1)
{
for (char i=0;i<128;i++)
{
c=getche();
comm=c;
}
}
}
}
}
 

simple C program ?

The SLIP protocol is good for this sort of thing and quite easy to impliment.
Just type slip into google, look for 'Serial Line Internet Protocol'
 

simple C program ?

take input character by character then check it by if statements if mached then print what you want
 

Re: simple C program ?

I would say, depending on the type of machine, XOR can be used. Just XOR the incoming signal with the FLAG and if the result is Zero thats the FLAG.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…