37
dle and etx bytes:
Software written to receive the two records should filter dle and etx bytes as described below:
typedef enum
{
dat,
dle,
etx
} rx_state_type;
char
in_que[256];
int
in_que_ptr = 0;
rx_state_type
rx_state = dat;
void add_to_que( char data )
{
#define
dle_byte 0x10
#define
etx_byte 0x03
if (rx_state == dat)
{
if (data == dle_byte)
{
rx_state = dle;
}
else
{
in_que[ in_+ ] = data;
}
}
else if (rx_state == dle)
{
if (data == etx_byte)
{
rx_state = etx;
}
else
{
rx_state = dat;
in_que[ in_+ ] = data;
}
}
else if (rx_state == etx)
{
if (data == dle_byte)
{
rx_state = dle;
}
}
if (in_que_ptr > 255)
{
in_que_ptr = 0;
}
}