diff --git a/CHANGES.md b/CHANGES.md index 589cd5a..f979b54 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,9 @@ ### New Features: ### + +- New variable speed option for gen_packets. For example, "-v 5,0.1" would generate packets from 5% too slow to 5% too fast with increments of 0.1. Some implementations might have imprecise timing. Use this to test how well TNCs tolerate sloppy timing. + - 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. @@ -17,7 +20,7 @@ - The BEACON configuration now recognizes the SOURCE= option. This replaces the AX.25 source address rather than using the MYCALL value for the channel. This is useful for sending more than 5 analog telemetry channels. Use two, or more, source addresses with up to 5 analog channels each. -- For more flexibility, the FX.25 transmit property can now be set individually by channel, rather than having a global setting for all channels. The -X on the command line applies only to channel 0. For other channels you need to add a new line to the configuration file. +- For more flexibility, the FX.25 transmit property can now be set individually by channel, rather than having a global setting for all channels. The -X on the command line applies only to channel 0. For other channels you need to add a new line to the configuration file. You can specify a specific number of parity bytes (16, 32, 64) or 1 to choose automatically based on packet size. > After: "CHANNEL 1" (or other channel) > diff --git a/man/gen_packets.1 b/man/gen_packets.1 index a404288..ba782fe 100644 --- a/man/gen_packets.1 +++ b/man/gen_packets.1 @@ -100,9 +100,13 @@ Send output to .wav file. 8 bit audio rather than 16. .TP -.B "-2" +.BI "-2" 2 channels of audio rather than 1. +.TP +.BI "-v" "max[,incr]" +Variable speed with specified maximum error and optional increment. + .SH EXAMPLES .P diff --git a/src/gen_packets.c b/src/gen_packets.c index ba58abb..9728611 100644 --- a/src/gen_packets.c +++ b/src/gen_packets.c @@ -56,7 +56,15 @@ * gen_packets -n 100 -o z2.wav * atest z2.wav * - * + * Variable speed. e.g. 95% to 105% of normal speed. + * Required parameter is max % below and above normal. + * Optionally specify step other than 0.1%. + * Used to test how tolerant TNCs are to senders not + * not using exactly the right baud rate. + * + * gen_packets -v 5 + * gen_packets -v 5,0.5 + * *------------------------------------------------------------------*/ @@ -67,6 +75,7 @@ #include #include #include +#include #include "audio.h" #include "ax25_pad.h" @@ -100,6 +109,7 @@ static float g_noise_level = 0; static int g_morse_wpm = 0; /* Send morse code at this speed. */ + static struct audio_s modem; @@ -179,6 +189,9 @@ int main(int argc, char **argv) int X_opt = 0; // send FX.25 int I_opt = -1; // send IL2P rather than AX.25, normal polarity int i_opt = -1; // send IL2P rather than AX.25, inverted polarity + double variable_speed_max_error = 0; // both in percent + double variable_speed_increment = 0.1; + /* * Set up default values for the modem. @@ -230,7 +243,7 @@ int main(int argc, char **argv) /* ':' following option character means arg is required. */ - c = getopt_long(argc, argv, "gjJm:s:a:b:B:r:n:N:o:z:82M:X:I:i:", + c = getopt_long(argc, argv, "gjJm:s:a:b:B:r:n:N:o:z:82M:X:I:i:v:", long_options, &option_index); if (c == -1) break; @@ -469,6 +482,16 @@ int main(int argc, char **argv) i_opt = atoi(optarg); break; + case 'v': // Variable speed data + an - this percentage + // optional comma and increment. + + variable_speed_max_error = fabs(atof(optarg)); + char *q = strchr(optarg, ','); + if (q != NULL) { + variable_speed_increment = fabs(atof(q+1)); + } + break; + case '?': /* Unknown option message was already printed. */ @@ -479,7 +502,7 @@ int main(int argc, char **argv) /* Should not be here. */ text_color_set(DW_COLOR_ERROR); - dw_printf("?? getopt returned character code 0%o ??\n", c); + dw_printf("?? getopt returned character code 0%o ??\n", (unsigned)c); usage (argv); } } @@ -647,9 +670,35 @@ int main(int argc, char **argv) */ text_color_set(DW_COLOR_INFO); dw_printf ("built in message...\n"); - - if (packet_count > 0) { +// +// Generate packets with variable speed. +// This overrides any other number of packets or adding noise. +// + + + if (variable_speed_max_error != 0) { + + int normal_speed = modem.achan[0].baud; + + text_color_set(DW_COLOR_INFO); + dw_printf ("Variable speed.\n"); + + for (double speed_error = - variable_speed_max_error; + speed_error <= variable_speed_max_error + 0.001; + speed_error += variable_speed_increment) { + + // Baud is int so we get some roundoff. Make it real? + modem.achan[0].baud = (int)round(normal_speed * (1. + speed_error / 100.)); + gen_tone_init (&modem, amplitude/2, 1); + + char stemp[256]; + snprintf (stemp, sizeof(stemp), "WB2OSZ-15>TEST:, speed %+0.1f%% The quick brown fox jumps over the lazy dog!", speed_error); + send_packet (stemp); + } + } + + else if (packet_count > 0) { /* * Generate packets with increasing noise level. @@ -730,6 +779,7 @@ static void usage (char **argv) dw_printf (" -o Send output to .wav file.\n"); dw_printf (" -8 8 bit audio rather than 16.\n"); dw_printf (" -2 2 channels (stereo) audio rather than one channel.\n"); + dw_printf (" -v max[,incr] Variable speed with specified maximum error and increment.\n"); // dw_printf (" -z Number of leading zero bits before frame.\n"); // dw_printf (" Default is 12 which is .01 seconds at 1200 bits/sec.\n");