aboutsummaryrefslogtreecommitdiffstats
path: root/utils/rtl_adsb.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils/rtl_adsb.c')
-rw-r--r--utils/rtl_adsb.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/utils/rtl_adsb.c b/utils/rtl_adsb.c
index 7de9204..7aea8dd 100644
--- a/utils/rtl_adsb.c
+++ b/utils/rtl_adsb.c
@@ -96,6 +96,7 @@ void usage(void)
"\t[-e allowed_errors (default: 5)]\n"
"\t[-g tuner_gain (default: automatic)]\n"
"\t[-p ppm_error (default: 0)]\n"
+ "\t[-T enable bias-T on GPIO PIN 0 (works for rtl-sdr.com v3 dongles)]\n"
"\tfilename (a '-' dumps samples to stdout)\n"
"\t (omitting the filename also uses stdout)\n\n"
"Streaming with netcat:\n"
@@ -182,7 +183,7 @@ int magnitute(uint8_t *buf, int len)
return len/2;
}
-uint16_t single_manchester(uint16_t a, uint16_t b, uint16_t c, uint16_t d)
+static inline uint16_t single_manchester(uint16_t a, uint16_t b, uint16_t c, uint16_t d)
/* takes 4 consecutive real samples, return 0 or 1, BADSAMPLE on error */
{
int bit, bit_p;
@@ -223,17 +224,17 @@ uint16_t single_manchester(uint16_t a, uint16_t b, uint16_t c, uint16_t d)
return BADSAMPLE;
}
-inline uint16_t min16(uint16_t a, uint16_t b)
+static inline uint16_t min16(uint16_t a, uint16_t b)
{
return a<b ? a : b;
}
-inline uint16_t max16(uint16_t a, uint16_t b)
+static inline uint16_t max16(uint16_t a, uint16_t b)
{
return a>b ? a : b;
}
-int preamble(uint16_t *buf, int i)
+static inline int preamble(uint16_t *buf, int i)
/* returns 0/1 for preamble at index i */
{
int i2;
@@ -371,11 +372,12 @@ int main(int argc, char **argv)
int dev_index = 0;
int dev_given = 0;
int ppm_error = 0;
+ int enable_biastee = 0;
pthread_cond_init(&ready, NULL);
pthread_mutex_init(&ready_m, NULL);
squares_precompute();
- while ((opt = getopt(argc, argv, "d:g:p:e:Q:VS")) != -1)
+ while ((opt = getopt(argc, argv, "d:g:p:e:Q:VST")) != -1)
{
switch (opt) {
case 'd':
@@ -400,6 +402,9 @@ int main(int argc, char **argv)
case 'Q':
quality = (int)(atof(optarg) * 10);
break;
+ case 'T':
+ enable_biastee = 1;
+ break;
default:
usage();
return 0;
@@ -470,6 +475,10 @@ int main(int argc, char **argv)
/* Set the sample rate */
verbose_set_sample_rate(dev, ADSB_RATE);
+ rtlsdr_set_bias_tee(dev, enable_biastee);
+ if (enable_biastee)
+ fprintf(stderr, "activated bias-T on GPIO PIN 0\n");
+
/* Reset endpoint before we start reading from it (mandatory) */
verbose_reset_buffer(dev);
@@ -483,6 +492,8 @@ int main(int argc, char **argv)
else {
fprintf(stderr, "\nLibrary error %d, exiting...\n", r);}
rtlsdr_cancel_async(dev);
+ pthread_cancel(demod_thread);
+ pthread_join(demod_thread, NULL);
pthread_cond_destroy(&ready);
pthread_mutex_destroy(&ready_m);