From b65f34c0aa7e58da3db9bf8fa16d80ddedf41abd Mon Sep 17 00:00:00 2001 From: Pieter Robyns Date: Thu, 7 Sep 2017 10:43:18 +0200 Subject: [PATCH] - Fixed decoding bug - Allow for pausing upon encountering test suite error - Round header bin index instead of floor --- apps/generate_test_suites.py | 2 +- docs/test-results/decode_long_usrp.md | 2 +- docs/test-results/short_usrp.md | 26 +++++++++++++------------- lib/decoder_impl.cc | 7 +++---- python/qa_testsuite.py | 13 +++++++++---- 5 files changed, 27 insertions(+), 23 deletions(-) diff --git a/apps/generate_test_suites.py b/apps/generate_test_suites.py index 66d9382..a0bfeae 100755 --- a/apps/generate_test_suites.py +++ b/apps/generate_test_suites.py @@ -196,4 +196,4 @@ if __name__ == '__main__': Test(payload="88", times=1), Test(payload="ffff", times=10), ] - #TestSuite(name='short', args=args, config_set=short_config_set, test_set=short_test_set).run() + TestSuite(name='short', args=args, config_set=short_config_set, test_set=short_test_set).run() diff --git a/docs/test-results/decode_long_usrp.md b/docs/test-results/decode_long_usrp.md index 563297c..5e368e6 100644 --- a/docs/test-results/decode_long_usrp.md +++ b/docs/test-results/decode_long_usrp.md @@ -1,6 +1,6 @@ # Test suite: 'decode_long_usrp' -*Results on 2017-09-06 14:44:23.827805* +*Results on 2017-09-07 08:34:10.155002* ### 868.1 MHz, SF 7, CR 4/8, BW 125 kHz, prlen 8, crc on, implicit off diff --git a/docs/test-results/short_usrp.md b/docs/test-results/short_usrp.md index eca9b34..fd2ee5f 100644 --- a/docs/test-results/short_usrp.md +++ b/docs/test-results/short_usrp.md @@ -1,12 +1,12 @@ # Test suite: 'short_usrp' -*Results on 2017-09-06 14:45:03.172136* +*Results on 2017-09-07 08:34:49.501821* ### 868.1 MHz, SF 7, CR 4/8, BW 125 kHz, prlen 8, crc on, implicit off Transmitted payload | :heavy_check_mark: | :hash: | :heavy_division_sign: --- | --- | --- | --- -`deadbeef ` | 0 | 5 | 0.00% +`deadbeef ` | 5 | 5 | 100.00% `88 ` | 1 | 1 | 100.00% `ffff ` | 10 | 10 | 100.00% @@ -54,7 +54,7 @@ Transmitted payload | :heavy_check_mark: | :hash: | :heavy_division_sign: Transmitted payload | :heavy_check_mark: | :hash: | :heavy_division_sign: --- | --- | --- | --- -`deadbeef ` | 0 | 5 | 0.00% +`deadbeef ` | 5 | 5 | 100.00% `88 ` | 1 | 1 | 100.00% `ffff ` | 10 | 10 | 100.00% @@ -62,7 +62,7 @@ Transmitted payload | :heavy_check_mark: | :hash: | :heavy_division_sign: Transmitted payload | :heavy_check_mark: | :hash: | :heavy_division_sign: --- | --- | --- | --- -`deadbeef ` | 0 | 5 | 0.00% +`deadbeef ` | 5 | 5 | 100.00% `88 ` | 1 | 1 | 100.00% `ffff ` | 10 | 10 | 100.00% @@ -166,15 +166,15 @@ Transmitted payload | :heavy_check_mark: | :hash: | :heavy_division_sign: Transmitted payload | :heavy_check_mark: | :hash: | :heavy_division_sign: --- | --- | --- | --- -`deadbeef ` | 2 | 5 | 40.00% -`88 ` | 0 | 1 | 0.00% -`ffff ` | 9 | 10 | 90.00% +`deadbeef ` | 5 | 5 | 100.00% +`88 ` | 1 | 1 | 100.00% +`ffff ` | 10 | 10 | 100.00% ### 868.1 MHz, SF 12, CR 4/7, BW 125 kHz, prlen 8, crc on, implicit off Transmitted payload | :heavy_check_mark: | :hash: | :heavy_division_sign: --- | --- | --- | --- -`deadbeef ` | 2 | 5 | 40.00% +`deadbeef ` | 5 | 5 | 100.00% `88 ` | 1 | 1 | 100.00% `ffff ` | 10 | 10 | 100.00% @@ -182,7 +182,7 @@ Transmitted payload | :heavy_check_mark: | :hash: | :heavy_division_sign: Transmitted payload | :heavy_check_mark: | :hash: | :heavy_division_sign: --- | --- | --- | --- -`deadbeef ` | 4 | 5 | 80.00% +`deadbeef ` | 5 | 5 | 100.00% `88 ` | 1 | 1 | 100.00% `ffff ` | 10 | 10 | 100.00% @@ -190,11 +190,11 @@ Transmitted payload | :heavy_check_mark: | :hash: | :heavy_division_sign: Transmitted payload | :heavy_check_mark: | :hash: | :heavy_division_sign: --- | --- | --- | --- -`deadbeef ` | 4 | 5 | 80.00% -`88 ` | 0 | 1 | 0.00% -`ffff ` | 8 | 10 | 80.00% +`deadbeef ` | 5 | 5 | 100.00% +`88 ` | 1 | 1 | 100.00% +`ffff ` | 10 | 10 | 100.00% ### Summary for suite 'short_usrp' -Total payloads passed: 356 out of 384 (92.71%) +Total payloads passed: 384 out of 384 (100.00%) diff --git a/lib/decoder_impl.cc b/lib/decoder_impl.cc index cb8e0c8..76f3ed2 100644 --- a/lib/decoder_impl.cc +++ b/lib/decoder_impl.cc @@ -77,6 +77,7 @@ namespace gr { d_samples_per_symbol = (uint32_t)(d_samples_per_second / d_symbols_per_second); d_delay_after_sync = d_samples_per_symbol / 4u; d_number_of_bins = (uint32_t)(1u << d_sf); + d_number_of_bins_hdr = (uint32_t)(1u << (d_sf-2)); d_decim_factor = d_samples_per_symbol / d_number_of_bins; d_energy_threshold = 0.01f; d_whitening_sequence = gr::lora::prng_payload; @@ -431,12 +432,10 @@ namespace gr { gradient = samples_ifreq_avg[i - 1] - samples_ifreq_avg[i]; if (gradient > max_gradient) { max_gradient = gradient; - max_index = i; + max_index = i+1; } } - max_index += 1; - return (d_number_of_bins - max_index) % d_number_of_bins; } @@ -453,7 +452,7 @@ namespace gr { // Header has additional redundancy if (is_header || d_sf > 10) { - bin_idx /= 4u; + bin_idx = std::lround(bin_idx / 4.0f) % d_number_of_bins_hdr; } // Decode (actually gray encode) the bin to get the symbol value diff --git a/python/qa_testsuite.py b/python/qa_testsuite.py index 730a77c..4f18362 100755 --- a/python/qa_testsuite.py +++ b/python/qa_testsuite.py @@ -35,7 +35,8 @@ def trunc(target, max_len=30): return result class TestSummary(): - def __init__(self, suite): + def __init__(self, suite, pause=False): + self.pause = pause self.suite = suite self._summary = [] self._summary_text = "-------- Test suite '{:s}' results on {:s} ---------\n".format(suite, str(datetime.datetime.utcnow())) @@ -117,6 +118,9 @@ class TestSummary(): if decoded == expected: num_correct_payloads += 1 self._num_total_correct_payloads += 1 + else: + if self.pause: + dummy = input("Expected %s but got %s for %s. Press enter to continue..." % (expected, decoded, lora_config.string_repr())) # Append to text report evaluation_text += "\tTest {:>3n}: {:<30s} * {:<3n} :: passed {:>3n} out of {:<3n} ({:.2%})\n".format( @@ -191,14 +195,14 @@ class qa_testsuite(): return total_data - def run(self, suites_to_run): + def run(self, suites_to_run, pause=False): for test_suite in self.test_suites: # Skip test suites that we don't want to run if suites_to_run != [] and (not test_suite in suites_to_run): continue print("[+] Testing suite: '%s'" % test_suite) - summary = TestSummary(suite=test_suite) + summary = TestSummary(suite=test_suite, pause=pause) # Get all metadata files associated with the suite get_mtime = lambda f: os.stat(os.path.join(self.test_suites_directory, test_suite, f)).st_mtime @@ -264,10 +268,11 @@ if __name__ == '__main__': # Parse args parser = argparse.ArgumentParser(description="Tool to evaluate decoding test suites for gr-lora.") parser.add_argument('suites', type=str, nargs="*", help='Names of the test suites to execute.') + parser.add_argument('--pause', action="store_true", default=False, help='Pause upon encountering an error.') args = parser.parse_args() # Make sure CTRL+C exits the whole test suite instead of only the current GNU Radio top block signal.signal(signal.SIGINT, signal_handler) suite = qa_testsuite() - suite.run(args.suites) + suite.run(args.suites, args.pause)