Was the code patch below suitable to get merged upstream? <br><br><br>-----Original Message-----<br><br>From: k1gto@comcast.net<br>To: osmocom-sdr@lists.osmocom.org<br>Cc: <br>Sent: 2015-05-15 17:23:53 GMT<br>Subject: Re: HackRF powered antenna support (pleeeeease :)<br><br><html><body><div style="font-family: Arial; font-size: 12pt; color: #000000"><div><br></div><div>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. <br></div><div><br></div><div>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. <br></div><div><br></div><div>Patch follows: <br></div><div><br></div><div>$ git diff 275e6aed19b9ba8563bffd318a227a1196e1da2c 9ca86fdcd068daf44d9dec0dd1993b22c24b02f2 | cat<br>diff --git a/lib/hackrf/hackrf_sink_c.cc b/lib/hackrf/hackrf_sink_c.cc<br>index 00f9768..0d52c60 100644<br>--- a/lib/hackrf/hackrf_sink_c.cc<br>+++ b/lib/hackrf/hackrf_sink_c.cc<br>@@ -164,6 +164,7 @@ hackrf_sink_c::hackrf_sink_c (const std::string &args)<br>     _bandwidth(0)<br> {<br>   int ret;<br>+  bool bias = false;<br> <br>   dict_t dict = params_to_dict(args);<br> <br>@@ -184,6 +185,11 @@ hackrf_sink_c::hackrf_sink_c (const std::string &args)<br>     _usage++;<br>   }<br> <br>+  // Check device args to find out if bias/phantom power is desired.<br>+  if ( dict.count("bias_tx") )    {<br>+    bias = boost::lexical_cast<bool>( dict["bias_tx"] );<br>+  }<br>+<br>   _dev = NULL;<br>   ret = hackrf_open( &_dev );<br>   HACKRF_THROW_ON_ERROR(ret, "Failed to open HackRF device")<br>@@ -218,6 +224,14 @@ hackrf_sink_c::hackrf_sink_c (const std::string &args)<br> <br>   set_if_gain( 16 ); /* preset to a reasonable default (non-GRC use case) */<br> <br>+  ret = hackrf_set_antenna_enable(_dev, (uint8_t)bias);<br>+  HACKRF_THROW_ON_ERROR( ret, "Failed to enable bias/phantom antenna power");<br>+  if (bias==true) {<br>+    std::cerr << "Successfully enabled antenna bias/power (bias_tx=" << bias  << ")" << std::endl;<br>+  } else {<br>+    std::cerr << "Successfully disabled antenna bias/power (bias_tx=" << bias  << ")" << std::endl;<br>+  }<br>+<br>   _buf = (char *) malloc( BUF_LEN );<br> <br>   cb_init( &_cbuf, _buf_num, BUF_LEN );<br>diff --git a/lib/hackrf/hackrf_source_c.cc b/lib/hackrf/hackrf_source_c.cc<br>index e3b3ea4..4ba24ec 100644<br>--- a/lib/hackrf/hackrf_source_c.cc<br>+++ b/lib/hackrf/hackrf_source_c.cc<br>@@ -181,6 +181,16 @@ hackrf_source_c::hackrf_source_c (const std::string &args)<br>       _buf[i] = (unsigned short *) malloc(_buf_len);<br>   }<br> <br>+<br>+// Enable bias/phantom power on the antenna port if device argument parameter bias= is present. 1=enable, 0=disable. <br>+    if ( dict.count("bias") )    {<br>+        bool bias = boost::lexical_cast<bool>( dict["bias"] );<br>+        int ret = hackrf_set_antenna_enable(_dev, (uint8_t)bias);<br>+        HACKRF_THROW_ON_ERROR( ret, "Failed to enable bias/phantom antenna power");<br>+        std::cerr << "Successfully set antenna power to " << bias << std::endl;<br>+    }<br>+<br>+<br> //  _thread = gr::thread::thread(_hackrf_wait, this);<br> <br>   ret = hackrf_start_rx( _dev, _hackrf_rx_callback, (void *)this );<br><br><br></div><div><br></div><hr id="zwchr"><div style="color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"Brad Hein" <k1gto@comcast.net><br><b>To: </b>osmocom-sdr@lists.osmocom.org<br><b>Sent: </b>Thursday, January 22, 2015 12:03:57 PM<br><b>Subject: </b>HackRF powered antenna support (pleeeeease :)<br><div><br></div><div style="font-family: Arial; font-size: 12pt; color: #000000"><div><br>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<br>(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. <br><div><br></div>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. <br></div><div><br></div><div>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!)<br></div><div><br>Reference:<br>https://www.mail-archive.com/hackrf-dev@greatscottgadgets.com/msg00423.html<br><div><br></div><br></div><div>Thanks!<br></div><div>Brad<br></div><div><br></div></div></div><div><br></div></div></body></html><br><br>