42
42
#include "demod_9600.h" /* for descramble() */
43
43
#include "ptt.h"
44
44
45
+ #if __WIN32__
46
+ #else
47
+ #include <fcntl.h>
48
+ #include <errno.h>
49
+ #include <string.h>
50
+ #endif
51
+
45
52
46
53
//#define TEST 1 /* Define for unit testing. */
47
54
@@ -125,6 +132,8 @@ static void dcd_change (int chan, int subchan, int state);
125
132
*
126
133
***********************************************************************************/
127
134
135
+ static struct audio_s * save_audio_config_p ;
136
+
128
137
static int was_init = 0 ;
129
138
130
139
void hdlc_rec_init (struct audio_s * pa )
@@ -137,6 +146,8 @@ void hdlc_rec_init (struct audio_s *pa)
137
146
138
147
assert (pa != NULL );
139
148
149
+ save_audio_config_p = pa ;
150
+
140
151
for (j = 0 ; j < MAX_CHANS ; j ++ )
141
152
{
142
153
composite_dcd [j ] = 0 ;
@@ -632,10 +643,46 @@ static void dcd_change (int chan, int subchan, int state)
632
643
int hdlc_rec_data_detect_any (int chan )
633
644
{
634
645
int subchan ;
646
+ int busy ;
635
647
636
648
assert (chan >= 0 && chan < MAX_CHANS );
637
649
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 ;
639
686
640
687
} /* end hdlc_rec_data_detect_any */
641
688
0 commit comments