Commit graph

67 commits

Author SHA1 Message Date
Rey Tucker
14e7f317a2 host: common/conversions: add str2channel
Converts from a string to a bladerf_channel
2018-02-05 15:35:28 -05:00
Rey Tucker
b9db604801 host: common/conversions: add firmware and rf_bist loopback options 2018-02-05 15:35:28 -05:00
Vanya A. Sergeev
bccd7e19f7 libbladeRF: migrate api to 64-bit frequency 2017-12-21 12:54:58 -05:00
Vanya A. Sergeev
9062b66d9c libbladeRF: migrate bladerf_module to bladerf_channel and bladerf_direction 2017-12-21 12:54:58 -05:00
Robert Ghilduta
a39a81d700 Add config option file parsing capabilities
This commit adds functions that parse config option files
2017-12-07 20:34:34 -08:00
Robert Ghilduta
68bf8e231a Add string parsing functions
The line to argumenet parser uses a two pass approach. The first pass
finds beginning and end of arguments, and counts the number of quotes.
The second pass copies the characters into the argument buffers.
2017-12-07 20:34:33 -08:00
Robert Ghilduta
82c424cc8c Add string manipulation functions 2017-12-07 20:34:33 -08:00
Robert Ghilduta
38664eaa10 Add bladeRF and libbladeRF specific look-ups and conversion 2017-12-07 17:10:28 -08:00
Robert Ghilduta
579199768c Cleanup files to add options file parser 2017-12-07 17:10:28 -08:00
Rey Tucker
f680b9ba8c host: dc_calibration.c: fix int conversion in rx_cal_dc_off (#515)
MSVC warns of loss of precision on implicit conversion from float to
int16_t.  Instead of relying on truncation, do a proper round with
bounds-checking.
2017-08-04 15:21:22 -04:00
Rey Tucker
236753aaea clock_gettime.c: remove HAVE_CLOCK_GETTIME check
This is not necessary due to the fact that cmake only includes this file
if clock_gettime is missing in the first place.
2017-08-03 10:56:17 -04:00
Rey Tucker
0779109841 host: explicitly test for clock_gettime (#508)
Instead of using version-based guessing on macOS (which appears to fail
with newer versions of Xcode on older versions of macOS), use an
explicit test for clock_gettime in CMake.
2017-08-02 15:02:38 -04:00
Robert Ghilduta
b31d4e6d5c bladeRF-cli: print verbose output for DC LUT calculation 2017-07-05 08:59:08 -07:00
Robert Ghilduta
7aff155a97 libbladeRF: add gain specific mean errors to DC calibration table
The DC calibration table will now include mean residual errors for 3 different
gains (that will be used by the AGC amont other things) including:
    Max : LNA=6dB, RXVGA1=30dB, RXVGA2=15dB
    Mid : LNA=6dB, RXVGA1=30dB, RXVGA2= 0dB
    Low : LNA=3dB, RXVGA1=12dB, RXVGA2= 0dB

The DC cal table version has been bumped to 2. This commit will allow backward
compatibility with existing DC cal tables.
2017-07-05 08:59:08 -07:00
Thomas Brown
21690e5da0 libbladeRF: Use system clock_gettime on macOS >= 10.12. 2017-07-05 08:58:17 -07:00
Jon Szymaniak
210591e8e2 host: common: Added conversion routines for bladerf_smb_mode 2016-05-17 00:20:01 -04:00
Jon Szymaniak
7656724db7 host: common: Added trigger role conversion routines 2016-05-17 00:20:01 -04:00
Jon Szymaniak
8c0ac5629d host/common: Added string <-> trigger enum conversion functions 2016-05-17 00:19:53 -04:00
Jon Szymaniak
2e042f122a host: common: Whitespace fix 2016-04-25 19:03:34 -04:00
Jon Szymaniak
3537c3a49a host: common: Added str2bool() conversion routine
This is intended for use with functions that require
enable/disable, on/off, true/false.
2016-04-25 19:03:34 -04:00
Jon Szymaniak
7c55150c98 host/common: Apply nominal DC offset values at end of cal routines
The nominal DC offset values were being left up to the caller to
apply. However, the bladeRF-cli was not doing this.

For convenience, these functions now apply the resulting nominal
values identified before exiting.
2016-02-10 15:18:44 -05:00
Jon Szymaniak
5c3510c0cf host: Addressed warnings from GCC -Os in dc_calibration.c
host/common/src/dc_calibration.c:584:19: error: ‘q_est’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
     const int16_t max_est = (i_est > q_est) ? i_est : q_est;
                   ^
host/common/src/dc_calibration.c:679:20: note: ‘q_est’ was declared here
     int16_t i_est, q_est;
                    ^
host/common/src/dc_calibration.c:584:19: error: ‘i_est’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
     const int16_t max_est = (i_est > q_est) ? i_est : q_est;
                   ^
host/common/src/dc_calibration.c:679:13: note: ‘i_est’ was declared here
     int16_t i_est, q_est;
             ^

Ensure i_est and q_est are assigned fallback values in error cases.
2016-01-04 09:58:28 -05:00
Jon Szymaniak
0132bcbabd host/common: MSVC 2013 build fix
Checks for INFINITY or -INFINITY inherently generate warning C4056,
"by design." Supress this.
2015-12-29 21:10:57 -05:00
Jon Szymaniak
9514471f57 host/common: Fix warnings on OSX
Use memset() to zeroize bladerf_metadata structure to avoid
missing initializer warnings.
2015-12-29 13:35:19 -05:00
Jon Szymaniak
6a9d7fcb6c host/common: Added check for divide-by-zero
Addresses CID 1346524.

This should never happen because the count input is assigned
from a compile-time constant.

However, this check and assert() are worth having to verify
this assumption, should someone break the code later...
2015-12-29 12:36:02 -05:00
Jon Szymaniak
c87747308e host/common: Fixed handling of BLADERF_ERR_TIME_PAST in DC cal
In the case where the timestamp was in the past we want to
try to resynchronize with the hardware's timestamp counter
rather than blindly increment the timestamp.

This addresses CID 1346525 due to the removal of a return
if status != 0 (rather than handling BLADERF_ERR_TIME_PAST).
2015-12-29 12:24:14 -05:00
Jon Szymaniak
221083a2d6 host/common: Added MIT-licensed DC calibration routines
This code is a re-designed set of DC calibration functionality
built atop of libbladeRF.

This functionality provides the ability to:
    - Run LMS6002D DC calibrations per module (or all at once)

    - Search for nominal RX/TX DC correction values for a single
      frequencies or a range of frequencies.

To avoid inducing issue #408 by utilizing a single stream,
rather than repeatedly starting and stopping streams.

No TX thread is used, as this is uneccessary; it is sufficient to
flush 0+0j samples through the TX path at the start of calibration
and allow the DAC to remain held in this state as the FPGA
(intentionally) underruns.
2015-12-28 22:29:04 -05:00
Jon Szymaniak
454b4931ec host/common: Added str to bladerf_module & bladerf_dc_cal_module fns 2015-12-28 22:20:20 -05:00
Jon Szymaniak
c5d1e4a9f3 host/common: Made devcfg_perform_sync_config() parameter const 2015-11-29 21:20:54 -05:00
Jon Szymaniak
672cf27eae host/common: Added string to uint64 and double w/ suffix conversions 2015-10-08 12:48:55 -04:00
Jon Szymaniak
bf9f8a62a4 host: Moved device config helpers to host/common
People may find these useful when developing their own tools or
contributions to the bladeRF codebase.
2015-06-21 23:07:40 -04:00
Jon Szymaniak
3cfb507f91 host_common: Use size_t for array length, MSVC build fix
size_t or unsigned int are preferred for variables that describe
the length of an array.

This change fixes an additional MSVC build issue caused by
test_scheduled_retune.
2015-06-21 22:52:19 -04:00
Jon Szymaniak
8780fc8011 host/common: Use float suffix on constants
...just for the sake of being explicit.  Sure, a compiler might
be "smart" enough to not use a double here, but it certainly doesn't
hurt to here "say what you mean."
2015-04-11 20:17:41 -04:00
Jon Szymaniak
ee266acb24 host/common: Multiple by inverse instead of divide
FP multiplies are generally less costly and our constant factor
is known at compile-time.
2015-04-10 14:34:23 -04:00
Jon Szymaniak
cd6cb0cca7 host/common: Added SC16Q11 <-> float conversion routines 2015-04-10 13:39:09 -04:00
Michael Ambrus
344d497cb2 libbladeRF: Added syslog support (Linux, OSX)
OpenBTS and YateBTS fork a transceiver sub-process and redirect stderr
and stdout, which effectively hide any bladerf logs. For debugging
time-critical code, printf debugging (or logging) is simple, yet
practically essential. libbladeRF logging via syslog is opt-in via the
CMake ENABLE_LIBBLADERF_SYSLOG option, which defaults to OFF.

To make this as transparent as possible, a generic mechanism for
initializing libraries without having to use any specific pre-known
function has been introduced (see init_fini.c). Currently its only real
purpose is to closelog() upon unloading library. Failing doing this is
an error affecting the case when the library is unloaded manually.

When the syslog support is enabled, the libbladeRF default log level is
reduced to WARNING, rather than INFO to avoid noise in logs.
2015-01-14 14:20:13 -05:00
Jon Szymaniak
41bcf7b12c host: Centralized duplicated code
Moved function to get string description to conversions.c.

There's a similar function within libbladeRF's backend.c, but that
is intended to be used in the device information string; this is
intended to be a bit more humand-readable.
2014-12-18 17:58:21 -05:00
Jon Szymaniak
7218273716 libbladeRF_test: Added common cmdline arg handling and device config
Most of the libbladeRF_test items contain their own command line
argument handling, yielding repeated code and inconsistent invocations.

This commit introduces common command-line argument handling and device
configuration for the most used device parameters.

Future patches will migrate the tests over to using this functionality.
New tests should use this immediately.
2014-11-18 17:09:11 -05:00
Jeremy Quirke
3716dd8210 host: Cygwin build fixes 2014-10-29 13:09:27 -04:00
Jon Szymaniak
c4d5bbe8b4 bladeRF-cli: Added '#' end-of-line comment
All characters following '#' are ignored as part of an end-of-line
comment.

Thank you to Karl Lehenbauer for suggesting this change.
2014-08-15 01:47:36 -04:00
Jon Szymaniak
a151ba4f99 bladeRF-cli: Handle unterminated quote as a non-fatal error condition
And additional return value has been added to str2args in order to
differentiate between an unexpected fatal (e.g, memory) error and
unterminated quotes.

This was previously causing cmd_handle() to fall through to an
"Unknown error" case, which is treated as a fatal error, resulting in
the CLI being terminated.

Thank you to Jens Elofsson (jenselo) for tracking down and reporting the
underlying defect! (Issue #259)
2014-06-30 01:34:00 -04:00
Jon Szymaniak
588650ecff bladeRF-cli: Cleaned up items reported by Clang static analysis
tx.c - Removed dead assignment, fixed leak due to incorrect status check
main.c - Memory leaks in rc_config items
conversions.c - Removed dead assignment
script.c - fileno() doesn't fail when given valid FILE*. Removed false positive.
2014-05-28 21:33:33 -04:00
Jon Szymaniak
e0f6ee0eea bladeRF-cli: Added -e <command> support
This option allows interactive mode commands to be executed from the
command line. Multiple -e <cmd> arguments may be provided; they will be
executed in the order they are specified.

Operations/command are performed in the following order:
    - Command line options (e.g., FPGA load, firmware flash)
    - Commands from '-e <cmd>' arguments
    - Commands from script files
    - Interactive mode commands
2014-05-28 21:33:27 -04:00
Jon Szymaniak
ffb54863b2 libbladeRF: Added loopback and clean SIGTERM handling to test_sync 2014-03-08 19:55:21 -05:00
Jon Szymaniak
daaa2e92c8 libbladeRF: Re-implemented sync interface, updated API docs, renamed timeout function
The sync interface has been re-implemented atop the existing
asynchronous interface. This is currently opt-in and only enable when
pthreads support is enabled and available.

Some clarifications have been made in the API documentation,
specifically in the explanations of the various stream parameters.

The bladerf_set_transfer_timeout and bladerf_get_transfer_timeout have
been named more appropriately, as these control stream transfer
timeouts, as opposed to all transfers.
2014-03-08 19:55:21 -05:00
Jon Szymaniak
30997a9f61 libbladeRF, bladeRF-cli: Reworked cal data generation and misc cleanup
The function to create cal data now is a wrapper around
bladerf_alloc_image() which initializes the returned image with
calibration data.

The associated CLI command now allows this to be either written to a
file or to the device directly.

API header cleanup: Pushed the lower level functions to to the end of
the header, so the functions people will use more frequently will be at
the top of the generated documentation.

Also added a missing API_EXPORT and made the Doxygen color scheme a little
more blue. (Tired of grayscale ;) )

Windows cleanup: Added get_timestamp() implementation, cleaned up
warnings, address some portability issues.
2013-11-28 14:14:38 -05:00
Daniel Gröber
cae59d8900 common: Add sha256 code from FreeBSD 2013-11-28 13:58:08 -05:00
Jon Szymaniak
12a4313cc1 bladeRF-cli: Improved script support, quoted param support, misc. cleanup
Scripts can be invoked from within other scripts, using the "run"
command. An error is reported if a recursive loop is detected.

An "echo" command has been added for debug purposes.

Parameters may now be surrounded in double quotes to include spaces.

Removed extraneous error messages from main(); The preceding functions
print error messages if needed.

Removed error-out if no device is attached. This allows scripts to be
run if the device is not attached. Commands already verify that a device
is attached, if required.
2013-11-11 22:14:53 -05:00
Jon Szymaniak
625694eaa5 license: License changes on various portions of the codebase
Where possible (and with contributor permission), items have been
changed to LGPLv2.1 or MIT licenses to avoid issues with any proprietary
libraries from vendors (HDL and FW), allow static linking (with headless
mode operation in mind), and to generally present users with more
permissive licenses.

File headers and the COPYING have been updated accordingly. Third party
sources have been either removed, replaced, or relocated in the source
tree, in accordance with the licenses decided upon for each part of the tree.

Contributor Assignment Agreements have been added, and it is required
that these be submitted before significant patches and pull requests
are accepted.
2013-10-27 00:17:35 -04:00
Jon Szymaniak
7a1b2c1462 common, libbladeRF: log.c support can be disabled at compile-time
CMake option added to disable log.c for libbladeRF. Adjustments made
to other files as needed to address warnings (becoming errors via
-Werror and /Wx).

Removed return values for log-related functions, as these were unused
and made it slightly more annoying to make this change. The libbladeRF
minor version has been bumped to note this change in the currently
unstable series v0.x.x series.
2013-10-21 22:44:59 -04:00