Garmin GPS 18 010-00321-56 Manuale Utente
![Garmin](https://files.manualsbrain.com/attachments/994f895c1fe9ba298f5fc917e3283ea0d22ac77e/common/fit/150/50/527c517f51a09dedc2e7b1a673b0cf7834e289874ec6cfcd6322d2baf6d7/brand_logo.png)
Codici prodotto
010-00321-56
GPS 18 Technical Specifications (190-00307-00)
Rev. D
Page 28
DLE and ETX bytes:
Sample C code to receive the two records should filter DLE and ETX bytes as described below:
typedef enum
{
DAT,
DLE,
ETX
} rx_state_type;
Sample C code to receive the two records should filter DLE and ETX bytes as described below:
typedef enum
{
DAT,
DLE,
ETX
} rx_state_type;
/* Declare and initialize static variables */
static char
static char
in_que[ 256 ];
static int
in_que_ptr = 0;
static rx_state_type rx_state = DAT;
.
.
.
.
.
void add_to_que( char data )
{
#define DLE_BYTE 0x10
#define ETX_BYTE 0x03
{
#define DLE_BYTE 0x10
#define ETX_BYTE 0x03
if ( rx_state == DAT )
{
if ( data == DLE_BYTE )
{
rx_state = DLE;
}
else
{
in_que[ in_que_ptr++ ] = data;
}
}
else if ( rx_state == DLE )
{
if ( data == ETX_BYTE )
{
rx_state = ETX;
}
else
{
rx_state = DAT;
in_que[ in_que_ptr++ ] = data;
}
}
else if ( rx_state == ETX )
{
if ( data == DLE_BYTE )
{
rx_state = DLE;
}
}
{
if ( data == DLE_BYTE )
{
rx_state = DLE;
}
else
{
in_que[ in_que_ptr++ ] = data;
}
}
else if ( rx_state == DLE )
{
if ( data == ETX_BYTE )
{
rx_state = ETX;
}
else
{
rx_state = DAT;
in_que[ in_que_ptr++ ] = data;
}
}
else if ( rx_state == ETX )
{
if ( data == DLE_BYTE )
{
rx_state = DLE;
}
}
if ( in_que_ptr > 255 )
{
in_que_ptr = 0;
}
}
{
in_que_ptr = 0;
}
}