Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor public headers #1

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d36e6ab
Move LogLevel out of SDRDevice
rjonaitis Apr 7, 2024
5924015
Move SDRConfig out of SDRDevice
rjonaitis Apr 7, 2024
ebd46ef
Move StreamConfig into separate headers
rjonaitis Apr 7, 2024
2cbb195
Extract Descriptors into separate headers
rjonaitis Apr 7, 2024
2d8e311
Fix headers warnings, replace expensive includes with forward declara…
rjonaitis Apr 7, 2024
c599fe2
cmake: check if changelog release version matches API version in header
rjonaitis Apr 7, 2024
7ea230d
remove IComms from public headers
rjonaitis Apr 7, 2024
be63899
Rename commonTypes.h -> types.h
rjonaitis Apr 7, 2024
e93e36e
Moved DeviceTreeNode out of public headers
rjonaitis Apr 7, 2024
f0536fc
Reduce public interface
rjonaitis Apr 8, 2024
d7777f6
Move Logger implementation out of public header
rjonaitis Apr 8, 2024
032e8cc
Change OpStatus to not use all uppercase names to avoid clashing with…
rjonaitis Apr 8, 2024
0af2c61
Change LogLevel to not use all uppercase to avoid clashing with macros
rjonaitis Apr 8, 2024
c8f23b8
Cleanup gui headers and forward declarations
rjonaitis Apr 8, 2024
863eb3d
HDSDR: update OpStatus names
rjonaitis Apr 8, 2024
f8dab61
Fix clang compilation/warnings
rjonaitis Apr 8, 2024
04f34e7
Fix Windows FX3 compilation
rjonaitis Apr 8, 2024
5250207
Don't cancel gitaction build on first failure
rjonaitis Apr 8, 2024
2a2ae02
Install .hpp header
rjonaitis Apr 8, 2024
3a9d118
Fix static tests
rjonaitis Apr 8, 2024
7baed28
Fix soapysdr compilation
rjonaitis Apr 8, 2024
62f5fbb
Fix formatting
rjonaitis Apr 8, 2024
71a9355
Fix windows tests compilation
rjonaitis Apr 8, 2024
a3f7c7d
Fix linux libusb discovery error, when library is not found
rjonaitis Apr 8, 2024
ca57301
Fix HDSDR compilation
rjonaitis Apr 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
Expand Down
19 changes: 18 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ endif()

########################################################################
# Gather version information from the changelog
# LIME_SUITE_API_VERSION in VersionInfo.h reflects the major/minor
# LIMESUITENG_API_VERSION in VersionInfo.h reflects the major/minor
########################################################################
file(READ "${PROJECT_SOURCE_DIR}/Changelog.txt" changelog_txt)
string(REGEX MATCH "Release ([0-9]+)\\.([0-9]+)\\.([0-9]+) \\(" CHANGELOG_MATCH "${changelog_txt}")
Expand All @@ -29,6 +29,23 @@ set(VERSION_MAJOR "${CMAKE_MATCH_1}")
set(VERSION_MINOR "${CMAKE_MATCH_2}")
set(VERSION_PATCH "${CMAKE_MATCH_3}")

# verify that VersionInfo.h LIMESUITENG_API_VERSION define matches changelog
file(READ "${PROJECT_SOURCE_DIR}/src/include/limesuiteng/VersionInfo.h" version_info_header_txt)
string(REGEX MATCH "LIMESUITENG_API_VERSION 0x([A-Fa-f0-9]*)" VERSION_DEFINE_MATCH "${version_info_header_txt}")
if (NOT VERSION_DEFINE_MATCH)
message(FATAL_ERROR "Failed to extract API version from VersionInfo.h")
endif()
math(EXPR VERSION_MAJOR_IN_HEADER "(0x${CMAKE_MATCH_1} >> 24) & 0xFF" OUTPUT_FORMAT DECIMAL)
math(EXPR VERSION_MINOR_IN_HEADER "(0x${CMAKE_MATCH_1} >> 16) & 0xFF" OUTPUT_FORMAT DECIMAL)
math(EXPR VERSION_PATCH_IN_HEADER "(0x${CMAKE_MATCH_1}) & 0xFFFF" OUTPUT_FORMAT DECIMAL)
if (NOT ${VERSION_MAJOR} EQUAL ${VERSION_MAJOR_IN_HEADER}
OR NOT ${VERSION_MINOR} EQUAL ${VERSION_MINOR_IN_HEADER}
OR NOT ${VERSION_PATCH} EQUAL ${VERSION_PATCH_IN_HEADER}
)
message(FATAL_ERROR "Changelog release version (${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})"
" don't match header API version (${VERSION_MAJOR_IN_HEADER}.${VERSION_MINOR_IN_HEADER}.${VERSION_PATCH_IN_HEADER})")
endif()

