Skip to content
Prev Previous commit
Next Next commit
Add TXINH check to hdlc_data_detect_any
  • Loading branch information
ab0tj committed Nov 12, 2015
commit 401db2d1d5e562345ff54890ed6ae4c63fdec56f
49 changes: 48 additions & 1 deletion hdlc_rec.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@
#include "demod_9600.h" /* for descramble() */
#include "ptt.h"

#if __WIN32__
#else
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#endif


//#define TEST 1 /* Define for unit testing. */

Expand Down Expand Up @@ -125,6 +132,8 @@ static void dcd_change (int chan, int subchan, int state);
*
***********************************************************************************/

static struct audio_s *save_audio_config_p;

static int was_init = 0;

void hdlc_rec_init (struct audio_s *pa)
Expand All @@ -137,6 +146,8 @@ void hdlc_rec_init (struct audio_s *pa)

assert (pa != NULL);

save_audio_config_p = pa;

for (j=0; j<MAX_CHANS; j++)
{
composite_dcd[j] = 0;
Expand Down Expand Up @@ -632,10 +643,46 @@ static void dcd_change (int chan, int subchan, int state)
int hdlc_rec_data_detect_any (int chan)
{
int subchan;
int busy;

assert (chan >= 0 && chan < MAX_CHANS);

return (composite_dcd[chan] != 0);
if (composite_dcd[chan] != 0) busy = 1;

#if __WIN32__
#else

if (save_audio_config_p->achan[chan].txinh.enabled) {
int fd;
char stemp[80];

sprintf (stemp, "/sys/class/gpio/gpio%d/value", save_audio_config_p->achan[chan].txinh.gpio);

fd = open(stemp, O_RDONLY);
if (fd < 0) {
int e = errno;
text_color_set(DW_COLOR_ERROR);
dw_printf ("Error opening %s to check TXINH.\n", stemp);
dw_printf ("%s\n", strerror(e));
return;
}

if (read (fd, stemp, 1) != 1) {
int e = errno;
text_color_set(DW_COLOR_ERROR);
dw_printf ("Error getting GPIO %d value for TXINH\n", save_audio_config_p->achan[chan].txinh.gpio);
dw_printf ("%s\n", strerror(e));
}
close (fd);

char vtemp[2];
sprintf (vtemp, "%d", save_audio_config_p->achan[chan].txinh.invert);

if (!strcmp (stemp, vtemp)) busy = 1;
}
#endif

return busy;

} /* end hdlc_rec_data_detect_any */

Expand Down