From 1389e86d116509884b0e5ee3421fe7683afcab9b Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 18 Jun 2017 18:16:02 +0300 Subject: Add pseudo-random bit sequence generator to libosmcoore These PRBS sequences are specified in ITU-T O.150. They are typically used as test data to be transmitted for BER (bit error rate) testing. Change-Id: I227b6a6e86a251460ecb816afa9a7439d5fb94d1 --- tests/prbs/prbs_test.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 tests/prbs/prbs_test.c (limited to 'tests/prbs/prbs_test.c') diff --git a/tests/prbs/prbs_test.c b/tests/prbs/prbs_test.c new file mode 100644 index 00000000..f478635b --- /dev/null +++ b/tests/prbs/prbs_test.c @@ -0,0 +1,47 @@ +#include +#include +#include +#include + +static void dump_bits(const ubit_t *bits, unsigned int num_bits) +{ + unsigned int i; + + for (i = 0; i < num_bits; i++) { + if (bits[i]) + fputc('1', stdout); + else + fputc('0', stdout); + } + fputc('\n',stdout); +} + +static void test_prbs(const struct osmo_prbs *prbs) +{ + struct osmo_prbs_state st; + unsigned int i; + + printf("Testing PRBS sequence generation '%s'\n", prbs->name); + osmo_prbs_state_init(&st, prbs); + + /* 2 lines */ + for (i = 0; i < 2; i++) { + unsigned int seq_len = (1 << prbs->len)-1; + ubit_t bits[seq_len]; + memset(bits, 0, sizeof(bits)); + osmo_prbs_get_ubits(bits, sizeof(bits), &st); + dump_bits(bits, sizeof(bits)); + } + + printf("\n"); +} + +int main(int argc, char **argv) +{ + test_prbs(&osmo_prbs7); + test_prbs(&osmo_prbs9); + test_prbs(&osmo_prbs11); + test_prbs(&osmo_prbs15); + + exit(0); +} -- cgit v1.2.3