Skip to content

Commit 29b82e2

Browse files
author
Dave van der Locht
committed
Added channel interlock functionality
New INTERLOCK parameter for config file interlocks all channels with the same interlock number configured to share DCD and PTT signaling. Useful with several setup types where 2 or more channels shouldn't interfere with eachother. For example when radios and/or antennas are shared.
1 parent c9ffbd7 commit 29b82e2

File tree

6 files changed

+85
-3
lines changed

6 files changed

+85
-3
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 DCD or 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] || dcd_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

+27
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,31 @@ 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+
*/
1739+
1740+
else if (strcasecmp(t, "INTERLOCK") == 0) {
1741+
int n;
1742+
t = split(NULL,0);
1743+
if (t == NULL) {
1744+
text_color_set(DW_COLOR_ERROR);
1745+
dw_printf ("Line %d: Missing number for INTERLOCK command.\n", line);
1746+
continue;
1747+
}
1748+
n = atoi(t);
1749+
if (n >= 0 && n <= MAX_INTERLOCKS) {
1750+
p_audio_config->achan[channel].interlock = n;
1751+
}
1752+
else {
1753+
p_audio_config->achan[channel].interlock = 0;
1754+
text_color_set(DW_COLOR_ERROR);
1755+
dw_printf ("Line %d: Invalid number for INTERLOCK. Using %d.\n",
1756+
line, p_audio_config->achan[channel].interlock);
1757+
}
1758+
}
17321759

17331760
/*
17341761
* PTT - Push To Talk signal line.

Diff for: src/hdlc_rec.c

+20-3
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,27 @@ 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 and PTT state at data link state machine
806+
if (is_channel_busy(ch))
807+
return (1);
808+
}
809+
}
810+
} else {
811+
// No interlock
812+
for (sc = 0; sc < num_subchan[chan]; sc++) {
813+
if (composite_dcd[chan][sc] != 0)
814+
return (1);
815+
}
799816
}
800817

801818
if (get_input(ICTYPE_TXINH, chan) == 1) return (1);

0 commit comments

Comments
 (0)