Skip to content

Commit c41841e

Browse files
committed
New -T command line option for timestamps.
1 parent d8e9273 commit c41841e

File tree

3 files changed

+92
-29
lines changed

3 files changed

+92
-29
lines changed

audio.h

+4
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ struct audio_s {
9797

9898
int recv_error_rate; /* Similar but the % probablity of dropping a received frame. */
9999

100+
char timestamp_format[40]; /* -T option */
101+
/* Precede received & transmitted frames with timestamp. */
102+
/* Command line option uses "strftime" format string. */
103+
100104

101105
/* Properties for each audio channel, common to receive and transmit. */
102106
/* Can be different for each radio channel. */

direwolf.c

+37-24
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
#include "morse.h"
118118
#include "mheard.h"
119119
#include "ax25_link.h"
120+
#include "dtime_now.h"
120121

121122

122123
//static int idx_decoded = 0;
@@ -163,8 +164,8 @@ static void __cpuid(int cpuinfo[4], int infotype){
163164

164165
static struct audio_s audio_config;
165166
static struct tt_config_s tt_config;
166-
//struct digi_config_s digi_config;
167-
//struct cdigi_config_s cdigi_config;
167+
static struct misc_config_s misc_config;
168+
168169

169170
static const int audio_amplitude = 100; /* % of audio sample range. */
170171
/* This translates to +-32k for 16 bit samples. */
@@ -178,9 +179,6 @@ static int q_d_opt = 0; /* "-q d" Quiet, suppress the printing of decoded of A
178179

179180

180181

181-
static struct misc_config_s misc_config;
182-
183-
184182
int main (int argc, char *argv[])
185183
{
186184
int err;
@@ -197,7 +195,7 @@ int main (int argc, char *argv[])
197195
char l_opt_logdir[80];
198196
char L_opt_logfile[80];
199197
char input_file[80];
200-
// char timestamp[16];
198+
char T_opt_timestamp[40];
201199

202200
int t_opt = 1; /* Text color option. */
203201
int a_opt = 0; /* "-a n" interval, in seconds, for audio statistics report. 0 for none. */
@@ -219,6 +217,7 @@ int main (int argc, char *argv[])
219217
strlcpy(l_opt_logdir, "", sizeof(l_opt_logdir));
220218
strlcpy(L_opt_logfile, "", sizeof(L_opt_logfile));
221219
strlcpy(P_opt, "", sizeof(P_opt));
220+
strlcpy(T_opt_timestamp, "", sizeof(T_opt_timestamp));
222221

223222
#if __WIN32__
224223

@@ -263,26 +262,21 @@ int main (int argc, char *argv[])
263262

264263
text_color_init(t_opt);
265264
text_color_set(DW_COLOR_INFO);
266-
//dw_printf ("Dire Wolf version %d.%d (%s) Beta Test\n", MAJOR_VERSION, MINOR_VERSION, __DATE__);
267-
dw_printf ("Dire Wolf DEVELOPMENT version %d.%d %s (%s)\n", MAJOR_VERSION, MINOR_VERSION, "C", __DATE__);
265+
dw_printf ("Dire Wolf version %d.%d (%s) Beta Test\n", MAJOR_VERSION, MINOR_VERSION, __DATE__);
266+
//dw_printf ("Dire Wolf DEVELOPMENT version %d.%d %s (%s)\n", MAJOR_VERSION, MINOR_VERSION, "C", __DATE__);
268267
//dw_printf ("Dire Wolf version %d.%d\n", MAJOR_VERSION, MINOR_VERSION);
269268

270-
// FIXME: temp test
271-
272-
// timestamp_now (timestamp, sizeof(timestamp), 1);
273-
// dw_printf ("%s\n", timestamp);
274-
275-
276-
277-
278269

279-
#if defined(ENABLE_GPSD) || defined(USE_HAMLIB)
270+
#if defined(ENABLE_GPSD) || defined(USE_HAMLIB) || defined(USE_CM108)
280271
dw_printf ("Includes optional support for: ");
281272
#if defined(ENABLE_GPSD)
282273
dw_printf (" gpsd");
283274
#endif
284275
#if defined(USE_HAMLIB)
285276
dw_printf (" hamlib");
277+
#endif
278+
#if defined(USE_CM108)
279+
dw_printf (" cm108-ptt");
286280
#endif
287281
dw_printf ("\n");
288282
#endif
@@ -358,7 +352,7 @@ int main (int argc, char *argv[])
358352

359353
/* ':' following option character means arg is required. */
360354

361-
c = getopt_long(argc, argv, "P:B:D:c:pxr:b:n:d:q:t:Ul:L:Sa:E:",
355+
c = getopt_long(argc, argv, "P:B:D:c:pxr:b:n:d:q:t:Ul:L:Sa:E:T:",
362356
long_options, &option_index);
363357
if (c == -1)
364358
break;
@@ -573,6 +567,10 @@ int main (int argc, char *argv[])
573567
}
574568
break;
575569

570+
case 'T': /* -T for receive timestamp. */
571+
strlcpy (T_opt_timestamp, optarg, sizeof(T_opt_timestamp));
572+
break;
573+
576574
default:
577575

578576
/* Should not be here. */
@@ -676,6 +674,8 @@ int main (int argc, char *argv[])
676674
audio_config.achan[0].decimate = D_opt;
677675
}
678676

677+
strlcpy(audio_config.timestamp_format, T_opt_timestamp, sizeof(audio_config.timestamp_format));
678+
679679
// temp - only xmit errors.
680680

681681
audio_config.xmit_error_rate = E_tx_opt;
@@ -965,9 +965,21 @@ void app_process_rec_packet (int chan, int subchan, int slice, packet_t pp, alev
965965

966966
// -1 for APRStt DTMF decoder.
967967

968+
char ts[100]; // optional time stamp
969+
970+
if (strlen(audio_config.timestamp_format) > 0) {
971+
char tstmp[100];
972+
timestamp_user_format (tstmp, sizeof(tstmp), audio_config.timestamp_format);
973+
strlcpy (ts, " ", sizeof(ts)); // space after channel.
974+
strlcat (ts, tstmp, sizeof(ts));
975+
}
976+
else {
977+
strlcpy (ts, "", sizeof(ts));
978+
}
979+
968980
if (subchan == -1) {
969981
text_color_set(DW_COLOR_REC);
970-
dw_printf ("[%d.dtmf] ", chan);
982+
dw_printf ("[%d.dtmf%s] ", chan, ts);
971983
}
972984
else {
973985
if (ax25_is_aprs(pp)) {
@@ -978,16 +990,16 @@ void app_process_rec_packet (int chan, int subchan, int slice, packet_t pp, alev
978990
}
979991

980992
if (audio_config.achan[chan].num_subchan > 1 && audio_config.achan[chan].num_slicers == 1) {
981-
dw_printf ("[%d.%d] ", chan, subchan);
993+
dw_printf ("[%d.%d%s] ", chan, subchan, ts);
982994
}
983995
else if (audio_config.achan[chan].num_subchan == 1 && audio_config.achan[chan].num_slicers > 1) {
984-
dw_printf ("[%d.%d] ", chan, slice);
996+
dw_printf ("[%d.%d%s] ", chan, slice, ts);
985997
}
986998
else if (audio_config.achan[chan].num_subchan > 1 && audio_config.achan[chan].num_slicers > 1) {
987-
dw_printf ("[%d.%d.%d] ", chan, subchan, slice);
999+
dw_printf ("[%d.%d.%d%s] ", chan, subchan, slice, ts);
9881000
}
9891001
else {
990-
dw_printf ("[%d] ", chan);
1002+
dw_printf ("[%d%s] ", chan, ts);
9911003
}
9921004
}
9931005

@@ -1011,7 +1023,7 @@ void app_process_rec_packet (int chan, int subchan, int slice, packet_t pp, alev
10111023
dw_printf ("(%s)", desc);
10121024
if (ftype == frame_type_U_XID) {
10131025
struct xid_param_s param;
1014-
char info2text[100];
1026+
char info2text[150];
10151027

10161028
xid_parse (pinfo, info_len, &param, info2text, sizeof(info2text));
10171029
dw_printf (" %s\n", info2text);
@@ -1271,6 +1283,7 @@ static void usage (char **argv)
12711283
dw_printf (" -x Send Xmit level calibration tones.\n");
12721284
dw_printf (" -U Print UTF-8 test string and exit.\n");
12731285
dw_printf (" -S Print symbol tables and exit.\n");
1286+
dw_printf (" -T fmt Time stamp format for sent and received frames.\n");
12741287
dw_printf ("\n");
12751288

12761289
dw_printf ("After any options, there can be a single command line argument for the source of\n");

xmit.c

+51-5
Original file line numberDiff line numberDiff line change
@@ -916,10 +916,22 @@ static int send_one_frame (int c, int p, packet_t pp)
916916
return(0);
917917
}
918918

919+
char ts[100]; // optional time stamp.
920+
921+
if (strlen(save_audio_config_p->timestamp_format) > 0) {
922+
char tstmp[100];
923+
timestamp_user_format (tstmp, sizeof(tstmp), save_audio_config_p->timestamp_format);
924+
strlcpy (ts, " ", sizeof(ts)); // space after channel.
925+
strlcat (ts, tstmp, sizeof(ts));
926+
}
927+
else {
928+
strlcpy (ts, "", sizeof(ts));
929+
}
930+
919931
ax25_format_addrs (pp, stemp);
920932
info_len = ax25_get_info (pp, &pinfo);
921933
text_color_set(DW_COLOR_XMIT);
922-
dw_printf ("[%d%c] ", c, p==TQ_PRIO_0_HI ? 'H' : 'L');
934+
dw_printf ("[%d%c%s] ", c, p==TQ_PRIO_0_HI ? 'H' : 'L', ts);
923935
dw_printf ("%s", stemp); /* stations followed by : */
924936

925937
/* Demystify non-APRS. Use same format for received frames in direwolf.c. */
@@ -938,7 +950,7 @@ static int send_one_frame (int c, int p, packet_t pp)
938950

939951
if (ftype == frame_type_U_XID) {
940952
struct xid_param_s param;
941-
char info2text[100];
953+
char info2text[150];
942954

943955
xid_parse (pinfo, info_len, &param, info2text, sizeof(info2text));
944956
dw_printf (" %s\n", info2text);
@@ -1021,11 +1033,23 @@ static void xmit_speech (int c, packet_t pp)
10211033
* Print spoken packet. Prefix by channel.
10221034
*/
10231035

1036+
char ts[100]; // optional time stamp.
1037+
1038+
if (strlen(save_audio_config_p->timestamp_format) > 0) {
1039+
char tstmp[100];
1040+
timestamp_user_format (tstmp, sizeof(tstmp), save_audio_config_p->timestamp_format);
1041+
strlcpy (ts, " ", sizeof(ts)); // space after channel.
1042+
strlcat (ts, tstmp, sizeof(ts));
1043+
}
1044+
else {
1045+
strlcpy (ts, "", sizeof(ts));
1046+
}
1047+
10241048
info_len = ax25_get_info (pp, &pinfo);
10251049
(void)info_len;
10261050

10271051
text_color_set(DW_COLOR_XMIT);
1028-
dw_printf ("[%d.speech] \"%s\"\n", c, pinfo);
1052+
dw_printf ("[%d.speech%s] \"%s\"\n", c, pinfo, ts);
10291053

10301054

10311055
if (strlen(save_audio_config_p->tts_script) == 0) {
@@ -1136,11 +1160,22 @@ static void xmit_morse (int c, packet_t pp, int wpm)
11361160
int length_ms, wait_ms;
11371161
double start_ptt, wait_until, now;
11381162

1163+
char ts[100]; // optional time stamp.
1164+
1165+
if (strlen(save_audio_config_p->timestamp_format) > 0) {
1166+
char tstmp[100];
1167+
timestamp_user_format (tstmp, sizeof(tstmp), save_audio_config_p->timestamp_format);
1168+
strlcpy (ts, " ", sizeof(ts)); // space after channel.
1169+
strlcat (ts, tstmp, sizeof(ts));
1170+
}
1171+
else {
1172+
strlcpy (ts, "", sizeof(ts));
1173+
}
11391174

11401175
info_len = ax25_get_info (pp, &pinfo);
11411176
(void)info_len;
11421177
text_color_set(DW_COLOR_XMIT);
1143-
dw_printf ("[%d.morse] \"%s\"\n", c, pinfo);
1178+
dw_printf ("[%d.morse%s] \"%s\"\n", c, pinfo, ts);
11441179

11451180
ptt_set (OCTYPE_PTT, c, 1);
11461181
start_ptt = dtime_now();
@@ -1197,11 +1232,22 @@ static void xmit_dtmf (int c, packet_t pp, int speed)
11971232
int length_ms, wait_ms;
11981233
double start_ptt, wait_until, now;
11991234

1235+
char ts[100]; // optional time stamp.
1236+
1237+
if (strlen(save_audio_config_p->timestamp_format) > 0) {
1238+
char tstmp[100];
1239+
timestamp_user_format (tstmp, sizeof(tstmp), save_audio_config_p->timestamp_format);
1240+
strlcpy (ts, " ", sizeof(ts)); // space after channel.
1241+
strlcat (ts, tstmp, sizeof(ts));
1242+
}
1243+
else {
1244+
strlcpy (ts, "", sizeof(ts));
1245+
}
12001246

12011247
info_len = ax25_get_info (pp, &pinfo);
12021248
(void)info_len;
12031249
text_color_set(DW_COLOR_XMIT);
1204-
dw_printf ("[%d.dtmf] \"%s\"\n", c, pinfo);
1250+
dw_printf ("[%d.dtmf%s] \"%s\"\n", c, pinfo, ts);
12051251

12061252
ptt_set (OCTYPE_PTT, c, 1);
12071253
start_ptt = dtime_now();

0 commit comments

Comments
 (0)