From 049614d16c14c5cd1f6060a704fd8b1f42d45b55 Mon Sep 17 00:00:00 2001 From: wb2osz Date: Mon, 22 Nov 2021 21:10:31 -0500 Subject: [PATCH] Fix IL2P for 9600 bps. --- CHANGES.md | 2 +- src/audio.c | 2 ++ src/ax25_pad2.c | 4 +++- src/config.c | 1 + src/demod_afsk.c | 12 +++++++++--- src/gen_tone.c | 5 ++++- test/CMakeLists.txt | 8 ++++++++ test/scripts/check-modem9600-i | 18 ++++++++++++++++++ 8 files changed, 46 insertions(+), 6 deletions(-) create mode 100755 test/scripts/check-modem9600-i diff --git a/CHANGES.md b/CHANGES.md index 49dc22a..b2ffa01 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,7 +7,7 @@ ### New Features: ### -- Improved Layer 2 Protocol [(IL2P)](https://en.wikipedia.org/wiki/FX.25_Forward_Error_Correction). Use "-I 1" to enable transmit for first channel. +- Improved Layer 2 Protocol [(IL2P)](https://en.wikipedia.org/wiki/FX.25_Forward_Error_Correction). Use "-I 1" on command line to enable transmit for first channel. Compatible with Nino TNC for 1200 and 9600 bps. - Limited support for CM109/CM119 GPIO PTT on Windows. diff --git a/src/audio.c b/src/audio.c index 15c5fc6..44d1cd1 100644 --- a/src/audio.c +++ b/src/audio.c @@ -1094,6 +1094,8 @@ int audio_get (int a) dw_printf ("This is most likely caused by the CPU being too slow to keep up with the audio stream.\n"); dw_printf ("Use the \"top\" command, in another command window, to look at CPU usage.\n"); dw_printf ("This might be a temporary condition so we will attempt to recover a few times before giving up.\n"); + dw_printf ("If using a very slow CPU, try reducing the CPU load by using -P- command\n"); + dw_printf ("line option for 9600 bps or -D3 for slower AFSK .\n"); } audio_stats (a, diff --git a/src/ax25_pad2.c b/src/ax25_pad2.c index 862f913..347df4b 100644 --- a/src/ax25_pad2.c +++ b/src/ax25_pad2.c @@ -102,7 +102,9 @@ * * RR note: It seems that some implementations put a hint * in the "RR" reserved bits. - * http://www.tapr.org/pipermail/ax25-layer2/2005-October/000297.html + * http://www.tapr.org/pipermail/ax25-layer2/2005-October/000297.html (now broken) + * https://elixir.bootlin.com/linux/latest/source/net/ax25/ax25_addr.c#L237 + * * The RR bits can also be used for "DAMA" which is * some sort of channel access coordination scheme. * http://internet.freepage.de/cgi-bin/feets/freepage_ext/41030x030A/rewrite/hennig/afu/afudoc/afudama.html diff --git a/src/config.c b/src/config.c index 527e832..730991c 100644 --- a/src/config.c +++ b/src/config.c @@ -4522,6 +4522,7 @@ void config_init (char *fname, struct audio_s *p_audio_config, * * In version 1.2 we allow 0 to disable listening. */ +// FIXME: complain if extra parameter e.g. port as in KISSPORT else if (strcasecmp(t, "AGWPORT") == 0) { int n; diff --git a/src/demod_afsk.c b/src/demod_afsk.c index a61fdc1..3528797 100644 --- a/src/demod_afsk.c +++ b/src/demod_afsk.c @@ -431,11 +431,17 @@ void demod_afsk_init (int samples_per_sec, int baud, int mark_freq, TUNE("TUNE_PRE_FILTER_TAPS", D->pre_filter_taps, "pre_filter_taps", "%d") +// TODO: Size comes out to 417 for 1200 bps with 48000 sample rate. +// The message is upsetting. Can we handle this better? + if (D->pre_filter_taps > MAX_FILTER_SIZE) { text_color_set (DW_COLOR_ERROR); - dw_printf ("Calculated pre filter size of %d is too large.\n", D->pre_filter_taps); - dw_printf ("Decrease the audio sample rate or increase the decimation factor or\n"); - dw_printf ("recompile the application with MAX_FILTER_SIZE larger than %d.\n", MAX_FILTER_SIZE); + dw_printf ("Warning: Calculated pre filter size of %d is too large.\n", D->pre_filter_taps); + dw_printf ("Decrease the audio sample rate or increase the decimation factor.\n"); + dw_printf ("You can use -D2 or -D3, on the command line, to down-sample the audio rate\n"); + dw_printf ("before demodulating. This greatly decreases the CPU requirements with little\n"); + dw_printf ("impact on the decoding performance. This is useful for a slow ARM processor,\n"); + dw_printf ("such as with a Raspberry Pi model 1.\n"); D->pre_filter_taps = (MAX_FILTER_SIZE - 1) | 1; } diff --git a/src/gen_tone.c b/src/gen_tone.c index a0caedc..023c0f8 100644 --- a/src/gen_tone.c +++ b/src/gen_tone.c @@ -360,7 +360,10 @@ void tone_gen_put_bit (int chan, int dat) bit_count[chan] = 0; } - if (save_audio_config_p->achan[chan].modem_type == MODEM_SCRAMBLE) { + // Would be logical to have MODEM_BASEBAND for IL2P rather than checking here. But... + // That would mean putting in at least 3 places and testing all rather than just one. + if (save_audio_config_p->achan[chan].modem_type == MODEM_SCRAMBLE && + save_audio_config_p->achan[chan].layer2_xmit != LAYER2_IL2P) { int x; x = (dat ^ (lfsr[chan] >> 16) ^ (lfsr[chan] >> 11)) & 1; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1b08a07..a95cbaf 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -20,6 +20,7 @@ set(TEST_CHECK-MODEM1200_FILE "check-modem1200") set(TEST_CHECK-MODEM1200_IL2P_FILE "check-modem1200-i") set(TEST_CHECK-MODEM300_FILE "check-modem300") set(TEST_CHECK-MODEM9600_FILE "check-modem9600") +set(TEST_CHECK-MODEM9600_IL2P_FILE "check-modem9600-i") set(TEST_CHECK-MODEM19200_FILE "check-modem19200") set(TEST_CHECK-MODEM2400-a_FILE "check-modem2400-a") set(TEST_CHECK-MODEM2400-b_FILE "check-modem2400-b") @@ -64,6 +65,12 @@ configure_file( @ONLY ) +configure_file( + "${CUSTOM_TEST_SCRIPTS_DIR}/${TEST_CHECK-MODEM9600_IL2P_FILE}" + "${CUSTOM_TEST_BINARY_DIR}/${TEST_CHECK-MODEM9600_IL2P_FILE}${CUSTOM_SCRIPT_SUFFIX}" + @ONLY + ) + configure_file( "${CUSTOM_TEST_SCRIPTS_DIR}/${TEST_CHECK-MODEM19200_FILE}" "${CUSTOM_TEST_BINARY_DIR}/${TEST_CHECK-MODEM19200_FILE}${CUSTOM_SCRIPT_SUFFIX}" @@ -485,6 +492,7 @@ add_test(check-modem1200 "${CUSTOM_TEST_BINARY_DIR}/${TEST_CHECK-MODEM1200_FILE} add_test(check-modem1200-i "${CUSTOM_TEST_BINARY_DIR}/${TEST_CHECK-MODEM1200_IL2P_FILE}${CUSTOM_SCRIPT_SUFFIX}") add_test(check-modem300 "${CUSTOM_TEST_BINARY_DIR}/${TEST_CHECK-MODEM300_FILE}${CUSTOM_SCRIPT_SUFFIX}") add_test(check-modem9600 "${CUSTOM_TEST_BINARY_DIR}/${TEST_CHECK-MODEM9600_FILE}${CUSTOM_SCRIPT_SUFFIX}") +add_test(check-modem9600-i "${CUSTOM_TEST_BINARY_DIR}/${TEST_CHECK-MODEM9600_IL2P_FILE}${CUSTOM_SCRIPT_SUFFIX}") add_test(check-modem19200 "${CUSTOM_TEST_BINARY_DIR}/${TEST_CHECK-MODEM19200_FILE}${CUSTOM_SCRIPT_SUFFIX}") add_test(check-modem2400-a "${CUSTOM_TEST_BINARY_DIR}/${TEST_CHECK-MODEM2400-a_FILE}${CUSTOM_SCRIPT_SUFFIX}") add_test(check-modem2400-b "${CUSTOM_TEST_BINARY_DIR}/${TEST_CHECK-MODEM2400-b_FILE}${CUSTOM_SCRIPT_SUFFIX}") diff --git a/test/scripts/check-modem9600-i b/test/scripts/check-modem9600-i new file mode 100755 index 0000000..0ba01be --- /dev/null +++ b/test/scripts/check-modem9600-i @@ -0,0 +1,18 @@ +@CUSTOM_SHELL_SHABANG@ + +@GEN_PACKETS_BIN@ -B9600 -I1 -n 100 -o test96-il2p-I1.wav +@ATEST_BIN@ -B9600 -L72 -G76 test96-il2p-I1.wav +@ATEST_BIN@ -B9600 -P+ -L76 -G80 test96-il2p-I1.wav + +@GEN_PACKETS_BIN@ -B9600 -I0 -n 100 -o test96-il2p-I0.wav +@ATEST_BIN@ -B9600 -L64 -G68 test96-il2p-I0.wav + + +@GEN_PACKETS_BIN@ -B9600 -i1 -n 100 -o test96-il2p-i1.wav +@ATEST_BIN@ -B9600 -L70 -G74 test96-il2p-i1.wav +@ATEST_BIN@ -B9600 -P+ -L73 -G77 test96-il2p-i1.wav + +@GEN_PACKETS_BIN@ -B9600 -i0 -n 100 -o test96-il2p-i0.wav +@ATEST_BIN@ -B9600 -L67 -G71 test96-il2p-i0.wav + +