From 401db2d1d5e562345ff54890ed6ae4c63fdec56f Mon Sep 17 00:00:00 2001 From: Alex Swedenburg Date: Thu, 12 Nov 2015 14:20:41 -0700 Subject: [PATCH] Add TXINH check to hdlc_data_detect_any --- hdlc_rec.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/hdlc_rec.c b/hdlc_rec.c index e645ee1..f832204 100644 --- a/hdlc_rec.c +++ b/hdlc_rec.c @@ -42,6 +42,13 @@ #include "demod_9600.h" /* for descramble() */ #include "ptt.h" +#if __WIN32__ +#else +#include +#include +#include +#endif + //#define TEST 1 /* Define for unit testing. */ @@ -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) @@ -137,6 +146,8 @@ void hdlc_rec_init (struct audio_s *pa) assert (pa != NULL); + save_audio_config_p = pa; + for (j=0; j= 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 */