-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #214 from luarvique/pocsag_fix
Fixing POCSAG decoders not working when fed small data over pipes, etc.
- Loading branch information
Showing
3 changed files
with
19 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* demod_afsk12.c -- 1200 baud AFSK demodulator | ||
* | ||
* Copyright (C) 1996 | ||
* Copyright (C) 1996 | ||
* Thomas Sailer ([email protected], [email protected]) | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
/* | ||
* demod_poc12.c -- 1200 baud POCSAG demodulator | ||
* | ||
* Copyright (C) 1996 | ||
* Copyright (C) 1996 | ||
* Thomas Sailer ([email protected], [email protected]) | ||
* Copyright (C) 2024 | ||
* Marat Fayzullin ([email protected]) | ||
* | ||
* POCSAG (Post Office Code Standard Advisory Group) | ||
* Radio Paging Decoder | ||
|
@@ -54,16 +56,15 @@ static void poc12_init(struct demod_state *s) | |
static void poc12_demod(struct demod_state *s, buffer_t buffer, int length) | ||
{ | ||
if (s->l1.poc12.subsamp) { | ||
int numfill = SUBSAMP - s->l1.poc12.subsamp; | ||
if (length < numfill) { | ||
s->l1.poc12.subsamp += length; | ||
if (length <= (int)s->l1.poc12.subsamp) { | ||
s->l1.poc12.subsamp -= length; | ||
return; | ||
} | ||
buffer.fbuffer += numfill; | ||
length -= numfill; | ||
buffer.fbuffer += s->l1.poc12.subsamp; | ||
length -= s->l1.poc12.subsamp; | ||
s->l1.poc12.subsamp = 0; | ||
} | ||
for (; length >= SUBSAMP; length -= SUBSAMP, buffer.fbuffer += SUBSAMP) { | ||
for (; length > 0; length -= SUBSAMP, buffer.fbuffer += SUBSAMP) { | ||
s->l1.poc12.dcd_shreg <<= 1; | ||
s->l1.poc12.dcd_shreg |= ((*buffer.fbuffer) > 0); | ||
verbprintf(10, "%c", '0'+(s->l1.poc12.dcd_shreg & 1)); | ||
|
@@ -82,7 +83,7 @@ static void poc12_demod(struct demod_state *s, buffer_t buffer, int length) | |
pocsag_rxbit(s, s->l1.poc12.dcd_shreg & 1); | ||
} | ||
} | ||
s->l1.poc12.subsamp = length; | ||
s->l1.poc12.subsamp = -length; | ||
} | ||
|
||
static void poc12_deinit(struct demod_state *s) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
/* | ||
* demod_poc5.c -- 512 baud POCSAG demodulator | ||
* | ||
* Copyright (C) 1996 | ||
* Copyright (C) 1996 | ||
* Thomas Sailer ([email protected], [email protected]) | ||
* Copyright (C) 2024 | ||
* Marat Fayzullin ([email protected]) | ||
* | ||
* POCSAG (Post Office Code Standard Advisory Group) | ||
* Radio Paging Decoder | ||
|
@@ -52,16 +54,15 @@ static void poc5_init(struct demod_state *s) | |
static void poc5_demod(struct demod_state *s, buffer_t buffer, int length) | ||
{ | ||
if (s->l1.poc5.subsamp) { | ||
int numfill = SUBSAMP - s->l1.poc5.subsamp; | ||
if (length < numfill) { | ||
s->l1.poc5.subsamp += length; | ||
if (length <= (int)s->l1.poc5.subsamp) { | ||
s->l1.poc5.subsamp -= length; | ||
return; | ||
} | ||
buffer.fbuffer += numfill; | ||
length -= numfill; | ||
buffer.fbuffer += s->l1.poc5.subsamp; | ||
length -= s->l1.poc5.subsamp; | ||
s->l1.poc5.subsamp = 0; | ||
} | ||
for (; length >= SUBSAMP; length -= SUBSAMP, buffer.fbuffer += SUBSAMP) { | ||
for (; length > 0; length -= SUBSAMP, buffer.fbuffer += SUBSAMP) { | ||
s->l1.poc5.dcd_shreg <<= 1; | ||
s->l1.poc5.dcd_shreg |= ((*buffer.fbuffer) > 0); | ||
verbprintf(10, "%c", '0'+(s->l1.poc5.dcd_shreg & 1)); | ||
|
@@ -80,7 +81,7 @@ static void poc5_demod(struct demod_state *s, buffer_t buffer, int length) | |
pocsag_rxbit(s, s->l1.poc5.dcd_shreg & 1); | ||
} | ||
} | ||
s->l1.poc5.subsamp = length; | ||
s->l1.poc5.subsamp = -length; | ||
} | ||
|
||
static void poc5_deinit(struct demod_state *s) | ||
|