Thank you!

I pulled the latest upstream master and saw your modifications. I compiled and installed gr-osmosdr and launched gnuradio - I saw your documentation update showing bias syntax. I then launched gqrx several times using hackrf=0,bias=0 and hackrf=0,bias=1 and both strings worked as expected. Low noise floor, about 22db gain when enabled. I tuned around hf/vhf/uhf and gain was good across all bands. This lna really is awesome.

BTW I used a multimeter to visually check for bias power and indeed I measured 3.00 volts at the hackrf output going into the lna when bias=1 and 0.00v when bias=0.

I didn't have a chance to check transmit bias yet.

If still not working for you maybe try loading the latest hackrf firmware. I seem to remember bias/phantom power support being a later addition to the firmware package.


-----Original Message-----

From: horiz0n@gmx.net
To: k1gto@comcast.net,osmocom-sdr@lists.osmocom.org
Cc:
Sent: 2015-05-27 18:06:14 GMT
Subject: Re: HackRF powered antenna support (pleeeeease :)

Brad,

calling that function does not seem to work with my hardware. Nevertheless
i've reworked your original patch and applied it. Please test current
master.

Best regards,
Dimitri

On Wed, 27 May 2015 13:36:18 +0200, BRAD wrote:

> Was the code patch below suitable to get merged upstream?
>
>
> -----Original Message-----
>
> From: k1gto@comcast.net
> To: osmocom-sdr@lists.osmocom.org
> Cc:
> Sent: 2015-05-15 17:23:53 GMT
> Subject: Re: HackRF powered antenna support (pleeeeease :)
>
>
> I modified the osmosdr hackrf code to support antenna/phantom power via
> a new
> device argument "bias=" (to match bladeRF's existing bias power syntax).
> 0=disable
> and 1=enable. My initial testing suggests it works great, but I would
> invite
> others to also confirm if they are able. You'll have to apply the patch
> below.
>
>
> I also added a device argument to control bias power at transmit time. I
> named
> this option differently - "bias_tx" - to avoid accidentally enabling
> bias power
> in transmit mode when an LNA may be attached in an input amplifier
> configuration.
> I reached out to the designer of the lna4all to find out if bias power
> can be
> supported, from a hardware perspective, in transmit mode (hackrf output
> connected to lna4all input, lna4all output connected to antenna). We'll
> see what
> he says. If so, I look forward to testing transmit mode bias power.
>
>
> Patch follows:
>
>
> $ git diff 275e6aed19b9ba8563bffd318a227a1196e1da2c
> 9ca86fdcd068daf44d9dec0dd1993b22c24b02f2
> | cat
> diff --git a/lib/hackrf/hackrf_sink_c.cc b/lib/hackrf/hackrf_sink_c.cc
> index 00f9768..0d52c60 100644
> --- a/lib/hackrf/hackrf_sink_c.cc
> +++ b/lib/hackrf/hackrf_sink_c.cc
> @@ -164,6 +164,7 @@ hackrf_sink_c::hackrf_sink_c (const std::string
> &args)
> _bandwidth(0)
> {
> int ret;
> + bool bias = false;
>
> dict_t dict = params_to_dict(args);
>
> @@ -184,6 +185,11 @@ hackrf_sink_c::hackrf_sink_c (const std::string
> &args)
> _usage++;
> }
>
> + // Check device args to find out if bias/phantom power is desired.
> + if ( dict.count("bias_tx") ) {
> + bias = boost::lexical_cast( dict["bias_tx"] );
> + }
> +
> _dev = NULL;
> ret = hackrf_open( &_dev );
> HACKRF_THROW_ON_ERROR(ret, "Failed to open HackRF device")
> @@ -218,6 +224,14 @@ hackrf_sink_c::hackrf_sink_c (const std::string
> &args)
>
> set_if_gain( 16 ); /* preset to a reasonable default (non-GRC use case)
> */
>
> + ret = hackrf_set_antenna_enable(_dev, (uint8_t)bias);
> + HACKRF_THROW_ON_ERROR( ret, "Failed to enable bias/phantom antenna
> power");
> + if (bias==true) {
> + std::cerr << "Successfully enabled antenna bias/power (bias_tx=" <<
> bias << ")"
> << std::endl;
> + } else {
> + std::cerr << "Successfully disabled antenna bias/power (bias_tx=" <<
> bias <<
> ")" << std::endl;
> + }
> +
> _buf = (char *) malloc( BUF_LEN );
>
> cb_init( &_cbuf, _buf_num, BUF_LEN );
> diff --git a/lib/hackrf/hackrf_source_c.cc
> b/lib/hackrf/hackrf_source_c.cc
> index e3b3ea4..4ba24ec 100644
> --- a/lib/hackrf/hackrf_source_c.cc
> +++ b/lib/hackrf/hackrf_source_c.cc
> @@ -181,6 +181,16 @@ hackrf_source_c::hackrf_source_c (const std::string
> &args)
> _buf[i] = (unsigned short *) malloc(_buf_len);
> }
>
> +
> +// Enable bias/phantom power on the antenna port if device argument
> parameter
> bias= is present. 1=enable, 0=disable.
> + if ( dict.count("bias") ) {
> + bool bias = boost::lexical_cast( dict["bias"] );
> + int ret = hackrf_set_antenna_enable(_dev, (uint8_t)bias);
> + HACKRF_THROW_ON_ERROR( ret, "Failed to enable bias/phantom antenna
> power");
> + std::cerr << "Successfully set antenna power to " << bias << std::endl;
> + }
> +
> +
> // _thread = gr::thread::thread(_hackrf_wait, this);
>
> ret = hackrf_start_rx( _dev, _hackrf_rx_callback, (void *)this );
>
>
>
> From: "Brad Hein"
> To: osmocom-sdr@lists.osmocom.org
> Sent: Thursday, January 22, 2015 12:03:57 PM
> Subject: HackRF powered antenna support (pleeeeease :)
>
>
>
> I would like to humbly request support for hackrf antenna power in
> gr-osmosdr.
> At runtime preferably, or at least an init string flag to control it
> (hackrf=0,antenna_power=1 for example). The function call seems to be
> hackrf_set_antenna_enable()
> but it's not exposed in gr-osmosdr as far as I can tell.
>
>
> I have some dev experience (but not in C) but I'm falling short trying to
> understand the code and add the feature myself. If someone wants to
> provide some
> "ELI5" guidance I'll be happy to give it another go.
>
>
> Having this feature would open up the powered antenna feature to users
> of gr-osmosdr
> such as gnuradio, gqrx, and the list goes on (big win!)
>
>
> Reference:
> https://www.mail-archive.com/hackrf-dev@greatscottgadgets.com/msg00423.html
>
>
>
> Thanks!
>
> Brad
>
>
>
>