Files
adsb-tools/common.h

47 lines
732 B
C
Raw Normal View History

#include <stdint.h>
#include <unistd.h>
2016-02-15 06:47:40 +00:00
//////// misc
#define PARSER_STATE_LEN 256
2016-02-14 20:35:43 +00:00
//////// buf
2016-02-14 22:26:34 +00:00
#define BUF_LEN_MAX 256
struct buf {
2016-02-14 22:26:34 +00:00
char buf[BUF_LEN_MAX];
size_t start;
size_t length;
};
2016-02-14 20:35:43 +00:00
#define buf_chr(buff, at) ((buff)->buf[(buff)->start + (at)])
#define buf_at(buff, at) (&buf_chr(buff, at))
ssize_t buf_fill(struct buf *, int);
void buf_consume(struct buf *, size_t);
//////// packet
2016-02-14 22:26:34 +00:00
#define MLAT_MHZ 120
#define RSSI_MAX UINT32_MAX
#define DATA_LEN_MAX 14
struct packet {
enum {
MODE_AC,
MODE_S_SHORT,
MODE_S_LONG,
} type;
2016-02-14 22:26:34 +00:00
char data[DATA_LEN_MAX];
uint64_t mlat_timestamp;
uint32_t rssi;
};
2016-02-14 20:35:43 +00:00
//////// hex
2016-02-14 22:26:34 +00:00
void hex_init();
void hex_to_bin(char *, char *, size_t);
uint64_t hex_to_int(char *, size_t);