Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - Added channel INTERLOCK functionality #422

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixes bug in added channel INTERLOCK functionality
DCD state could get stuck which blocked PTT, now fixed.
  • Loading branch information
dvanderlocht committed Sep 15, 2022
commit 675e5484ca6b99cf04a8ce53832b175d08a495c5
8 changes: 8 additions & 0 deletions src/atest.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
#include "hdlc_rec.h"



#if 0 /* Typical but not flexible enough. */

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


/* Fake is_channel_busy */
int is_channel_busy(int chan)
{
return 0;
}


void ptt_set (int ot, int chan, int ptt_signal)
{
// Should only get here for DCD output control.
Expand Down
10 changes: 10 additions & 0 deletions src/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ struct audio_s {

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

/* Interlock channels */
int interlock; /* Interlock number */


/* Additional properties for transmit. */
Expand Down Expand Up @@ -451,6 +453,14 @@ struct audio_s {
#define DEFAULT_TXTAIL 10
#define DEFAULT_FULLDUP 0

/*
* Interlocks are used to 'bind' channels together 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.
*/

#define MAX_INTERLOCKS 8

/*
* Note that we have two versions of these in audio.c and audio_win.c.
* Use one or the other depending on the platform.
Expand Down
19 changes: 19 additions & 0 deletions src/ax25_link.c
Original file line number Diff line number Diff line change
Expand Up @@ -1998,6 +1998,25 @@ void lm_channel_busy (dlq_item_t *E)
} /* end lm_channel_busy */


/*------------------------------------------------------------------------------
*
* Name: is_channel_busy
*
* Purpose: Returns PTT status for channel
*
* Inputs: Channel
*
* Outputs: True when busy, false when free
*
*------------------------------------------------------------------------------*/

int is_channel_busy(int chan)
{
if (ptt_status[chan])
return 1;

return 0;
} /* end is_channel_busy */


/*------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src/ax25_link.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ void lm_seize_confirm (dlq_item_t *E);

void lm_channel_busy (dlq_item_t *E);

int is_channel_busy(int chan);

void dl_timer_expiry (void);

Expand Down
29 changes: 29 additions & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,8 @@ void config_init (char *fname, struct audio_s *p_audio_config,
p_audio_config->achan[channel].sanity_test = SANITY_APRS;
p_audio_config->achan[channel].passall = 0;

p_audio_config->achan[channel].interlock = 0;

for (ot = 0; ot < NUM_OCTYPES; ot++) {
p_audio_config->achan[channel].octrl[ot].ptt_method = PTT_METHOD_NONE;
strlcpy (p_audio_config->achan[channel].octrl[ot].ptt_device, "", sizeof(p_audio_config->achan[channel].octrl[ot].ptt_device));
Expand Down Expand Up @@ -1729,6 +1731,33 @@ void config_init (char *fname, struct audio_s *p_audio_config,
}
}

/*
* INTERLOCK n
*
* Interlocks channels with the same interlock number (n) 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.
*/

else if (strcasecmp(t, "INTERLOCK") == 0) {
int n;
t = split(NULL,0);
if (t == NULL) {
text_color_set(DW_COLOR_ERROR);
dw_printf ("Line %d: Missing number for INTERLOCK command.\n", line);
continue;
}
n = atoi(t);
if (n >= 0 && n <= MAX_INTERLOCKS) {
p_audio_config->achan[channel].interlock = n;
}
else {
p_audio_config->achan[channel].interlock = 0;
text_color_set(DW_COLOR_ERROR);
dw_printf ("Line %d: Invalid number for INTERLOCK. Using %d.\n",
line, p_audio_config->achan[channel].interlock);
}
}

/*
* PTT - Push To Talk signal line.
Expand Down
30 changes: 25 additions & 5 deletions src/hdlc_rec.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "ptt.h"
#include "fx25.h"
#include "il2p.h"
#include "ax25_link.h"


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

int sc;
int ch;
int il;
assert (chan >= 0 && chan < MAX_CHANS);

for (sc = 0; sc < num_subchan[chan]; sc++) {
if (composite_dcd[chan][sc] != 0)
return (1);
if (g_audio_p->achan[chan].interlock > 0) {
// Channel has an interlock number configured, proceed checking interlocked channels
il = g_audio_p->achan[chan].interlock;

for (ch = 0; ch < MAX_CHANS; ch++) {
if (g_audio_p->achan[ch].interlock == il) {
// Check DCD state
for (sc = 0; sc < num_subchan[ch]; sc++) {
if (composite_dcd[ch][sc] != 0)
return (1);
}
// Check PTT state at data link state machine
if (is_channel_busy(ch))
return (1);
}
}
} else {
// No interlock
for (sc = 0; sc < num_subchan[chan]; sc++) {
if (composite_dcd[chan][sc] != 0)
return (1);
}
}

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

/* end hdlc_rec.c */


6 changes: 5 additions & 1 deletion src/rrbb.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ rrbb_t rrbb_new (int chan, int subchan, int slice, int is_scrambled, int descram

new_count++;

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