Package: bladerf / 0.2017.12~rc1-2

0007-Fix-wrong-usage-of-str2bool.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
From 0e59cdaf062d5201588a61ae621c1733ff8399fc Mon Sep 17 00:00:00 2001
From: Christian Inci <chris.gh@broke-the-inter.net>
Date: Sat, 30 Dec 2017 01:50:19 +0100
Subject: [PATCH 07/15] Fix wrong usage of str2bool

This leads to AGC being disabled on every call of bladeRF-cli.
Please see https://github.com/Nuand/bladeRF/blob/master/host/utilities/bladeRF-cli/src/cmd/xb300.c#L117 for the proper usage.

I'm not sure if only checking LSB is the proper way to do it, as val (uint32_t) is uninitialized and str2bool sees it as bool (on my machine "off" is 2048 and "on" is 2049), but it would even work if those "else if's" are being
reordered, thus initialized by something else to a non-zero value, or you could zero it right before the str2bool call.
The printf call might not be needed anymore.

Notes:
With the latest changes in kalibrate-bladeRF (add win32 support), changing the buffer sizes of m_x_cb, m_y_cb, m_e_cb, the results of the program look even more odd. Were those changes intended? Either the outputs are correct
before and after the patch, or one BTS has the worst clock in history. I think it's the second one.
With the latest FPGA change (0.7.0 -> 0.7.1, using edge_detector instead of pulse_gen), even setting the sample rate can sometimes lead to a failure. (At least on my board, only shortly after power-on)

Have a nice weekend!

Signed-off-by: Christian Inci <chris.gh@broke-the-inter.net>
---
 host/libraries/libbladeRF/src/config.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/host/libraries/libbladeRF/src/config.c b/host/libraries/libbladeRF/src/config.c
index 1ddd2712..fdcff2a1 100644
--- a/host/libraries/libbladeRF/src/config.c
+++ b/host/libraries/libbladeRF/src/config.c
@@ -194,12 +194,12 @@ static int apply_config_options(struct bladerf *dev, struct config_options opt)
 
         status = bladerf_set_bandwidth(dev, BLADERF_MODULE_TX, bw, NULL);
     } else if (!strcasecmp(opt.key, "agc")) {
-        gain_mode = str2bool(opt.value, &ok) ? BLADERF_GAIN_AUTOMATIC
-                                            : BLADERF_GAIN_MANUAL;
+        ok = str2bool(opt.value, &val);
         printf("%s %d \n", opt.value, ok);
-        if (!ok)
+        if (ok != 0)
             return BLADERF_ERR_INVAL;
 
+        gain_mode = (val & 1) ? BLADERF_GAIN_AUTOMATIC : BLADERF_GAIN_MANUAL;
         status = bladerf_set_gain_mode(dev, BLADERF_MODULE_RX, gain_mode);
     } else if (!strcasecmp(opt.key, "gpio")) {
         val = str2uint(opt.key, 0, -1, &ok);
-- 
2.11.0