Skip to content

Commit 200f669

Browse files
committed
PTT was being turned off too soon when sending Morse code.
Add capability to send DTMF tones. -qd option now suppresses complaints about telemetry packets. Handle more than 150 destinations in tocalls.txt.
1 parent 7a88785 commit 200f669

7 files changed

+265
-88
lines changed

Makefile.linux

+13-4
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ log2gpx : log2gpx.c textcolor.o misc.a
325325

326326
# Test application to generate sound.
327327

328-
gen_packets : gen_packets.c ax25_pad.c hdlc_send.c fcs_calc.c gen_tone.c morse.c textcolor.c dsp.c misc.a
328+
gen_packets : gen_packets.c ax25_pad.c hdlc_send.c fcs_calc.c gen_tone.c morse.c dtmf.c textcolor.c dsp.c misc.a
329329
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
330330

331331
# Unit test for AFSK demodulator
@@ -588,7 +588,7 @@ install-rpi : dw-start.sh
588588
# Combine some unit tests into a single regression sanity check.
589589

590590

591-
check : dtest ttest tttexttest pftest tlmtest lltest enctest kisstest pad2test xidtest check-modem1200 check-modem300 check-modem9600 check-modem19200 check-modem2400 check-modem4800
591+
check : dtest ttest tttexttest pftest tlmtest lltest enctest kisstest pad2test xidtest dtmftest check-modem1200 check-modem300 check-modem9600 check-modem19200 check-modem2400 check-modem4800
592592

593593
# Can we encode and decode at popular data rates?
594594

@@ -632,8 +632,8 @@ check-modem4800 : gen_packets atest
632632
# Unit test for inner digipeater algorithm
633633

634634
.PHONY : dtest
635-
dtest : digipeater.c dedupe.c \
636-
pfilter.o ax25_pad.o fcs_calc.o tq.o textcolor.o \
635+
dtest : digipeater.c dedupe.c pfilter.c \
636+
ax25_pad.o fcs_calc.o tq.o textcolor.o \
637637
decode_aprs.o dwgpsnmea.o dwgps.o dwgpsd.o serial_port.o latlong.o telemetry.o symbols.o tt_text.o misc.a
638638
$(CC) $(CFLAGS) -DDIGITEST -o $@ $^ $(LDFLAGS)
639639
./dtest
@@ -717,6 +717,15 @@ xidtest : xid.c textcolor.o misc.a
717717
rm xidtest
718718

719719

720+
# Unit Test for DTMF encode/decode.
721+
722+
.PHONY: dtmftest
723+
dtmftest : dtmf.c textcolor.o
724+
$(CC) $(CFLAGS) -DDTMF_TEST -o $@ $^ $(LDFLAGS)
725+
./dtmftest
726+
rm dtmftest
727+
728+
720729

721730
# ----------------------------- Manual tests and experiments ---------------------------
722731

Makefile.macosx

+1-1
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ log2gpx : log2gpx.c
437437

438438
# Test application to generate sound.
439439

440-
gen_packets : gen_packets.c ax25_pad.c hdlc_send.c fcs_calc.c gen_tone.c morse.c textcolor.c dsp.c
440+
gen_packets : gen_packets.c ax25_pad.c hdlc_send.c fcs_calc.c gen_tone.c morse.c dtmf.c textcolor.c dsp.c
441441
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS) -lm
442442

443443
demod.o : tune.h

decode_aprs.c

+22-7
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static void aprs_station_capabilities (decode_aprs_t *A, char *, int);
111111
static void aprs_status_report (decode_aprs_t *A, char *, int);
112112
static void aprs_general_query (decode_aprs_t *A, char *, int, int quiet);
113113
static void aprs_directed_station_query (decode_aprs_t *A, char *addressee, char *query, int quiet);
114-
static void aprs_telemetry (decode_aprs_t *A, char *, int, int quiet);
114+
static void aprs_telemetry (decode_aprs_t *A, char *info, int info_len, int quiet);
115115
static void aprs_raw_touch_tone (decode_aprs_t *A, char *, int);
116116
static void aprs_morse_code (decode_aprs_t *A, char *, int);
117117
static void aprs_positionless_weather_report (decode_aprs_t *A, unsigned char *, int);
@@ -3076,7 +3076,7 @@ double get_latitude_8 (char *p, int quiet)
30763076
return (G_UNKNOWN);
30773077
}
30783078

