22//
33// This file is part of Dire Wolf, an amateur radio packet TNC.
44//
5- // Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016 John Langner, WB2OSZ
5+ // Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2019 John Langner, WB2OSZ
66//
77// This program is free software: you can redistribute it and/or modify
88// it under the terms of the GNU General Public License as published by
@@ -182,7 +182,10 @@ static int sample_number = -1; /* Sample number from the file. */
182182
183183static int B_opt = DEFAULT_BAUD ; // Bits per second. Need to change all baud references to bps.
184184static int g_opt = 0 ; // G3RUH modem regardless of speed.
185+ static int j_opt = 0 ; /* 2400 bps PSK compatible with direwolf <= 1.5 */
186+ static int J_opt = 0 ; /* 2400 bps PSK compatible MFJ-2400 and maybe others. */
185187static int h_opt = 0 ; // Hexadecimal display of received packet.
188+ static char P_opt [16 ] = "" ; // Demodulator profiles.
186189
187190
188191int main (int argc , char * argv [])
@@ -219,49 +222,6 @@ int main (int argc, char *argv[])
219222 my_audio_config .adev [0 ].samples_per_sec = DEFAULT_SAMPLES_PER_SEC ;
220223 my_audio_config .adev [0 ].bits_per_sample = DEFAULT_BITS_PER_SAMPLE ;
221224
222- // Results v0.9:
223- //
224- // fix_bits = 0 971 packets, 69 sec
225- // fix_bits = SINGLE 990 64
226- // fix_bits = DOUBLE 992 65
227- // fix_bits = TRIPLE 992 67
228- // fix_bits = TWO_SEP 1004 476
229-
230- // Essentially no difference in time for those with order N time.
231- // Time increases greatly for the one with order N^2 time.
232-
233-
234- // Results: version 1.1, decoder C, my_audio_config.fix_bits = RETRY_MAX - 1
235- //
236- // 971 NONE
237- // +19 SINGLE
238- // +2 DOUBLE
239- // +12 TWO_SEP
240- // +3 REMOVE_MANY
241- // ----
242- // 1007 Total in 1008 sec. More than twice as long as earlier version.
243-
244- // Results: version 1.1, decoders ABC, my_audio_config.fix_bits = RETRY_MAX - 1
245- //
246- // 976 NONE
247- // +21 SINGLE
248- // +1 DOUBLE
249- // +22 TWO_SEP
250- // +1 MANY
251- // +3 REMOVE_MANY
252- // ----
253- // 1024 Total in 2042 sec.
254- // About 34 minutes of CPU time for a roughly 40 minute CD.
255- // Many computers wouldn't be able to keep up.
256-
257- // The SINGLE and TWO_SEP techniques are the most effective.
258- // Should we reorder the enum values so that TWO_SEP
259- // comes after SINGLE? That way "FIX_BITS 2" would
260- // use the two most productive techniques and not waste
261- // time on the others. People with plenty of CPU power
262- // to spare can still specify larger numbers for the other
263- // techniques with less return on investment.
264-
265225
266226 for (channel = 0 ; channel < MAX_CHANS ; channel ++ ) {
267227
@@ -299,7 +259,7 @@ int main (int argc, char *argv[])
299259
300260 /* ':' following option character means arg is required. */
301261
302- c = getopt_long (argc , argv , "B:P:D:U:gF :L:G:012h" ,
262+ c = getopt_long (argc , argv , "B:P:D:U:gjJF :L:G:012h" ,
303263 long_options , & option_index );
304264 if (c == -1 )
305265 break ;
@@ -316,10 +276,20 @@ int main (int argc, char *argv[])
316276 g_opt = 1 ;
317277 break ;
318278
279+ case 'j' : /* -j V.26 compatible with earlier direwolf. */
280+
281+ j_opt = 1 ;
282+ break ;
283+
284+ case 'J' : /* -J V.26 compatible with MFJ-2400. */
285+
286+ J_opt = 1 ;
287+ break ;
288+
319289 case 'P' : /* -P for modem profile. */
320290
321- dw_printf ( "Demodulator profile set to \"%s\"\n" , optarg );
322- strlcpy (my_audio_config . achan [ 0 ]. profiles , optarg , sizeof (my_audio_config . achan [ 0 ]. profiles ));
291+ // Wait until after other options processed.
292+ strlcpy (P_opt , optarg , sizeof (P_opt ));
323293 break ;
324294
325295 case 'D' : /* -D reduce sampling rate for lower CPU usage. */
@@ -353,7 +323,7 @@ int main (int argc, char *argv[])
353323 my_audio_config .achan [0 ].upsample = upsample ;
354324 break ;
355325
356- case 'F' : /* -D set "fix bits" level. */
326+ case 'F' : /* -F set "fix bits" level. */
357327
358328 my_audio_config .achan [0 ].fix_bits = atoi (optarg );
359329
@@ -411,7 +381,7 @@ int main (int argc, char *argv[])
411381
412382/*
413383 * Set modem type based on data rate.
414- * (Could be overridden by -g later.)
384+ * (Could be overridden by -g, -j, or -J later.)
415385 */
416386 /* 300 implies 1600/1800 AFSK. */
417387 /* 1200 implies 1200/2200 AFSK. */
@@ -478,6 +448,40 @@ int main (int argc, char *argv[])
478448 strlcpy (my_audio_config .achan [0 ].profiles , " " , sizeof (my_audio_config .achan [0 ].profiles )); // avoid getting default later.
479449 }
480450
451+ /*
452+ * We have two different incompatible flavors of V.26.
453+ */
454+ if (j_opt ) {
455+
456+ // V.26 compatible with earlier versions of direwolf.
457+ // Example: -B 2400 -j or simply -j
458+
459+ my_audio_config .achan [0 ].v26_alternative = V26_A ;
460+ my_audio_config .achan [0 ].modem_type = MODEM_QPSK ;
461+ my_audio_config .achan [0 ].mark_freq = 0 ;
462+ my_audio_config .achan [0 ].space_freq = 0 ;
463+ my_audio_config .achan [0 ].baud = 2400 ;
464+ strlcpy (my_audio_config .achan [0 ].profiles , "" , sizeof (my_audio_config .achan [0 ].profiles ));
465+ }
466+ if (J_opt ) {
467+
468+ // V.26 compatible with MFJ and maybe others.
469+ // Example: -B 2400 -J or simply -J
470+
471+ my_audio_config .achan [0 ].v26_alternative = V26_B ;
472+ my_audio_config .achan [0 ].modem_type = MODEM_QPSK ;
473+ my_audio_config .achan [0 ].mark_freq = 0 ;
474+ my_audio_config .achan [0 ].space_freq = 0 ;
475+ my_audio_config .achan [0 ].baud = 2400 ;
476+ strlcpy (my_audio_config .achan [0 ].profiles , "" , sizeof (my_audio_config .achan [0 ].profiles ));
477+ }
478+
479+ // Needs to be after -B, -j, -J.
480+ if (strlen (P_opt ) > 0 ) {
481+ dw_printf ("Demodulator profile set to \"%s\"\n" , P_opt );
482+ strlcpy (my_audio_config .achan [0 ].profiles , P_opt , sizeof (my_audio_config .achan [0 ].profiles ));
483+ }
484+
481485 memcpy (& my_audio_config .achan [1 ], & my_audio_config .achan [0 ], sizeof (my_audio_config .achan [0 ]));
482486
483487
@@ -879,11 +883,15 @@ static void usage (void) {
879883 dw_printf (" atest [ options ] wav-file-in\n" );
880884 dw_printf ("\n" );
881885 dw_printf (" -B n Bits/second for data. Proper modem automatically selected for speed.\n" );
882- dw_printf (" 300 baud uses 1600/1800 Hz AFSK.\n" );
883- dw_printf (" 1200 (default) baud uses 1200/2200 Hz AFSK.\n" );
884- dw_printf (" 9600 baud uses K9NG/G2RUH standard.\n" );
886+ dw_printf (" 300 bps defaults to AFSK tones of 1600 & 1800.\n" );
887+ dw_printf (" 1200 bps uses AFSK tones of 1200 & 2200.\n" );
888+ dw_printf (" 2400 bps uses QPSK based on V.26 standard.\n" );
889+ dw_printf (" 4800 bps uses 8PSK based on V.27 standard.\n" );
890+ dw_printf (" 9600 bps and up uses K9NG/G3RUH standard.\n" );
885891 dw_printf ("\n" );
886- dw_printf (" -g Force G3RUH modem rather rather than default for data rate.\n" );
892+ dw_printf (" -g Use G3RUH modem rather rather than default for data rate.\n" );
893+ dw_printf (" -j 2400 bps QPSK compatible with direwolf <= 1.5.\n" );
894+ dw_printf (" -J 2400 bps QPSK compatible with MFJ-2400.\n" );
887895 dw_printf ("\n" );
888896 dw_printf (" -D n Divide audio sample rate by n.\n" );
889897 dw_printf ("\n" );
@@ -894,8 +902,12 @@ static void usage (void) {
894902 dw_printf (" 1 = Try to fix only a single bit. \n" );
895903 dw_printf (" more = Try modifying more bits to get a good CRC.\n" );
896904 dw_printf ("\n" );
897- dw_printf (" -P m Select the demodulator type such as A, B, C, D (default for 300 baud),\n" );
898- dw_printf (" E (default for 1200 baud), F, A+, B+, C+, D+, E+, F+.\n" );
905+ dw_printf (" -L Error if less than this number decoded.\n" );
906+ dw_printf ("\n" );
907+ dw_printf (" -G Error if greater than this number decoded.\n" );
908+ dw_printf ("\n" );
909+ dw_printf (" -P m Select the demodulator type such as D (default for 300 bps),\n" );
910+ dw_printf (" E+ (default for 1200 bps), PQRS for 2400 bps, etc.\n" );
899911 dw_printf ("\n" );
900912 dw_printf (" -0 Use channel 0 (left) of stereo audio (default).\n" );
901913 dw_printf (" -1 use channel 1 (right) of stereo audio.\n" );
@@ -918,11 +930,11 @@ static void usage (void) {
918930 dw_printf (" bits per second.\n" );
919931 dw_printf ("\n" );
920932 dw_printf (" atest 02_Track_2.wav\n" );
921- dw_printf (" atest -P C+ 02_Track_2.wav\n" );
933+ dw_printf (" atest -P E- 02_Track_2.wav\n" );
922934 dw_printf (" atest -F 1 02_Track_2.wav\n" );
923- dw_printf (" atest -P C+ -F 1 02_Track_2.wav\n" );
935+ dw_printf (" atest -P E- -F 1 02_Track_2.wav\n" );
924936 dw_printf ("\n" );
925- dw_printf (" Try different combinations of options to find the best decoding\n" );
937+ dw_printf (" Try different combinations of options to compare decoding\n" );
926938 dw_printf (" performance.\n" );
927939
928940 exit (1 );
0 commit comments