Support both types of line endings in airspy_adsb. Fix a bug in raw line ending handling that could delay packets.

This commit is contained in:
Ian Gulliver
2016-02-26 14:18:28 -08:00
parent e3a372e1ea
commit 8ed1f152a6
2 changed files with 26 additions and 30 deletions

View File

@@ -27,11 +27,10 @@ struct __attribute__((packed)) raw_mode_s_long_overlay {
static bool raw_parse_mode_s_short(struct buf *buf, struct packet *packet) {
struct raw_mode_s_short_overlay *overlay = (struct raw_mode_s_short_overlay *) buf_at(buf, 0);
if (buf->length < sizeof(*overlay) ||
if (((buf->length < sizeof(*overlay) - 1 || overlay->cr_lf != '\n') &&
(buf->length < sizeof(*overlay) || overlay->cr_lf != '\r' || overlay->lf != '\n')) ||
overlay->asterisk != '*' ||
overlay->semicolon != ';' ||
((overlay->cr_lf != '\n') &&
(overlay->cr_lf != '\r' || overlay->lf != '\n'))) {
overlay->semicolon != ';') {
return false;
}
if (!hex_to_bin(packet->payload, overlay->payload, sizeof(overlay->payload) / 2)) {
@@ -44,11 +43,10 @@ static bool raw_parse_mode_s_short(struct buf *buf, struct packet *packet) {
static bool raw_parse_mode_s_long(struct buf *buf, struct packet *packet) {
struct raw_mode_s_long_overlay *overlay = (struct raw_mode_s_long_overlay *) buf_at(buf, 0);
if (buf->length < sizeof(*overlay) ||
if (((buf->length < sizeof(*overlay) - 1 || overlay->cr_lf != '\n') &&
(buf->length < sizeof(*overlay) || overlay->cr_lf != '\r' || overlay->lf != '\n')) ||
overlay->asterisk != '*' ||
overlay->semicolon != ';' ||
((overlay->cr_lf != '\n') &&
(overlay->cr_lf != '\r' || overlay->lf != '\n'))) {
overlay->semicolon != ';') {
return false;
}
if (!hex_to_bin(packet->payload, overlay->payload, sizeof(overlay->payload) / 2)) {