diff --git a/adsbus.c b/adsbus.c index 4a0adaa..485e3a3 100644 --- a/adsbus.c +++ b/adsbus.c @@ -18,6 +18,12 @@ struct opts { char *backend_service; }; +typedef bool (*parser)(struct buf *, struct packet *); +static parser parsers[] = { + airspy_adsb_parse, +}; +#define NUM_PARSERS (sizeof(parsers) / sizeof(*parsers)) + static int parse_opts(int argc, char *argv[], struct opts *opts) { int opt; @@ -128,7 +134,7 @@ static int loop(int bfd) { } struct packet packet; - while (airspy_adsb_parse(&buf, &packet)) { + while (parsers[0](&buf, &packet)) { } if (buf.length == BUF_LEN_MAX) { diff --git a/airspy_adsb.c b/airspy_adsb.c index b4a5489..922e205 100644 --- a/airspy_adsb.c +++ b/airspy_adsb.c @@ -48,6 +48,6 @@ static bool airspy_adsb_parse_common(char *in, struct packet *packet) { } uint16_t mlat_mhz = 2 * hex_to_int(&in[9], 1); packet->mlat_timestamp = hex_to_int(in, 4) * (MLAT_MHZ / mlat_mhz); - packet->rssi = hex_to_int(&in[12], 2) * (RSSI_MAX / (1 << 16)); + packet->rssi = hex_to_int(&in[12], 2) * (RSSI_MAX / UINT16_MAX); return true; }