3079-
if (plat->minn[0] >= '0' || plat->minn[0] <= '5')
3079+
if (plat->minn[0] >= '0' && plat->minn[0] <= '5')
30803080
result += ((plat->minn[0]) - '0') * (10. / 60.);
30813081
else if (plat->minn[0] == ' ')
30823082
;
@@ -3239,7 +3239,7 @@ double get_longitude_9 (char *p, int quiet)
32393239
return (G_UNKNOWN);
32403240
}
32413241

3242-
if (plon->minn[0] >= '0' || plon->minn[0] <= '5')
3242+
if (plon->minn[0] >= '0' && plon->minn[0] <= '5')
32433243
result += ((plon->minn[0]) - '0') * (10. / 60.);
32443244
else if (plon->minn[0] == ' ')
32453245
;
@@ -3683,7 +3683,15 @@ static int data_extension_comment (decode_aprs_t *A, char *pdext)
36833683
*
36843684
*------------------------------------------------------------------*/
36853685

3686-
#define MAX_TOCALLS 150
3686+
// If I was more ambitious, this would dynamically allocate enough
3687+
// storage based on the file contents. Just stick in a constant for
3688+
// now. This takes an insignificant amount of space and
3689+
// I don't anticipate tocalls.txt growing that quickly.
3690+
// Version 1.4 - add message if too small instead of silently ignoring the rest.
3691+
3692+
// Dec. 2016 tocalls.txt has 153 destination addresses.
3693+
3694+
#define MAX_TOCALLS 200
36873695

36883696
static struct tocalls_s {
36893697
unsigned char len;
@@ -3780,7 +3788,7 @@ static void decode_tocall (decode_aprs_t *A, char *dest)
37803788
if (strlen(tocalls[num_tocalls].prefix) > 2) {
37813789
tocalls[num_tocalls].description = strdup(stuff+14);
37823790
tocalls[num_tocalls].len = strlen(tocalls[num_tocalls].prefix);
3783-
// dw_printf("debug: %d '%s' -> '%s'\n", tocalls[num_tocalls].len, tocalls[num_tocalls].prefix, tocalls[num_tocalls].description);
3791+
// dw_printf("debug %d: %d '%s' -> '%s'\n", num_tocalls, tocalls[num_tocalls].len, tocalls[num_tocalls].prefix, tocalls[num_tocalls].description);
37843792

37853793
num_tocalls++;
37863794
}
@@ -3804,11 +3812,15 @@ static void decode_tocall (decode_aprs_t *A, char *dest)
38043812
if (strlen(tocalls[num_tocalls].prefix) > 2) {
38053813
tocalls[num_tocalls].description = strdup(stuff+14);
38063814
tocalls[num_tocalls].len = strlen(tocalls[num_tocalls].prefix);
3807-
// dw_printf("debug: %d '%s' -> '%s'\n", tocalls[num_tocalls].len, tocalls[num_tocalls].prefix, tocalls[num_tocalls].description);
3815+
// dw_printf("debug %d: %d '%s' -> '%s'\n", num_tocalls, tocalls[num_tocalls].len, tocalls[num_tocalls].prefix, tocalls[num_tocalls].description);
38083816

38093817
num_tocalls++;
38103818
}
38113819
}
3820+
if (num_tocalls == MAX_TOCALLS) { // oops. might have discarded some.
3821+
text_color_set(DW_COLOR_ERROR);
3822+
dw_printf("MAX_TOCALLS needs to be larger than %d to handle contents of 'tocalls.txt'.\n", MAX_TOCALLS);
3823+
}
38123824
}
38133825
fclose(fp);
38143826

@@ -3832,9 +3844,12 @@ static void decode_tocall (decode_aprs_t *A, char *dest)
38323844
dw_printf("System types in the destination field will not be decoded.\n");
38333845
}
38343846
}
3835-
38363847

38373848
first_time = 0;
3849+
3850+
//for (n=0; n<num_tocalls; n++) {
3851+
// dw_printf("sorted %d: %d '%s' -> '%s'\n", n, tocalls[n].len, tocalls[n].prefix, tocalls[n].description);
3852+
//}
38383853
}
38393854

38403855

direwolf.c

+19-9
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
#include "aprs_tt.h"
108108
#include "tt_user.h"
109109
#include "igate.h"
110+
#include "pfilter.h"
110111
#include "symbols.h"
111112
#include "dwgps.h"
112113
#include "waypoint.h"
@@ -164,6 +165,8 @@ static struct tt_config_s tt_config;
164165
//struct digi_config_s digi_config;
165166
//struct cdigi_config_s cdigi_config;
166167

