summaryrefslogtreecommitdiffstats
path: root/tests/coding/coding_test.c
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2017-10-16 14:58:00 +0200
committerMax <msuraev@sysmocom.de>2017-12-11 10:36:47 +0000
commit32e5641dbbfd91b650a9ec8cf62d28fd22109e9e (patch)
tree401803f3b61944c3264c341a54878c8456c61110 /tests/coding/coding_test.c
parent9dd3bf0cb4e780b54772f4abe1e2966b09f99301 (diff)
Add functions for extended RACH coding
Add support for extended RACH (11 bit) according 3GPP TS 45.003 ยง5.3.2: * convolutional code with puncturing * encoding/decoding routines * corresponding tests Change-Id: I85a34a82d5cd39a594ee89d91a2338226066ab5d Related: OS#1548
Diffstat (limited to 'tests/coding/coding_test.c')
-rw-r--r--tests/coding/coding_test.c41
1 files changed, 39 insertions, 2 deletions
diff --git a/tests/coding/coding_test.c b/tests/coding/coding_test.c
index b77410fd..511dbb7b 100644
--- a/tests/coding/coding_test.c
+++ b/tests/coding/coding_test.c
@@ -110,7 +110,7 @@ static void test_rach(uint8_t bsic, uint8_t ra)
/* Encode L2 message */
printf("Encoding: %02x\n", ra);
- gsm0503_rach_encode(bursts_u, &ra, bsic);
+ gsm0503_rach_ext_encode(bursts_u, ra, bsic, false);
/* Prepare soft-bits */
osmo_ubit2sbit(bursts_s, bursts_u, 36);
@@ -126,7 +126,38 @@ static void test_rach(uint8_t bsic, uint8_t ra)
gsm0503_rach_decode(&result, bursts_s, bsic);
printf("Decoded: %02x\n", result);
- OSMO_ASSERT(ra == result);
+ if (ra != result)
+ printf("FAIL [RACH]: encoded %u != %u decoded\n", ra, result);
+
+ printf("\n");
+}
+
+static void test_rach_ext(uint8_t bsic, uint16_t ra)
+{
+ uint16_t result = 3000; /* Max ext. RA is 2^11 = 2048 */
+ ubit_t bursts_u[36];
+ sbit_t bursts_s[36];
+
+ /* Encode L2 message */
+ printf("Encoding: %02x\n", ra);
+ gsm0503_rach_ext_encode(bursts_u, ra, bsic, true);
+
+ /* Prepare soft-bits */
+ osmo_ubit2sbit(bursts_s, bursts_u, 36);
+
+ printf("U-Bits: %s\n", osmo_ubit_dump(bursts_u, 36));
+
+ printf("S-Bits: %s\n", osmo_hexdump((uint8_t *)bursts_s, 36));
+
+ /* Destroy some bits */
+ memset(bursts_s + 9, 0, 8);
+
+ /* Decode, correcting errors */
+ gsm0503_rach_ext_decode(&result, bursts_s, bsic);
+ printf("Decoded: %02x\n", result);
+
+ if (ra != result)
+ printf("FAIL [RACH ext]: encoded %u != %u decoded\n", ra, result);
printf("\n");
}
@@ -332,6 +363,12 @@ int main(int argc, char **argv)
test_rach(0x1a, i);
}
+ for (i = 0; i < 2048; i++) {
+ test_rach_ext(0x3f, i);
+ test_rach_ext(0x00, i);
+ test_rach_ext(0x1a, i);
+ }
+
for (i = 0; i < len_l2; i++)
test_sch(test_l2[i]);