Cheaper airspy matching

This commit is contained in:
Ian Gulliver
2016-02-14 07:11:26 +00:00
parent 51690ba0df
commit f7bee3ce44
4 changed files with 13 additions and 13 deletions

View File

@@ -1,20 +1,20 @@
#include <stdio.h>
#include <string.h>
#include "common.h"
#include "airspy_adsb.h"
bool airspy_adsb_parse(struct buf *buf, struct packet *packet) {
if (buf->length < 35) {
// Minimum frame length
if (buf->length < 1 || *buf_at(buf, 0) != '*') {
return false;
}
if (buf->buf[buf->start] != '*') {
return false;
if (buf->length >= 35 && *buf_at(buf, 34) == '\n') {
buf_consume(buf, 35);
return true;
}
char *last = memchr(&buf->buf[buf->start], '\n', buf->length);
if (!last) {
return false;
if (buf->length >= 49 && *buf_at(buf, 48) == '\n') {
buf_consume(buf, 49);
return true;
}
buf_consume(buf, last - &buf->buf[buf->start] + 1);
return true;
return false;
}