168+
static const int audio_amplitude = 100; /* % of audio sample range. */
169+
/* This translates to +-32k for 16 bit samples. */
167170

168171
static int d_u_opt = 0; /* "-d u" command line option to print UTF-8 also in hexadecimal. */
169172
static int d_p_opt = 0; /* "-d p" option for dumping packets over radio. */
@@ -254,7 +257,7 @@ int main (int argc, char *argv[])
254257
text_color_init(t_opt);
255258
text_color_set(DW_COLOR_INFO);
256259
//dw_printf ("Dire Wolf version %d.%d (%s) Beta Test\n", MAJOR_VERSION, MINOR_VERSION, __DATE__);
257-
dw_printf ("Dire Wolf DEVELOPMENT version %d.%d %s (%s)\n", MAJOR_VERSION, MINOR_VERSION, "D", __DATE__);
260+
dw_printf ("Dire Wolf DEVELOPMENT version %d.%d %s (%s)\n", MAJOR_VERSION, MINOR_VERSION, "E", __DATE__);
258261
//dw_printf ("Dire Wolf version %d.%d\n", MAJOR_VERSION, MINOR_VERSION);
259262

260263
#if defined(ENABLE_GPSD) || defined(USE_HAMLIB)
@@ -693,7 +696,7 @@ int main (int argc, char *argv[])
693696
/*
694697
* Initialize the touch tone decoder & APRStt gateway.
695698
*/
696-
dtmf_init (&audio_config);
699+
dtmf_init (&audio_config, audio_amplitude);
697700
aprs_tt_init (&tt_config);
698701
tt_user_init (&audio_config, &tt_config);
699702

@@ -702,8 +705,8 @@ int main (int argc, char *argv[])
702705
* Note: This is not the same as a volume control you would see on the screen.
703706
* It is the range of the digital sound representation.
704707
*/
705-
gen_tone_init (&audio_config, 100, 0);
706-
morse_init (&audio_config, 100);
708+
gen_tone_init (&audio_config, audio_amplitude, 0);
709+
morse_init (&audio_config, audio_amplitude);
707710

708711
assert (audio_config.adev[0].bits_per_sample == 8 || audio_config.adev[0].bits_per_sample == 16);
709712
assert (audio_config.adev[0].num_channels == 1 || audio_config.adev[0].num_channels == 2);
@@ -746,6 +749,7 @@ int main (int argc, char *argv[])
746749
digipeater_init (&audio_config, &digi_config);
747750
igate_init (&audio_config, &igate_config, &digi_config, d_i_opt);
748751
cdigipeater_init (&audio_config, &cdigi_config);
752+
//FIXME//pfilter_init (&igate_config, 0);
749753
ax25_link_init (&misc_config);
750754

751755
/*
@@ -1015,16 +1019,21 @@ void app_process_rec_packet (int chan, int subchan, int slice, packet_t pp, alev
10151019
}
10161020

10171021

1018-
/* Decode the contents of APRS frames and display in human-readable form. */
1019-
/* Suppress decoding if "-q d" option used. */
1020-
1022+
/*
1023+
* Decode the contents of UI frames and display in human-readable form.
1024+
* Could be APRS or anything random for old fashioned packet beacons.
1025+
*
1026+
* Suppress printed decoding if "-q d" option used.
1027+
*/
10211028

10221029
if (ax25_is_aprs(pp)) {
10231030

10241031
decode_aprs_t A;
10251032

1026-
decode_aprs (&A, pp, 0);
1033+
// we still want to decode it for logging and other processing.
1034+
// Just be quiet about errors if "-qd" is set.
10271035

1036+
decode_aprs (&A, pp, q_d_opt);
10281037

10291038
if ( ! q_d_opt ) {
10301039

@@ -1046,9 +1055,10 @@ void app_process_rec_packet (int chan, int subchan, int slice, packet_t pp, alev
10461055
// temp experiment.
10471056
//log_rr_bits (&A, pp);
10481057

1049-
// Add to list of stations heard.
1058+
// Add to list of stations heard over the radio.
10501059

10511060
mheard_save (chan, &A, pp, alevel, retries);
1061+
//FIXME//mheard_save_rf (chan, &A, pp, alevel, retries);
10521062

10531063

10541064
// Convert to NMEA waypoint sentence if we have a location.

0 commit comments

Comments
 (0)