# the ABI compatibility number should be incremented when the ABI changes
# the format is to use the same major and minor, but to have an incrementing
# number if there are changes within the major.minor release series
Expand Down
20 changes: 10 additions & 10 deletions cmake/Modules/Findlibusb-1.0.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,13 @@ if(bananapi-r2)
)
endif(bananapi-r2)

set(LIBUSB_1_INCLUDE_DIRS
${LIBUSB_1_INCLUDE_DIR}
)
set(LIBUSB_1_LIBRARIES
${LIBUSB_1_LIBRARY}
)
if (LIBUSB_1_INCLUDE_DIR)
set(LIBUSB_1_INCLUDE_DIRS ${LIBUSB_1_INCLUDE_DIR})
endif()

if (LIBUSB_1_LIBRARY)
set(LIBUSB_1_LIBRARIES ${LIBUSB_1_LIBRARY})
endif()

if (LIBUSB_1_INCLUDE_DIRS AND LIBUSB_1_LIBRARIES)
set(LIBUSB_1_FOUND TRUE)
Expand All @@ -106,16 +107,15 @@ endif(bananapi-r2)
message(STATUS " - LIBUSB_1_INCLUDE_DIRS: ${LIBUSB_1_INCLUDE_DIRS}")
message(STATUS " - LIBUSB_1_LIBRARIES: ${LIBUSB_1_LIBRARIES}")
endif (NOT libusb-1.0_FIND_QUIETLY)
# show the LIBUSB_1_INCLUDE_DIRS and LIBUSB_1_LIBRARIES variables only in the advanced view
mark_as_advanced(LIBUSB_1_INCLUDE_DIRS LIBUSB_1_LIBRARIES)
mark_as_advanced(LIBUSB_1_INCLUDE_DIR LIBUSB_1_LIBRARY)
else (LIBUSB_1_FOUND)
if (libusb-1.0_FIND_REQUIRED)
message(FATAL_ERROR "Could not find libusb")
endif (libusb-1.0_FIND_REQUIRED)
endif (LIBUSB_1_FOUND)

# show the LIBUSB_1_INCLUDE_DIRS and LIBUSB_1_LIBRARIES variables only in the advanced view
mark_as_advanced(LIBUSB_1_INCLUDE_DIRS LIBUSB_1_LIBRARIES)
mark_as_advanced(LIBUSB_1_INCLUDE_DIR LIBUSB_1_LIBRARY)

endif (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)

