aboutsummaryrefslogtreecommitdiffstats
path: root/tests/subchan_demux/subchan_demux_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/subchan_demux/subchan_demux_test.c')
-rw-r--r--tests/subchan_demux/subchan_demux_test.c186
1 files changed, 186 insertions, 0 deletions
diff --git a/tests/subchan_demux/subchan_demux_test.c b/tests/subchan_demux/subchan_demux_test.c
index 75c5901..2a9a678 100644
--- a/tests/subchan_demux/subchan_demux_test.c
+++ b/tests/subchan_demux/subchan_demux_test.c
@@ -1,6 +1,7 @@
/* Subchan Demux syncing test */
/* (C) 2012 by Holger Hans Peter Freyther
+ * (C) 2012 by Tobias Engel
*
* All Rights Reserved
*
@@ -25,6 +26,179 @@
#include <stdio.h>
#include <string.h>
+static uint8_t test_frames[] =
+{
+ /* (transmission order is from left to right) */
+ /* Frame 1 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* sync header: 16 bits zero... */
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 0, 1, 0, 0, 0, 1, 1, /* ... and 1 bit one (on the left) */
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 0, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 0, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1,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, 1, 0,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 0, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 0, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 0, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+};
+
+
+
static int data_cb(struct subch_demux *demux, int ch, uint8_t *data, int len, void *p)
{
printf("DATA_CB Channel(%d): %s\n",
@@ -34,15 +208,27 @@ static int data_cb(struct subch_demux *demux, int ch, uint8_t *data, int len, vo
static void test_csd(void)
{
+ int i;
+ uint8_t muxbyte;
struct subch_demux demux;
memset(&demux, 0, sizeof(demux));
subch_demux_init(&demux);
+ demux.chan_activ = 1;
demux.out_cb = data_cb;
/* Push data into the demuxer and see what happens. */
printf("Testing the csd sync.\n");
+ for(i = 0; i < sizeof(test_frames); i += 2) {
+
+ muxbyte = 0;
+ muxbyte |= test_frames[i];
+ muxbyte |= (test_frames[i+1] << 1);
+
+ subch_demux_in(&demux, &muxbyte, 1);
+ }
+
}
int main(int argc, char **argv)