From: hayati ayguen <[email protected]>

* added debug output when activating
Signed-off-by: hayati ayguen <[email protected]>
* fixed options argument
Signed-off-by: Fabian P. Schmidt <[email protected]>
---
This patch was generated from branch feature/add-bias-t-frontend
at https://github.com/kerel-fs/librtlsdr/tree/feature/add-bias-t-frontend

Sincerely,
Fabian P. Schmidt / kerel
 src/rtl_adsb.c  | 11 ++++++++++-
 src/rtl_fm.c    | 11 ++++++++++-
 src/rtl_power.c | 11 ++++++++++-
 src/rtl_tcp.c   | 13 +++++++++++--
 4 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/src/rtl_adsb.c b/src/rtl_adsb.c
index e611e78..07fdd2a 100644
--- a/src/rtl_adsb.c
+++ b/src/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"
@@ -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);
 
diff --git a/src/rtl_fm.c b/src/rtl_fm.c
index e89e42d..d2d011a 100644
--- a/src/rtl_fm.c
+++ b/src/rtl_fm.c
@@ -193,6 +193,7 @@ void usage(void)
                "\t    raw mode outputs 2x16 bit IQ pairs\n"
                "\t[-s sample_rate (default: 24k)]\n"
                "\t[-d device_index (default: 0)]\n"
+               "\t[-T enable bias-T on GPIO PIN 0 (works for rtl-sdr.com v3 
dongles)]\n"
                "\t[-g tuner_gain (default: automatic)]\n"
                "\t[-l squelch_level (default: 0/off)]\n"
                //"\t    for fm squelch is inverted\n"
@@ -1042,12 +1043,13 @@ int main(int argc, char **argv)
        int r, opt;
        int dev_given = 0;
        int custom_ppm = 0;
+    int enable_biastee = 0;
        dongle_init(&dongle);
        demod_init(&demod);
        output_init(&output);
        controller_init(&controller);
 
-       while ((opt = getopt(argc, argv, "d:f:g:s:b:l:o:t:r:p:E:F:A:M:h")) != 
-1) {
+       while ((opt = getopt(argc, argv, "d:f:g:s:b:l:o:t:r:p:E:F:A:M:hT")) != 
-1) {
                switch (opt) {
                case 'd':
                        dongle.dev_index = verbose_device_search(optarg);
@@ -1142,6 +1144,9 @@ int main(int argc, char **argv)
                                demod.deemph = 1;
                                demod.squelch_level = 0;}
                        break;
+               case 'T':
+                       enable_biastee = 1;
+                       break;
                case 'h':
                default:
                        usage();
@@ -1205,6 +1210,10 @@ int main(int argc, char **argv)
                verbose_gain_set(dongle.dev, dongle.gain);
        }
 
+       rtlsdr_set_bias_tee(dongle.dev, enable_biastee);
+       if (enable_biastee)
+               fprintf(stderr, "activated bias-T on GPIO PIN 0\n");
+
        verbose_ppm_set(dongle.dev, dongle.ppm_error);
 
        if (strcmp(output.filename, "-") == 0) { /* Write samples to stdout */
diff --git a/src/rtl_power.c b/src/rtl_power.c
index aa7a138..00f4d9f 100644
--- a/src/rtl_power.c
+++ b/src/rtl_power.c
@@ -133,6 +133,7 @@ void usage(void)
                "\t[-d device_index (default: 0)]\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"
@@ -771,6 +772,7 @@ int main(int argc, char **argv)
        int single = 0;
        int direct_sampling = 0;
        int offset_tuning = 0;
+       int enable_biastee = 0;
        double crop = 0.0;
        char *freq_optarg;
        time_t next_tick;
@@ -781,7 +783,7 @@ int main(int argc, char **argv)
        double (*window_fn)(int, int) = rectangle;
        freq_optarg = "";
 
-       while ((opt = getopt(argc, argv, "f:i:s:t:d:g:p:e:w:c:F:1PDOh")) != -1) 
{
+       while ((opt = getopt(argc, argv, "f:i:s:t:d:g:p:e:w:c:F:1PDOhT")) != 
-1) {
                switch (opt) {
                case 'f': // lower:upper:bin_size
                        freq_optarg = strdup(optarg);
@@ -849,6 +851,9 @@ int main(int argc, char **argv)
                        boxcar = 0;
                        comp_fir_size = atoi(optarg);
                        break;
+               case 'T':
+                       enable_biastee = 1;
+                       break;
                case 'h':
                default:
                        usage();
@@ -925,6 +930,10 @@ int main(int argc, char **argv)
 
        verbose_ppm_set(dev, ppm_error);
 
+       rtlsdr_set_bias_tee(dev, enable_biastee);
+       if (enable_biastee)
+               fprintf(stderr, "activated bias-T on GPIO PIN 0\n");
+
        if (strcmp(filename, "-") == 0) { /* Write log to stdout */
                file = stdout;
 #ifdef _WIN32
diff --git a/src/rtl_tcp.c b/src/rtl_tcp.c
index 317e0f3..7925da7 100644
--- a/src/rtl_tcp.c
+++ b/src/rtl_tcp.c
@@ -78,6 +78,7 @@ typedef struct { /* structure size must be multiple of 2 
bytes */
 
 static rtlsdr_dev_t *dev = NULL;
 
+static int enable_biastee = 0;
 static int global_numq = 0;
 static struct llist *ll_buffers = 0;
 static int llbuf_num = 500;
@@ -95,7 +96,8 @@ void usage(void)
                "\t[-b number of buffers (default: 15, set by library)]\n"
                "\t[-n max number of linked list buffers to keep (default: 
500)]\n"
                "\t[-d device index (default: 0)]\n"
-               "\t[-P ppm_error (default: 0)]\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");
        exit(1);
 }
 
@@ -391,7 +393,7 @@ int main(int argc, char **argv)
        struct sigaction sigact, sigign;
 #endif
 
-       while ((opt = getopt(argc, argv, "a:p:f:g:s:b:n:d:P:")) != -1) {
+       while ((opt = getopt(argc, argv, "a:p:f:g:s:b:n:d:P:T")) != -1) {
                switch (opt) {
                case 'd':
                        dev_index = verbose_device_search(optarg);
@@ -421,6 +423,9 @@ int main(int argc, char **argv)
                case 'P':
                        ppm_error = atoi(optarg);
                        break;
+               case 'T':
+                       enable_biastee = 1;
+                       break;
                default:
                        usage();
                        break;
@@ -491,6 +496,10 @@ int main(int argc, char **argv)
                        fprintf(stderr, "Tuner gain set to %f dB.\n", 
gain/10.0);
        }
 
+       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) */
        r = rtlsdr_reset_buffer(dev);
        if (r < 0)
-- 
2.1.4

Reply via email to