Add option '-T' for activating bias-T in rtl_(adsb|fm|power|tcp)

* added debug output when activating
Signed-off-by: hayati ayguen <h_ayguen@web.de>
* fixed options argument
Signed-off-by: Fabian P. Schmidt <kerel-fs@gmx.de>
Signed-off-by: Steve Markgraf <steve@steve-m.de>
master
hayati ayguen 8 years ago committed by Steve Markgraf
parent fa3a113b77
commit 18bf26989c
  1. 11
      src/rtl_adsb.c
  2. 11
      src/rtl_fm.c
  3. 11
      src/rtl_power.c
  4. 13
      src/rtl_tcp.c

@ -96,6 +96,7 @@ void usage(void)
"\t[-e allowed_errors (default: 5)]\n" "\t[-e allowed_errors (default: 5)]\n"
"\t[-g tuner_gain (default: automatic)]\n" "\t[-g tuner_gain (default: automatic)]\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"
"\tfilename (a '-' dumps samples to stdout)\n" "\tfilename (a '-' dumps samples to stdout)\n"
"\t (omitting the filename also uses stdout)\n\n" "\t (omitting the filename also uses stdout)\n\n"
"Streaming with netcat:\n" "Streaming with netcat:\n"
@ -371,11 +372,12 @@ int main(int argc, char **argv)
int dev_index = 0; int dev_index = 0;
int dev_given = 0; int dev_given = 0;
int ppm_error = 0; int ppm_error = 0;
int enable_biastee = 0;
pthread_cond_init(&ready, NULL); pthread_cond_init(&ready, NULL);
pthread_mutex_init(&ready_m, NULL); pthread_mutex_init(&ready_m, NULL);
squares_precompute(); 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) { switch (opt) {
case 'd': case 'd':
@ -400,6 +402,9 @@ int main(int argc, char **argv)
case 'Q': case 'Q':
quality = (int)(atof(optarg) * 10); quality = (int)(atof(optarg) * 10);
break; break;
case 'T':
enable_biastee = 1;
break;
default: default:
usage(); usage();
return 0; return 0;
@ -470,6 +475,10 @@ int main(int argc, char **argv)
/* Set the sample rate */ /* Set the sample rate */
verbose_set_sample_rate(dev, ADSB_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) */ /* Reset endpoint before we start reading from it (mandatory) */
verbose_reset_buffer(dev); verbose_reset_buffer(dev);

@ -193,6 +193,7 @@ void usage(void)
"\t raw mode outputs 2x16 bit IQ pairs\n" "\t raw mode outputs 2x16 bit IQ pairs\n"
"\t[-s sample_rate (default: 24k)]\n" "\t[-s sample_rate (default: 24k)]\n"
"\t[-d device_index (default: 0)]\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[-g tuner_gain (default: automatic)]\n"
"\t[-l squelch_level (default: 0/off)]\n" "\t[-l squelch_level (default: 0/off)]\n"
//"\t for fm squelch is inverted\n" //"\t for fm squelch is inverted\n"
@ -1042,12 +1043,13 @@ int main(int argc, char **argv)
int r, opt; int r, opt;
int dev_given = 0; int dev_given = 0;
int custom_ppm = 0; int custom_ppm = 0;
int enable_biastee = 0;
dongle_init(&dongle); dongle_init(&dongle);
demod_init(&demod); demod_init(&demod);
output_init(&output); output_init(&output);
controller_init(&controller); 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) { switch (opt) {
case 'd': case 'd':
dongle.dev_index = verbose_device_search(optarg); dongle.dev_index = verbose_device_search(optarg);
@ -1142,6 +1144,9 @@ int main(int argc, char **argv)
demod.deemph = 1; demod.deemph = 1;
demod.squelch_level = 0;} demod.squelch_level = 0;}
break; break;
case 'T':
enable_biastee = 1;
break;
case 'h': case 'h':
default: default:
usage(); usage();
@ -1205,6 +1210,10 @@ int main(int argc, char **argv)
verbose_gain_set(dongle.dev, dongle.gain); 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); verbose_ppm_set(dongle.dev, dongle.ppm_error);
if (strcmp(output.filename, "-") == 0) { /* Write samples to stdout */ if (strcmp(output.filename, "-") == 0) { /* Write samples to stdout */

@ -133,6 +133,7 @@ void usage(void)
"\t[-d device_index (default: 0)]\n" "\t[-d device_index (default: 0)]\n"
"\t[-g tuner_gain (default: automatic)]\n" "\t[-g tuner_gain (default: automatic)]\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"
"\tfilename (a '-' dumps samples to stdout)\n" "\tfilename (a '-' dumps samples to stdout)\n"
"\t (omitting the filename also uses stdout)\n" "\t (omitting the filename also uses stdout)\n"
"\n" "\n"
@ -771,6 +772,7 @@ int main(int argc, char **argv)
int single = 0; int single = 0;
int direct_sampling = 0; int direct_sampling = 0;
int offset_tuning = 0; int offset_tuning = 0;
int enable_biastee = 0;
double crop = 0.0; double crop = 0.0;
char *freq_optarg; char *freq_optarg;
time_t next_tick; time_t next_tick;
@ -781,7 +783,7 @@ int main(int argc, char **argv)
double (*window_fn)(int, int) = rectangle; double (*window_fn)(int, int) = rectangle;
freq_optarg = ""; 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) { switch (opt) {
case 'f': // lower:upper:bin_size case 'f': // lower:upper:bin_size
freq_optarg = strdup(optarg); freq_optarg = strdup(optarg);
@ -849,6 +851,9 @@ int main(int argc, char **argv)
boxcar = 0; boxcar = 0;
comp_fir_size = atoi(optarg); comp_fir_size = atoi(optarg);
break; break;
case 'T':
enable_biastee = 1;
break;
case 'h': case 'h':
default: default:
usage(); usage();
@ -925,6 +930,10 @@ int main(int argc, char **argv)
verbose_ppm_set(dev, ppm_error); 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 */ if (strcmp(filename, "-") == 0) { /* Write log to stdout */
file = stdout; file = stdout;
#ifdef _WIN32 #ifdef _WIN32

@ -78,6 +78,7 @@ typedef struct { /* structure size must be multiple of 2 bytes */
static rtlsdr_dev_t *dev = NULL; static rtlsdr_dev_t *dev = NULL;
static int enable_biastee = 0;
static int global_numq = 0; static int global_numq = 0;
static struct llist *ll_buffers = 0; static struct llist *ll_buffers = 0;
static int llbuf_num = 500; static int llbuf_num = 500;
@ -95,7 +96,8 @@ void usage(void)
"\t[-b number of buffers (default: 15, set by library)]\n" "\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[-n max number of linked list buffers to keep (default: 500)]\n"
"\t[-d device index (default: 0)]\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); exit(1);
} }
@ -395,7 +397,7 @@ int main(int argc, char **argv)
struct sigaction sigact, sigign; struct sigaction sigact, sigign;
#endif #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) { switch (opt) {
case 'd': case 'd':
dev_index = verbose_device_search(optarg); dev_index = verbose_device_search(optarg);
@ -425,6 +427,9 @@ int main(int argc, char **argv)
case 'P': case 'P':
ppm_error = atoi(optarg); ppm_error = atoi(optarg);
break; break;
case 'T':
enable_biastee = 1;
break;
default: default:
usage(); usage();
break; break;
@ -495,6 +500,10 @@ int main(int argc, char **argv)
fprintf(stderr, "Tuner gain set to %f dB.\n", gain/10.0); 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) */ /* Reset endpoint before we start reading from it (mandatory) */
r = rtlsdr_reset_buffer(dev); r = rtlsdr_reset_buffer(dev);
if (r < 0) if (r < 0)

Loading…
Cancel
Save