set(libusb-1.0_FOUND ${LIBUSB_1_FOUND})
63 changes: 33 additions & 30 deletions plugins/HDSDR/src/ExtIO_LimeSDR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ THE SOFTWARE
#include <process.h>
//---------------------------------------------------------------------------
#include <limesuiteng/complex.h>
#include <limesuiteng/types.h>
#include <limesuiteng/DeviceHandle.h>
#include <limesuiteng/DeviceRegistry.h>
#include <limesuiteng/Logger.h>
#include <limesuiteng/SDRDevice.h>
#include <limesuiteng/SDRDescriptor.h>
#include <limesuiteng/StreamConfig.h>
#include <limesuiteng/VersionInfo.h>
//---------------------------------------------------------------------------
#include <array>
Expand Down Expand Up @@ -141,8 +144,8 @@ static void error(lime::LogLevel lvl, const char* msg)
DbgPrintf(msg);
DbgPrintf("\n");
#else
if (isErrorLoggingEnabled && lvl < lime::LogLevel::WARNING) {
if (lvl == lime::LogLevel::CRITICAL) {
if (isErrorLoggingEnabled && lvl < lime::LogLevel::Warning) {
if (lvl == lime::LogLevel::Critical) {
ExtIOCallback(-1, extHw_Stop, 0, NULL);
}
DbgPrintf(msg);
Expand All @@ -154,19 +157,19 @@ static bool SetGain()
{
int rcc_ctl_pga_rbb = (430 * std::pow(0.65, PGA / 10.0) - 110.35) / 20.4516 + 16; //From datasheet

if (device->SetParameter(0, 0, "G_LNA_RFE"s, LNA) != lime::OpStatus::SUCCESS) {
if (device->SetParameter(0, 0, "G_LNA_RFE"s, LNA) != lime::OpStatus::Success) {
return false;
}

if (device->SetParameter(0, 0, "G_PGA_RBB"s, PGA) != lime::OpStatus::SUCCESS) {
if (device->SetParameter(0, 0, "G_PGA_RBB"s, PGA) != lime::OpStatus::Success) {
return false;
}

if (device->SetParameter(0, 0, "RCC_CTL_PGA_RBB"s, rcc_ctl_pga_rbb) != lime::OpStatus::SUCCESS) {
if (device->SetParameter(0, 0, "RCC_CTL_PGA_RBB"s, rcc_ctl_pga_rbb) != lime::OpStatus::Success) {
return false;
}

if (device->SetParameter(0, 0, "G_TIA_RFE"s, TIA) != lime::OpStatus::SUCCESS) {
if (device->SetParameter(0, 0, "G_TIA_RFE"s, TIA) != lime::OpStatus::Success) {
return false;
}

Expand All @@ -184,7 +187,7 @@ static void PerformCalibration(bool enableErrorLogging)

isCalibrated = CalibrationStatus::Calibrated;

if (device->Calibrate(0, lime::TRXDir::Rx, channel, calibrationBandwidth) != lime::OpStatus::SUCCESS) {
if (device->Calibrate(0, lime::TRXDir::Rx, channel, calibrationBandwidth) != lime::OpStatus::Success) {
isCalibrated = CalibrationStatus::CalibrationErr;
}

Expand All @@ -203,18 +206,18 @@ static bool DisableLPF()
}

/* Making sure that tia isn't -12dB */
if (device->SetParameter(0, 0, "G_TIA_RFE", 3) != lime::OpStatus::SUCCESS) {
if (device->SetParameter(0, 0, "G_TIA_RFE", 3) != lime::OpStatus::Success) {
return false;
}

/* If the bandwidth is higher than 110e6, LPF is bypassed */
if (device->SetLowPassFilter(0, lime::TRXDir::Rx, channel, 130e6) != lime::OpStatus::SUCCESS) {
if (device->SetLowPassFilter(0, lime::TRXDir::Rx, channel, 130e6) != lime::OpStatus::Success) {
return false;
}

isLPFEnabled = false;

if (device->SetParameter(0, 0, "G_TIA_RFE", TIA) != lime::OpStatus::SUCCESS) {
if (device->SetParameter(0, 0, "G_TIA_RFE", TIA) != lime::OpStatus::Success) {
return false;
}

Expand All @@ -235,15 +238,15 @@ static bool EnableLPF()
StopHW();
}

if (device->SetParameter(0, 0, "G_TIA_RFE", 3) != lime::OpStatus::SUCCESS) {
if (device->SetParameter(0, 0, "G_TIA_RFE", 3) != lime::OpStatus::Success) {
return false;
}

if (device->SetLowPassFilter(0, lime::TRXDir::Rx, channel, LPFBandwidth) != lime::OpStatus::SUCCESS) {
if (device->SetLowPassFilter(0, lime::TRXDir::Rx, channel, LPFBandwidth) != lime::OpStatus::Success) {
return false;
}

if (device->SetParameter(0, 0, "G_TIA_RFE", TIA) != lime::OpStatus::SUCCESS) {
if (device->SetParameter(0, 0, "G_TIA_RFE", TIA) != lime::OpStatus::Success) {
return false;
}
isLPFEnabled = true;
Expand Down Expand Up @@ -272,14 +275,14 @@ static bool InitializeLMS()
return false;
}

const lime::SDRDevice::Descriptor& descriptor = device->GetDescriptor();
const lime::SDRDescriptor& descriptor = device->GetDescriptor();

numberOfChannels = descriptor.rfSOC.at(0).channelCount;
if (numberOfChannels <= 0) {
return false;
}

lime::SDRDevice::SDRConfig configuration;
lime::SDRConfig configuration;
auto& channelConfiguration = configuration.channel[channel].rx;

channelConfiguration.enabled = true;
Expand All @@ -295,7 +298,7 @@ static bool InitializeLMS()

isCalibrated = CalibrationStatus::Calibrated;

if (device->Configure(configuration, 0) != lime::OpStatus::SUCCESS) {
if (device->Configure(configuration, 0) != lime::OpStatus::Success) {
isCalibrated = CalibrationStatus::CalibrationErr;

return false;
Expand Down Expand Up @@ -369,7 +372,7 @@ static int InitializeDialog(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
}
ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_COMBO_DEVICE), currentDeviceIndex);

const lime::SDRDevice::Descriptor& descriptor = device->GetDescriptor();
const lime::SDRDescriptor& descriptor = device->GetDescriptor();

/* Add antenna choices */
for (std::size_t i = 0; i < descriptor.rfSOC.at(0).pathNames.at(lime::TRXDir::Rx).size(); ++i) {
Expand Down Expand Up @@ -489,7 +492,7 @@ static int OnAntennaChange(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam
StopHW();
}

if (device->SetAntenna(0, lime::TRXDir::Rx, channel, antennaSelect) != lime::OpStatus::SUCCESS) {
if (device->SetAntenna(0, lime::TRXDir::Rx, channel, antennaSelect) != lime::OpStatus::Success) {
return FALSE;
}

Expand Down Expand Up @@ -554,7 +557,7 @@ static int OnDeviceChange(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
ComboBox_DeleteString(GetDlgItem(hwndDlg, IDC_COMBO_ANT), 0);
}

const lime::SDRDevice::Descriptor& descriptor = device->GetDescriptor();
const lime::SDRDescriptor& descriptor = device->GetDescriptor();

/* Add antenna choices */
for (std::size_t i = 0; i < descriptor.rfSOC.at(0).pathNames.at(lime::TRXDir::Rx).size(); ++i) {
Expand Down Expand Up @@ -591,23 +594,23 @@ static int OnChannelChange(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam
StopHW();
}

if (device->EnableChannel(0, lime::TRXDir::Rx, channel, false) != lime::OpStatus::SUCCESS) {
if (device->EnableChannel(0, lime::TRXDir::Rx, channel, false) != lime::OpStatus::Success) {
return FALSE;
}
if (device->EnableChannel(0, lime::TRXDir::Tx, channel, false) != lime::OpStatus::SUCCESS) {
if (device->EnableChannel(0, lime::TRXDir::Tx, channel, false) != lime::OpStatus::Success) {
return FALSE;
}

channel = ComboBox_GetCurSel(GET_WM_COMMAND_HWND(wParam, lParam));

if (device->EnableChannel(0, lime::TRXDir::Rx, channel, true) != lime::OpStatus::SUCCESS) {
if (device->EnableChannel(0, lime::TRXDir::Rx, channel, true) != lime::OpStatus::Success) {
return FALSE;
}
if (device->EnableChannel(0, lime::TRXDir::Tx, channel, true) != lime::OpStatus::SUCCESS) {
if (device->EnableChannel(0, lime::TRXDir::Tx, channel, true) != lime::OpStatus::Success) {
return FALSE;
}

if (device->SetAntenna(0, lime::TRXDir::Rx, channel, antennaSelect) != lime::OpStatus::SUCCESS) {
if (device->SetAntenna(0, lime::TRXDir::Rx, channel, antennaSelect) != lime::OpStatus::Success) {
return FALSE;
}

Expand Down Expand Up @@ -890,13 +893,13 @@ int EXTIO_API StartHW64(int64_t LOfreq)
{
SetHWLO64(LOfreq);

lime::SDRDevice::StreamConfig config;
lime::StreamConfig config;

config.channels.at(lime::TRXDir::Rx) = { 0 };
config.bufferSize = 1024 * 128;
config.format = lime::SDRDevice::StreamConfig::DataFormat::I16;
config.format = lime::DataFormat::I16;

if (device->StreamSetup(config, 0) != lime::OpStatus::SUCCESS) {
if (device->StreamSetup(config, 0) != lime::OpStatus::Success) {
return -1;
}

Expand Down Expand Up @@ -1015,7 +1018,7 @@ int EXTIO_API GetActualAttIdx(void)
double _gain = 0;

if (device != nullptr) {
if (device->GetGain(0, lime::TRXDir::Rx, channel, lime::eGainTypes::UNKNOWN, _gain) != lime::OpStatus::SUCCESS) {
if (device->GetGain(0, lime::TRXDir::Rx, channel, lime::eGainTypes::UNKNOWN, _gain) != lime::OpStatus::Success) {
return -1; // ERROR
}
}
Expand All @@ -1026,7 +1029,7 @@ int EXTIO_API GetActualAttIdx(void)
int EXTIO_API SetAttenuator(int atten_idx)
{
if (device != nullptr) {
if (device->SetGain(0, lime::TRXDir::Rx, channel, lime::eGainTypes::UNKNOWN, atten_idx) != lime::OpStatus::SUCCESS) {
if (device->SetGain(0, lime::TRXDir::Rx, channel, lime::eGainTypes::UNKNOWN, atten_idx) != lime::OpStatus::Success) {
return -1; // ERROR
}
isCalibrated = CalibrationStatus::NotCalibrated;
Expand Down Expand Up @@ -1057,7 +1060,7 @@ int EXTIO_API ExtIoSetSrate(int srate_idx)
StopHW();
}

if (device->SetSampleRate(0, lime::TRXDir::Rx, 0, sampleRates.at(srate_idx), oversample) != lime::OpStatus::SUCCESS) {
if (device->SetSampleRate(0, lime::TRXDir::Rx, 0, sampleRates.at(srate_idx), oversample) != lime::OpStatus::Success) {
return -1;
}

Expand Down
12 changes: 7 additions & 5 deletions plugins/SoapyLMS7/Registration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,28 @@
#include <SoapySDR/Logger.hpp>

#include "limesuiteng/Logger.h"
#include "limesuiteng/DeviceHandle.h"

using namespace lime;

static void limeSuiteLogHandler(const LogLevel level, const char* message)
{
switch (level)
{
case LogLevel::CRITICAL:
case LogLevel::Critical:
SoapySDR::log(SOAPY_SDR_CRITICAL, message);
return;
case LogLevel::ERROR:
case LogLevel::Error:
SoapySDR::log(SOAPY_SDR_ERROR, message);
return;
case LogLevel::WARNING:
case LogLevel::Warning:
SoapySDR::log(SOAPY_SDR_WARNING, message);
return;
case LogLevel::INFO:
case LogLevel::Info:
case LogLevel::Verbose:
SoapySDR::log(SOAPY_SDR_INFO, message);
return;
case LogLevel::DEBUG:
case LogLevel::Debug:
SoapySDR::log(SOAPY_SDR_DEBUG, message);
return;
}
Expand Down
Loading
Loading