Skip to content

Commit 401db2d

Browse files
committed
Add TXINH check to hdlc_data_detect_any
1 parent 0d7003b commit 401db2d

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

Diff for: hdlc_rec.c

+48-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@
4242
#include "demod_9600.h" /* for descramble() */
4343
#include "ptt.h"
4444

45+
#if __WIN32__
46+
#else
47+
#include <fcntl.h>
48+
#include <errno.h>
49+
#include <string.h>
50+
#endif
51+
4552

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

@@ -125,6 +132,8 @@ static void dcd_change (int chan, int subchan, int state);
125132
*
126133
***********************************************************************************/
127134

135+
static struct audio_s *save_audio_config_p;
136+
128137
static int was_init = 0;
129138

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

138147
assert (pa != NULL);
139148

149+
save_audio_config_p = pa;
150+
140151
for (j=0; j<MAX_CHANS; j++)
141152
{
142153
composite_dcd[j] = 0;
@@ -632,10 +643,46 @@ static void dcd_change (int chan, int subchan, int state)
632643
int hdlc_rec_data_detect_any (int chan)
633644
{
634645
int subchan;
646+
int busy;
635647

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

638-
return (composite_dcd[chan] != 0);
650+
if (composite_dcd[chan] != 0) busy = 1;
651+
652+
#if __WIN32__
653+
#else
654+
655+
if (save_audio_config_p->achan[chan].txinh.enabled) {
656+
int fd;
657+
char stemp[80];
658+
659+
sprintf (stemp, "/sys/class/gpio/gpio%d/value", save_audio_config_p->achan[chan].txinh.gpio);
660+
661+
fd = open(stemp, O_RDONLY);
662+
if (fd < 0) {
663+
int e = errno;
664+
text_color_set(DW_COLOR_ERROR);
665+
dw_printf ("Error opening %s to check TXINH.\n", stemp);
666+
dw_printf ("%s\n", strerror(e));
667+
return;
668+
}
669+
670+
if (read (fd, stemp, 1) != 1) {
671+
int e = errno;
672+
text_color_set(DW_COLOR_ERROR);
673+
dw_printf ("Error getting GPIO %d value for TXINH\n", save_audio_config_p->achan[chan].txinh.gpio);
674+
dw_printf ("%s\n", strerror(e));
675+
}
676+
close (fd);
677+
678+
char vtemp[2];
679+
sprintf (vtemp, "%d", save_audio_config_p->achan[chan].txinh.invert);
680+
681+
if (!strcmp (stemp, vtemp)) busy = 1;
682+
}
683+
#endif
684+
685+
return busy;
639686

640687
} /* end hdlc_rec_data_detect_any */
641688

0 commit comments

Comments
 (0)