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.
...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."
It appears the 'inline' keyword still isn't supported as of VS2013
(MSVC 18.00). However, we shouldn't be re-defining it
if building with VS's C++ compiler.
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.
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.
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.
Visual Studio 2013 now includes these headers, so they have
been moved as not to conflict (even though they are intended to
be equivalent.)
Our stdbool.h was providing an incorrect typedef; sizeof(bool)
should have been 1, not sizeof(int).
Per http://msdn.microsoft.com/en-us/library/tf4dy80a.aspx:
"In Visual C++4.2, the Standard C++ header files contained a typedef
that equated bool with int. In Visual C++ 5.0 and later, bool is
implemented as a built-in type with a size of 1 byte. That means
that for Visual C++ 4.2, a call of sizeof(bool) yields 4, while in
Visual C++ 5.0 and later, the same call yields 1. This can cause
memory corruption problems if you have defined structure members of
type bool in Visual C++ 4.2 and are mixing object files (OBJ) and/or
DLLs built with the 4.2 and 5.0 or later compilers."
When making log_* calls, add these two lines to the corresponding
CMake file prior to add_library() or add_executable():
set(SRC_TO_SHORTEN ${MY_SRC_LIST})
include(ShortFileMacro)
Many thanks to LazyDodo for providing the CMake approach for doing this,
and to rwr for suggesting this change.
Top-level API functions now acquire a per-device "control lock" before
performing control, programming, and low-level access operations.
(Specifically, these are the functions that manipulate the device handle
and utilize the FX3 <-> FPGA UART.)
Synchronous data transfer functions now hold a per-device, per-module
"sync lock" to ensure these operations are carried out atomically. The
control lock is also held during sync configuration, as upcoming changes
to introduce metadata support will require flipping some config bits on
the FPGA during this operation.
Only these top-level functions shall acquire these locks; the core logic
code should be able to assume that locks are already acquired.
To alleviate confusion, functions that are *not* part of the API, and
therefore are safe to call within the core logic, are stripped of the
bladerf_ prefix.
Now that pthreads is a required dependency, use of the sync API is
is no longer marked optional in the libbladeRF build.
ENABLE_LIBBLADERF_SYNC and related items have been removed from the
CMake build.
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)
On Linux and OSX, the following directories will be searched,
in the order listed:
~/.config/Nuand/bladeRF
~/.Nuand/bladeRF
/etc/Nuand/bladeRF
In Windows, %appdata%/Nuand/bladeRF will searched.
The following files will be loaded, if found in these search paths:
FPGA image: hostedx40.rbf or hostedx115.rbf, depending on the
size of the FPGA reported by the device.
DC Calibration tables: <serial>_dc_<rx|tx>.tbl
libbladeRF: Added Windows support to file_find
- Our surrogate inttypes.h is only needed for Visual Studio 2010 and
earlier, due to the lack of C99 support.
- Move all the inttypes.h includes into host_config.h, where we can
do the ugly in a centralized location
- MinGW on Linux is case-sensitive -- reflect that when including
windows.h.
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.
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
This work is largely based upon or directly from contributions by LazyDodo.
To allow for other USB drivers (e.g., native host drivers, the CyAPI) to
be more easily integrated, all driver-agnostic bladeRF<->USB code has
been moved to a generic USB backend. The intent is here is to decouple
bladeRF-specific logic from these USB "driver" interfaces to remove
unnecessary code duplication.
The contained changes include:
- Splitting the libusb backend code into backend/usb/usb.c and
backend/usb/libusb.c, and some cleanup in the moved code.
- Removal of the flash_firmware() backend function. This is has been
moved to flash.c, and is implemented atop the backend flash
functions.
- Removal of legacy support in the USB code. All legacy support
is planned for removal and replacement with an appropriate
error code to denote that a FW upgrade is required.
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.
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.
These changes simplify the image format a bit; the metadata fields are
flattened into the image to simplify both image creation and manually
viewing/extracting contents from images.
The checksum has been moved to directly after the file format's magic
value (i.e., signature), to make it a bit easier to just extract data
via dd. Similar to the approach used by mkimage for U-Boot headers,
the checksum calculation is performed over the entire image, with the
checksum field zeroed out.
Touched up CLI backup/restore commands and separated <address>
and <length> to separate args.
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.
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.
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.
With future license-related cleanup, all GPLv2 programs will live
in the utilities directory. As such, ezusb.c has been moved out
of the library, and the bladeRF-cli utility has been modified to
use this directly.
The rx and tx CLI commands now use the asynchronous stream interface to
yield more acceptable performance, and this code has been overhauled for
better readability. Command parameters have been added to allow for
configuration of the stream.
Although a bit overzealous, as "lock it if you use it" approach is taken
here. Optimizations may follow later..
Some rx/tx parameters now support K/M/G suffixes, where relevant.
To support sample rate sanity checks, an API function to check the
current USB speed has been added to libbladeRF. This speed is now
reported in the CLI 'info' command.
'value' could have be truncated on systems where sizeof(unsigned long) >
sizeof(unsigned int). As it is unlikely that someone will use such a
system, this is mainly to keep consistent with the other functions in
this file.
The API now presents a version structure that includes major, minor, and
patch versions. It additionally provides a "describe" string which
includes these version items in a string format, with any additional
annotations (such as git revision and dirty flag).
This changeset removes the older version functions, breaking reverse
compatibility (intentionally). Bumped minor version to reflect this change.
(The 0.Y.Z series is considered unstable at this time.)
From the documentation:
"A value of zero causes the thread to relinquish the remainder of its
time slice to any other thread of equal priority that is ready to run.
If there are no other threads of equal priority ready to run, the
function returns immediately, and the thread continues execution."
Thanks Simon!
- Split RF, FPGA load, and firmware methods into seperate .c files
- Split several vendor requests to eliminate magic glEp0Idx and to allow
for better error handling
- Updated libbladeRF to use new vendor requests and properly check return
code.
- Changed glSpiPageSize from global to #define
- Move OTP handling into firmware.c
- Version bump
Conflicts:
fx3_firmware/bladeRF.c
Initializing, extracting, and comparing device identifier information
(struct bladerf_devinfo) is now exposed through the API. Among other
things, this allow users to check if a device specifier string matches a
device they already have a handle for.
To support this, a copy of bladerf_devinfo information is now kept around in
the device handle; backends are responsible for populating this in their
open() implementation. A couple of the fields were already present, so
this only adds a couple small variables worth of overhead.
Some re-arranging of the linux and libusb probe and open calls has been done
to achieve this. A few warnings and bugs were addressed in this process:
- The Linux backend was attempting to fill in a serial number via
a cached entry.
- There was some potential for a read of an uninitialized portion
of an otp buffer.
- Missing serial # has been made non-fatal. (Some developers'
device do not have serial numbers.)
Files associated with this functionality was moved from host/common
back into the library, which should now be used instead. bladeRF-flash
has been updated to use these new API functions.