Skip to content

Commit 675e548

Browse files
committed
Fixes bug in added channel INTERLOCK functionality
DCD state could get stuck which blocked PTT, now fixed.
1 parent c9ffbd7 commit 675e548

File tree

7 files changed

+97
-6
lines changed

7 files changed

+97
-6
lines changed

Diff for: src/atest.c

+8
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
#include "hdlc_rec.h"
8787

8888

89+
8990
#if 0 /* Typical but not flexible enough. */
9091

9192
struct wav_header { /* .WAV file header. */
@@ -900,6 +901,13 @@ void dlq_rec_frame (int chan, int subchan, int slice, packet_t pp, alevel_t alev
900901
} /* end fake dlq_append */
901902

902903

904+
/* Fake is_channel_busy */
905+
int is_channel_busy(int chan)
906+
{
907+
return 0;
908+
}
909+
910+
903911
void ptt_set (int ot, int chan, int ptt_signal)
904912
{
905913
// Should only get here for DCD output control.

Diff for: src/audio.h

+10
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ struct audio_s {
245245

246246
int passall; /* Allow thru even with bad CRC. */
247247

248+
/* Interlock channels */
249+
int interlock; /* Interlock number */
248250

249251

250252
/* Additional properties for transmit. */
@@ -451,6 +453,14 @@ struct audio_s {
451453
#define DEFAULT_TXTAIL 10
452454
#define DEFAULT_FULLDUP 0
453455

456+
/*
457+
* Interlocks are used to 'bind' channels together to share DCD and PTT signaling.
458+
* Useful with several setup types where 2 or more channels shouldn't interfere with eachother.
459+
* For example when radios and/or antennas are shared.
460+
*/
461+
462+
#define MAX_INTERLOCKS 8
463+
454464
/*
455465
* Note that we have two versions of these in audio.c and audio_win.c.
456466
* Use one or the other depending on the platform.

Diff for: src/ax25_link.c

+19
Original file line numberDiff line numberDiff line change
@@ -1998,6 +1998,25 @@ void lm_channel_busy (dlq_item_t *E)
19981998
} /* end lm_channel_busy */
19991999

20002000

2001+
/*------------------------------------------------------------------------------
2002+
*
2003+
* Name: is_channel_busy
2004+
*
2005+
* Purpose: Returns PTT status for channel
2006+
*
2007+
* Inputs: Channel
2008+
*
2009+
* Outputs: True when busy, false when free
2010+
*
2011+
*------------------------------------------------------------------------------*/
2012+
2013+
int is_channel_busy(int chan)
2014+
{
2015+
if (ptt_status[chan])
2016+
return 1;
2017+
2018+
return 0;
2019+
} /* end is_channel_busy */
20012020

20022021

20032022
/*------------------------------------------------------------------------------

Diff for: src/ax25_link.h

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ void lm_seize_confirm (dlq_item_t *E);
7676

7777
void lm_channel_busy (dlq_item_t *E);
7878

79+
int is_channel_busy(int chan);
7980

8081
void dl_timer_expiry (void);
8182

Diff for: src/config.c

+29
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,8 @@ void config_init (char *fname, struct audio_s *p_audio_config,
780780
p_audio_config->achan[channel].sanity_test = SANITY_APRS;
781781
p_audio_config->achan[channel].passall = 0;
782782

783+
p_audio_config->achan[channel].interlock = 0;
784+
783785
for (ot = 0; ot < NUM_OCTYPES; ot++) {
784786
p_audio_config->achan[channel].octrl[ot].ptt_method = PTT_METHOD_NONE;
785787
strlcpy (p_audio_config->achan[channel].octrl[ot].ptt_device, "", sizeof(p_audio_config->achan[channel].octrl[ot].ptt_device));
@@ -1729,6 +1731,33 @@ void config_init (char *fname, struct audio_s *p_audio_config,
17291731
}
17301732
}
17311733

1734+
/*
1735+
* INTERLOCK n
1736+
*
1737+
* Interlocks channels with the same interlock number (n) to share DCD and PTT signaling.
1738+
* Useful with several setup types where 2 or more channels shouldn't interfere with eachother.
1739+
* For example when radios and/or antennas are shared.
1740+
*/
1741+
1742+
else if (strcasecmp(t, "INTERLOCK") == 0) {
1743+
int n;
1744+
t = split(NULL,0);
1745+
if (t == NULL) {
1746+
text_color_set(DW_COLOR_ERROR);
1747+
dw_printf ("Line %d: Missing number for INTERLOCK command.\n", line);
1748+
continue;
1749+
}
1750+
n = atoi(t);
1751+
if (n >= 0 && n <= MAX_INTERLOCKS) {
1752+
p_audio_config->achan[channel].interlock = n;
1753+
}
1754+
else {
1755+
p_audio_config->achan[channel].interlock = 0;
1756+
text_color_set(DW_COLOR_ERROR);
1757+
dw_printf ("Line %d: Invalid number for INTERLOCK. Using %d.\n",
1758+
line, p_audio_config->achan[channel].interlock);
1759+
}
1760+
}
17321761

17331762
/*
17341763
* PTT - Push To Talk signal line.

Diff for: src/hdlc_rec.c

+25-5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include "ptt.h"
4848
#include "fx25.h"
4949
#include "il2p.h"
50+
#include "ax25_link.h"
5051

5152

5253
//#define TEST 1 /* Define for unit testing. */
@@ -791,11 +792,32 @@ int hdlc_rec_data_detect_any (int chan)
791792
{
792793

793794
int sc;
795+
int ch;
796+
int il;
794797
assert (chan >= 0 && chan < MAX_CHANS);
795798

796-
for (sc = 0; sc < num_subchan[chan]; sc++) {
797-
if (composite_dcd[chan][sc] != 0)
798-
return (1);
799+
if (g_audio_p->achan[chan].interlock > 0) {
800+
// Channel has an interlock number configured, proceed checking interlocked channels
801+
il = g_audio_p->achan[chan].interlock;
802+
803+
for (ch = 0; ch < MAX_CHANS; ch++) {
804+
if (g_audio_p->achan[ch].interlock == il) {
805+
// Check DCD state
806+
for (sc = 0; sc < num_subchan[ch]; sc++) {
807+
if (composite_dcd[ch][sc] != 0)
808+
return (1);
809+
}
810+
// Check PTT state at data link state machine
811+
if (is_channel_busy(ch))
812+
return (1);
813+
}
814+
}
815+
} else {
816+
// No interlock
817+
for (sc = 0; sc < num_subchan[chan]; sc++) {
818+
if (composite_dcd[chan][sc] != 0)
819+
return (1);
820+
}
799821
}
800822

801823
if (get_input(ICTYPE_TXINH, chan) == 1) return (1);
@@ -805,5 +827,3 @@ int hdlc_rec_data_detect_any (int chan)
805827
} /* end hdlc_rec_data_detect_any */
806828

807829
/* end hdlc_rec.c */
808-
809-

Diff for: src/rrbb.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ rrbb_t rrbb_new (int chan, int subchan, int slice, int is_scrambled, int descram
101101

102102
new_count++;
103103

104-
if (new_count > delete_count + 100) {
104+
/*
105+
A value of delete_count + 100 seems to give issues with multiple channels and freq. offset decoding configured
106+
extended to 168 for testing a max. with 3 channels and 7 offset decoders p/channel
107+
*/
108+
if (new_count > delete_count + 168) {
105109
text_color_set(DW_COLOR_ERROR);
106110
dw_printf ("MEMORY LEAK, rrbb_new, new_count=%d, delete_count=%d\n", new_count, delete_count);
107111
}

0 commit comments

Comments
 (0)