1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-31 11:19:18 +00:00

Fix building if boost::endian is not available

This commit is contained in:
Carles Fernandez 2022-12-05 15:02:35 +01:00
parent 38341c351b
commit cecf7e5e43
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
2 changed files with 32 additions and 32 deletions

View File

@ -6,48 +6,41 @@
# Optional drivers # Optional drivers
set(OPT_DRIVER_SOURCES "")
set(OPT_DRIVER_HEADERS "")
if(ENABLE_RAW_UDP AND PCAP_FOUND) if(ENABLE_RAW_UDP AND PCAP_FOUND)
set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} custom_udp_signal_source.cc) list(APPEND OPT_DRIVER_SOURCES custom_udp_signal_source.cc)
set(OPT_DRIVER_HEADERS ${OPT_DRIVER_HEADERS} custom_udp_signal_source.h) list(APPEND OPT_DRIVER_HEADERS custom_udp_signal_source.h)
endif() endif()
if(ENABLE_PLUTOSDR) if(ENABLE_PLUTOSDR)
############################################## ##############################################
# ADALM-PLUTO (Analog Devices Inc.) # ADALM-PLUTO (Analog Devices Inc.)
############################################## ##############################################
set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} plutosdr_signal_source.cc) list(APPEND OPT_DRIVER_SOURCES plutosdr_signal_source.cc)
set(OPT_DRIVER_HEADERS ${OPT_DRIVER_HEADERS} plutosdr_signal_source.h) list(APPEND OPT_DRIVER_HEADERS plutosdr_signal_source.h)
endif() endif()
if(ENABLE_FMCOMMS2) if(ENABLE_FMCOMMS2)
############################################### ###############################################
# FMCOMMS2 based SDR Hardware # FMCOMMS2 based SDR Hardware
############################################### ###############################################
set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} fmcomms2_signal_source.cc) list(APPEND OPT_DRIVER_SOURCES fmcomms2_signal_source.cc)
set(OPT_DRIVER_HEADERS ${OPT_DRIVER_HEADERS} fmcomms2_signal_source.h) list(APPEND OPT_DRIVER_HEADERS fmcomms2_signal_source.h)
endif() endif()
if(ENABLE_AD9361) if(ENABLE_AD9361)
############################################### ###############################################
# AD9361 DIRECT TO FPGA Hardware # AD9361 DIRECT TO FPGA Hardware
############################################### ###############################################
set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} ad9361_fpga_signal_source.cc) list(APPEND OPT_DRIVER_SOURCES ad9361_fpga_signal_source.cc)
set(OPT_DRIVER_HEADERS ${OPT_DRIVER_HEADERS} ad9361_fpga_signal_source.h) list(APPEND OPT_DRIVER_HEADERS ad9361_fpga_signal_source.h)
endif() endif()
if(ENABLE_FLEXIBAND AND TELEORBIT_FOUND) if(ENABLE_FLEXIBAND AND TELEORBIT_FOUND)
set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} flexiband_signal_source.cc) list(APPEND OPT_DRIVER_SOURCES flexiband_signal_source.cc)
set(OPT_DRIVER_HEADERS ${OPT_DRIVER_HEADERS} flexiband_signal_source.h) list(APPEND OPT_DRIVER_HEADERS flexiband_signal_source.h)
endif() endif()
if(ENABLE_ARRAY) if(ENABLE_ARRAY)
############################################## ##############################################
# DBFCTTC GNSS EXPERIMENTAL ARRAY PROTOTYPE # DBFCTTC GNSS EXPERIMENTAL ARRAY PROTOTYPE
@ -56,32 +49,30 @@ if(ENABLE_ARRAY)
message(" gr-dbfcttc not found, install it from https://github.com/gnss-sdr/gr-dbfcttc") message(" gr-dbfcttc not found, install it from https://github.com/gnss-sdr/gr-dbfcttc")
message(FATAL_ERROR "gr-dbfcttc required for building gnss-sdr with this option enabled") message(FATAL_ERROR "gr-dbfcttc required for building gnss-sdr with this option enabled")
endif() endif()
set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} raw_array_signal_source.cc) list(APPEND OPT_DRIVER_SOURCES raw_array_signal_source.cc)
set(OPT_DRIVER_HEADERS ${OPT_DRIVER_HEADERS} raw_array_signal_source.h) list(APPEND OPT_DRIVER_HEADERS raw_array_signal_source.h)
endif() endif()
if(ENABLE_OSMOSDR) if(ENABLE_OSMOSDR)
################################################################################ ################################################################################
# OsmoSDR - https://osmocom.org/projects/gr-osmosdr/ # OsmoSDR - https://osmocom.org/projects/gr-osmosdr/
################################################################################ ################################################################################
if(GROSMOSDR_FOUND) if(GROSMOSDR_FOUND)
set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} osmosdr_signal_source.cc) list(APPEND OPT_DRIVER_SOURCES osmosdr_signal_source.cc)
set(OPT_DRIVER_HEADERS ${OPT_DRIVER_HEADERS} osmosdr_signal_source.h) list(APPEND OPT_DRIVER_HEADERS osmosdr_signal_source.h)
endif() endif()
endif() endif()
if(ENABLE_LIMESDR) if(ENABLE_LIMESDR)
if(GRLIMESDR_FOUND) if(GRLIMESDR_FOUND)
set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} limesdr_signal_source.cc) list(APPEND OPT_DRIVER_SOURCES limesdr_signal_source.cc)
set(OPT_DRIVER_HEADERS ${OPT_DRIVER_HEADERS} limesdr_signal_source.h) list(APPEND OPT_DRIVER_HEADERS limesdr_signal_source.h)
endif() endif()
endif() endif()
if(ENABLE_UHD) if(ENABLE_UHD)
set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} uhd_signal_source.cc) list(APPEND OPT_DRIVER_SOURCES uhd_signal_source.cc)
set(OPT_DRIVER_HEADERS ${OPT_DRIVER_HEADERS} uhd_signal_source.h) list(APPEND OPT_DRIVER_HEADERS uhd_signal_source.h)
endif() endif()
if(ENABLE_ZMQ) if(ENABLE_ZMQ)
@ -89,7 +80,6 @@ if(ENABLE_ZMQ)
list(APPEND OPT_DRIVER_HEADERS zmq_signal_source.h) list(APPEND OPT_DRIVER_HEADERS zmq_signal_source.h)
endif() endif()
set(SIGNAL_SOURCE_ADAPTER_SOURCES set(SIGNAL_SOURCE_ADAPTER_SOURCES
signal_source_base.cc signal_source_base.cc
file_source_base.cc file_source_base.cc
@ -218,7 +208,6 @@ if(ENABLE_LIMESDR AND GRLIMESDR_FOUND)
) )
endif() endif()
if(ENABLE_AD9361 AND LIBIIO_FOUND) if(ENABLE_AD9361 AND LIBIIO_FOUND)
target_link_libraries(signal_source_adapters target_link_libraries(signal_source_adapters
PRIVATE PRIVATE
@ -302,8 +291,6 @@ target_compile_definitions(signal_source_adapters
PRIVATE -DGNSSSDR_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}" PRIVATE -DGNSSSDR_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}"
) )
set_property(TARGET signal_source_adapters set_property(TARGET signal_source_adapters
APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>

View File

@ -21,7 +21,6 @@
#include "INIReader.h" #include "INIReader.h"
#include "command_event.h" #include "command_event.h"
#include "gnss_sdr_make_unique.h" #include "gnss_sdr_make_unique.h"
#include <boost/endian/conversion.hpp>
#include <gnuradio/io_signature.h> #include <gnuradio/io_signature.h>
#include <algorithm> #include <algorithm>
#include <array> #include <array>
@ -33,6 +32,10 @@
#include <sstream> #include <sstream>
#include <utility> #include <utility>
#if HAS_BOOST_ENDIAN
#include <boost/endian/conversion.hpp>
#endif
labsat23_source_sptr labsat23_make_source_sptr(const char *signal_file_basename, const std::vector<int> &channel_selector, Concurrent_Queue<pmt::pmt_t> *queue, bool digital_io_enabled) labsat23_source_sptr labsat23_make_source_sptr(const char *signal_file_basename, const std::vector<int> &channel_selector, Concurrent_Queue<pmt::pmt_t> *queue, bool digital_io_enabled)
{ {
@ -1078,8 +1081,18 @@ int labsat23_source::general_work(int noutput_items,
{ {
uint64_t read_register = 0ULL; uint64_t read_register = 0ULL;
// Labsat3W writes its 64-bit shift register to files in little endian. Read and convert to host endianness. // Labsat3W writes its 64-bit shift register to files in little endian. Read and convert to host endianness.
#if HAS_BOOST_ENDIAN
binary_input_file.read(reinterpret_cast<char *>(&read_register), sizeof(read_register)); binary_input_file.read(reinterpret_cast<char *>(&read_register), sizeof(read_register));
boost::endian::little_to_native_inplace(read_register); boost::endian::little_to_native_inplace(read_register);
#else
std::array<char, 8> memory_block{};
binary_input_file.read(memory_block.data(), 8);
for (int k = 7; k >= 0; --k)
{
read_register <<= 8;
read_register |= uint64_t(memory_block[k]); // This is buggy if the MSB of the char is set.
}
#endif
if (binary_input_file.gcount() == 8) if (binary_input_file.gcount() == 8)
{ {