kopia lustrzana https://github.com/rpp0/gr-lora
Fix linker errors for GNU Radio 3.8
Remove define conflict with log4cpp Port lora_receive_file_nogui.py to Python 3dev
rodzic
762c466fb2
commit
da8c067a90
|
@ -21,12 +21,12 @@
|
|||
# gr-lora specific options
|
||||
########################################################################
|
||||
option(HAS_MONGODB "Support for storing data to MongoDB" OFF)
|
||||
option(DEBUG "Print debug output" OFF)
|
||||
option(GRLORA_DEBUG "Print debug output" OFF)
|
||||
|
||||
if(DEBUG)
|
||||
if(GRLORA_DEBUG)
|
||||
message("-- Enabling debug mode")
|
||||
add_definitions(-DDEBUG)
|
||||
endif(DEBUG)
|
||||
add_definitions(-DGRLORA_DEBUG)
|
||||
endif(GRLORA_DEBUG)
|
||||
|
||||
########################################################################
|
||||
# Project setup
|
||||
|
@ -35,18 +35,34 @@ cmake_minimum_required(VERSION 3.8)
|
|||
project(gr-lora CXX C)
|
||||
enable_testing()
|
||||
|
||||
#select the release build type by default to get optimization flags
|
||||
# Install to PyBOMBS target prefix if defined
|
||||
if(DEFINED ENV{PYBOMBS_PREFIX})
|
||||
set(CMAKE_INSTALL_PREFIX $ENV{PYBOMBS_PREFIX})
|
||||
message(STATUS "PyBOMBS installed GNU Radio. Setting CMAKE_INSTALL_PREFIX to $ENV{PYBOMBS_PREFIX}")
|
||||
endif()
|
||||
|
||||
|
||||
# Select the release build type by default to get optimization flags
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
message(STATUS "Build type not specified: defaulting to release.")
|
||||
endif(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "")
|
||||
|
||||
#make sure our local CMake Modules path comes first
|
||||
# Make sure our local CMake Modules path comes first
|
||||
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/Modules)
|
||||
|
||||
# Set the version information here
|
||||
set(VERSION_MAJOR 1)
|
||||
set(VERSION_API 0)
|
||||
set(VERSION_ABI 0)
|
||||
set(VERSION_PATCH git)
|
||||
|
||||
cmake_policy(SET CMP0011 NEW)
|
||||
|
||||
# Enable generation of compile_commands.json for code completion engines
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
########################################################################
|
||||
# Compiler specific setup
|
||||
########################################################################
|
||||
|
@ -55,7 +71,6 @@ if((CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
|
|||
AND NOT WIN32)
|
||||
#http://gcc.gnu.org/wiki/Visibility
|
||||
add_definitions(-fvisibility=hidden)
|
||||
add_definitions(-std=c++11)
|
||||
add_definitions(-Wall)
|
||||
add_definitions(-Wextra)
|
||||
endif()
|
||||
|
@ -83,11 +98,15 @@ ENDIF()
|
|||
########################################################################
|
||||
# Install directories
|
||||
########################################################################
|
||||
find_package(Gnuradio "3.8" REQUIRED COMPONENTS blocks filter fft)
|
||||
find_package(Gnuradio "3.8" REQUIRED COMPONENTS blocks filter fft analog digital)
|
||||
include(GrVersion)
|
||||
|
||||
include(GrPlatform) #define LIB_SUFFIX
|
||||
|
||||
if(NOT CMAKE_MODULES_DIR)
|
||||
set(CMAKE_MODULES_DIR lib${LIB_SUFFIX}/cmake)
|
||||
endif(NOT CMAKE_MODULES_DIR)
|
||||
|
||||
set(GR_RUNTIME_DIR bin)
|
||||
set(GR_LIBRARY_DIR lib${LIB_SUFFIX})
|
||||
set(GR_INCLUDE_DIR include/lora)
|
||||
|
@ -100,6 +119,7 @@ set(GR_PKG_CONF_DIR ${GR_CONF_DIR}/${CMAKE_PROJECT_NAME}/conf.d)
|
|||
set(GR_LIBEXEC_DIR libexec)
|
||||
set(GR_PKG_LIBEXEC_DIR ${GR_LIBEXEC_DIR}/${CMAKE_PROJECT_NAME})
|
||||
set(GRC_BLOCKS_DIR ${GR_PKG_DATA_DIR}/grc/blocks)
|
||||
set(GR_CMAKE_DIR ${CMAKE_MODULES_DIR}/lora)
|
||||
|
||||
########################################################################
|
||||
# On Apple only, set install name and use rpath correctly, if not already set
|
||||
|
@ -124,13 +144,8 @@ endif(APPLE)
|
|||
########################################################################
|
||||
# Find gnuradio build dependencies
|
||||
########################################################################
|
||||
find_package(CppUnit)
|
||||
find_package(Doxygen)
|
||||
|
||||
if(NOT CPPUNIT_FOUND)
|
||||
message(FATAL_ERROR "CppUnit required to compile lora")
|
||||
endif()
|
||||
|
||||
########################################################################
|
||||
# Setup doxygen option
|
||||
########################################################################
|
||||
|
@ -166,10 +181,6 @@ add_subdirectory(docs)
|
|||
########################################################################
|
||||
# Install cmake search helper for this library
|
||||
########################################################################
|
||||
if(NOT CMAKE_MODULES_DIR)
|
||||
set(CMAKE_MODULES_DIR lib${LIB_SUFFIX}/cmake)
|
||||
endif(NOT CMAKE_MODULES_DIR)
|
||||
|
||||
install(FILES cmake/Modules/loraConfig.cmake
|
||||
DESTINATION ${CMAKE_MODULES_DIR}/lora
|
||||
)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python3
|
||||
# Gets a USRP capture trace from my research page and decodes it using gr-lora.
|
||||
# Author: Pieter Robyns
|
||||
|
||||
|
|
|
@ -39,13 +39,13 @@ if(NOT lora_sources)
|
|||
endif(NOT lora_sources)
|
||||
|
||||
add_library(gnuradio-lora SHARED ${lora_sources})
|
||||
target_link_libraries(gnuradio-lora ${Boost_LIBRARIES} ${GNURADIO_ALL_LIBRARIES} liquid log4cpp)
|
||||
set_target_properties(gnuradio-lora PROPERTIES DEFINE_SYMBOL "gnuradio_lora_EXPORTS")
|
||||
target_link_libraries(gnuradio-lora gnuradio::gnuradio-runtime gnuradio::gnuradio-blocks gnuradio::gnuradio-filter liquid log4cpp)
|
||||
target_include_directories(gnuradio-lora
|
||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
|
||||
PUBLIC $<BUILD_INTERFACE:${Boost_INCLUDE_DIR}>
|
||||
PUBLIC $<INSTALL_INTERFACE:include>
|
||||
)
|
||||
set_target_properties(gnuradio-lora PROPERTIES DEFINE_SYMBOL "gnuradio_lora_EXPORTS")
|
||||
|
||||
if(APPLE)
|
||||
set_target_properties(gnuradio-lora PROPERTIES
|
||||
|
@ -56,18 +56,16 @@ endif(APPLE)
|
|||
########################################################################
|
||||
# Install built library files
|
||||
########################################################################
|
||||
install(TARGETS gnuradio-lora
|
||||
LIBRARY DESTINATION lib${LIB_SUFFIX} # .so/.dylib file
|
||||
ARCHIVE DESTINATION lib${LIB_SUFFIX} # .lib file
|
||||
RUNTIME DESTINATION bin # .dll file
|
||||
)
|
||||
include(GrMiscUtils)
|
||||
GR_LIBRARY_FOO(gnuradio-lora RUNTIME_COMPONENT "lora_runtime" DEVEL_COMPONENT "lora_devel")
|
||||
|
||||
########################################################################
|
||||
# Build and register unit test
|
||||
########################################################################
|
||||
include(GrTest)
|
||||
|
||||
include_directories(${CPPUNIT_INCLUDE_DIRS})
|
||||
# If your unit tests require special include paths, add them here
|
||||
# include_directories()
|
||||
|
||||
list(APPEND test_lora_sources
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_lora.cc
|
||||
|
@ -75,15 +73,16 @@ list(APPEND test_lora_sources
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/qa_message_socket_sink.cc
|
||||
)
|
||||
|
||||
add_executable(test-lora ${test_lora_sources})
|
||||
# Anything we need to link to for the unit tests go here
|
||||
list(APPEND GR_TEST_TARGET_DEPS gnuradio-lora)
|
||||
|
||||
target_link_libraries(
|
||||
test-lora
|
||||
${GNURADIO_RUNTIME_LIBRARIES}
|
||||
${Boost_LIBRARIES}
|
||||
${CPPUNIT_LIBRARIES}
|
||||
gnuradio-lora
|
||||
liquid
|
||||
)
|
||||
if(NOT test_foo_sources)
|
||||
MESSAGE(STATUS "No C++ unit tests... skipping")
|
||||
return()
|
||||
endif(NOT test_foo_sources)
|
||||
|
||||
GR_ADD_TEST(test_lora test-lora)
|
||||
foreach(qa_file ${test_lora_sources})
|
||||
GR_ADD_CPP_TEST("lora_${qa_file}"
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${qa_file}
|
||||
)
|
||||
endforeach(qa_file)
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
//#define DBGR_CHRONO /// Measure execution time
|
||||
|
||||
#ifndef DEBUG
|
||||
#ifndef GRLORA_DEBUG
|
||||
#define DBGR_PAUSE(MSG)
|
||||
#define DBGR_QUICK_TO_FILE(FILEPATH, APPEND, DATA, SIZE, FORMAT)
|
||||
#define DBGR_WRITE_SIGNAL(IDEAL_SIG_FP, SAMPLE_SIG_FP, WINDOW, OFFSET, MIN, MAX, FULL, PAUSE, MSG)
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace gr {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef GRLORA_DEBUG
|
||||
d_debug_samples.open("/tmp/grlora_debug", std::ios::out | std::ios::binary);
|
||||
d_debug.open("/tmp/grlora_debug_txt", std::ios::out);
|
||||
d_dbg.attach();
|
||||
|
@ -125,7 +125,7 @@ namespace gr {
|
|||
* Our virtual destructor.
|
||||
*/
|
||||
decoder_impl::~decoder_impl() {
|
||||
#ifdef DEBUG
|
||||
#ifdef GRLORA_DEBUG
|
||||
if (d_debug_samples.is_open())
|
||||
d_debug_samples.close();
|
||||
|
||||
|
@ -189,7 +189,7 @@ namespace gr {
|
|||
}
|
||||
|
||||
void decoder_impl::samples_to_file(const std::string path, const gr_complex *v, const uint32_t length, const uint32_t elem_size) {
|
||||
#ifdef DEBUG
|
||||
#ifdef GRLORA_DEBUG
|
||||
std::ofstream out_file;
|
||||
out_file.open(path.c_str(), std::ios::out | std::ios::binary);
|
||||
|
||||
|
@ -208,7 +208,7 @@ namespace gr {
|
|||
}
|
||||
|
||||
void decoder_impl::samples_debug(const gr_complex *v, const uint32_t length) {
|
||||
#ifdef DEBUG
|
||||
#ifdef GRLORA_DEBUG
|
||||
gr_complex start_indicator(0.0f, 32.0f);
|
||||
d_debug_samples.write(reinterpret_cast<const char *>(&start_indicator), sizeof(gr_complex));
|
||||
|
||||
|
@ -314,7 +314,7 @@ namespace gr {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef GRLORA_DEBUG
|
||||
//d_debug << "FINE: " << -lag << std::endl;
|
||||
#endif
|
||||
|
||||
|
@ -498,7 +498,7 @@ namespace gr {
|
|||
// Decode (actually gray encode) the bin to get the symbol value
|
||||
const uint32_t word = bin_idx ^ (bin_idx >> 1u);
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef GRLORA_DEBUG
|
||||
d_debug << gr::lora::to_bin(word, reduced_rate ? d_sf - 2u : d_sf) << " " << word << " (bin " << bin_idx << ")" << std::endl;
|
||||
#endif
|
||||
d_words.push_back(word);
|
||||
|
@ -539,7 +539,7 @@ namespace gr {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef GRLORA_DEBUG
|
||||
print_interleave_matrix(d_debug, d_words, ppm);
|
||||
print_vector_bin(d_debug, words_deinterleaved, "D", sizeof(uint8_t) * 8u);
|
||||
#endif
|
||||
|
@ -618,7 +618,7 @@ namespace gr {
|
|||
d_words_deshuffled.push_back(result);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef GRLORA_DEBUG
|
||||
print_vector_bin(d_debug, d_words_deshuffled, "S", sizeof(uint8_t)*8);
|
||||
#endif
|
||||
|
||||
|
@ -639,7 +639,7 @@ namespace gr {
|
|||
d_words_dewhitened.push_back(xor_b);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef GRLORA_DEBUG
|
||||
print_vector_bin(d_debug, d_words_dewhitened, "W", sizeof(uint8_t) * 8);
|
||||
#endif
|
||||
|
||||
|
@ -749,7 +749,7 @@ namespace gr {
|
|||
|
||||
if (correlation >= 0.90f) {
|
||||
determine_snr();
|
||||
#ifdef DEBUG
|
||||
#ifdef GRLORA_DEBUG
|
||||
d_debug << "Ca: " << correlation << std::endl;
|
||||
#endif
|
||||
d_corr_fails = 0u;
|
||||
|
@ -780,12 +780,12 @@ namespace gr {
|
|||
case gr::lora::DecoderState::FIND_SFD: {
|
||||
const float c = detect_downchirp(input, d_samples_per_symbol);
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef GRLORA_DEBUG
|
||||
d_debug << "Cd: " << c << std::endl;
|
||||
#endif
|
||||
|
||||
if (c > 0.96f) {
|
||||
#ifdef DEBUG
|
||||
#ifdef GRLORA_DEBUG
|
||||
d_debug << "SYNC: " << c << std::endl;
|
||||
#endif
|
||||
// Debug stuff
|
||||
|
@ -801,7 +801,7 @@ namespace gr {
|
|||
|
||||
if (d_corr_fails > 4u) {
|
||||
d_state = gr::lora::DecoderState::DETECT;
|
||||
#ifdef DEBUG
|
||||
#ifdef GRLORA_DEBUG
|
||||
d_debug << "Lost sync" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
@ -844,7 +844,7 @@ namespace gr {
|
|||
const int blocks_needed = (int)std::ceil(symbols_needed / symbols_per_block);
|
||||
d_payload_symbols = blocks_needed * symbols_per_block;
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef GRLORA_DEBUG
|
||||
d_debug << "LEN: " << d_payload_length << " (" << d_payload_symbols << " symbols)" << std::endl;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -24,14 +24,11 @@ description here (python/__init__.py).
|
|||
'''
|
||||
|
||||
# import swig generated symbols into the lora namespace
|
||||
try:
|
||||
# this might fail if the module is python-only
|
||||
from lora_swig import *
|
||||
except ImportError:
|
||||
pass
|
||||
# this might fail if the module is python-only
|
||||
from .lora_swig import *
|
||||
|
||||
# import any pure python here
|
||||
from lora_receiver import lora_receiver
|
||||
from .lora_receiver import lora_receiver
|
||||
#
|
||||
|
||||
# import optional blocks
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python3
|
||||
import lora
|
||||
import socket
|
||||
import pmt
|
||||
|
@ -108,7 +108,7 @@ class TestSummary():
|
|||
self._num_total_payloads += 1
|
||||
|
||||
try:
|
||||
decoded = decoded_data[i]
|
||||
decoded = decoded_data[i].decode('utf-8')
|
||||
except IndexError:
|
||||
decoded = "?"
|
||||
try:
|
||||
|
@ -121,7 +121,7 @@ class TestSummary():
|
|||
self._num_total_correct_payloads += 1
|
||||
else:
|
||||
if self.pause:
|
||||
_ = raw_input("Expected %s but got %s for %s. Press enter to continue..." % (expected, decoded, lora_config.string_repr()))
|
||||
_ = input("Expected %s but got %s for %s. Press enter to continue..." % (expected, decoded, lora_config.string_repr()))
|
||||
|
||||
# Append to text report
|
||||
evaluation_text += "\tTest {:>3n}: {:<30s} * {:<3n} :: passed {:>3n} out of {:<3n} ({:.2%})\n".format(
|
||||
|
|
Ładowanie…
Reference in New Issue