From 93410c03df8ebf2f1942f9f9c0f8009ad62eb878 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Mon, 20 Aug 2012 14:23:56 -0700 Subject: [PATCH 01/10] Update cmake modules from Gnuradio to fix parallel build bug --- cmake/Modules/GrMiscUtils.cmake | 10 +++++----- cmake/Modules/GrPlatform.cmake | 18 +++++++++++++----- cmake/Modules/GrPython.cmake | 13 +++++++++---- cmake/Modules/GrSwig.cmake | 23 +++++++++++++---------- cmake/Modules/GrTest.cmake | 20 ++++++++++++-------- 5 files changed, 52 insertions(+), 32 deletions(-) diff --git a/cmake/Modules/GrMiscUtils.cmake b/cmake/Modules/GrMiscUtils.cmake index 0e1f400..a73e3e6 100644 --- a/cmake/Modules/GrMiscUtils.cmake +++ b/cmake/Modules/GrMiscUtils.cmake @@ -1,17 +1,17 @@ # Copyright 2010-2011 Free Software Foundation, Inc. -# +# # This file is part of GNU Radio -# +# # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3, or (at your option) # any later version. -# +# # GNU Radio is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with GNU Radio; see the file COPYING. If not, write to # the Free Software Foundation, Inc., 51 Franklin Street, @@ -155,7 +155,7 @@ function(GR_LIBRARY_FOO target) GR_LIBTOOL(TARGET ${target} DESTINATION ${GR_LIBRARY_DIR}) #give the library a special name with ultra-zero soversion - set_target_properties(${target} PROPERTIES LIBRARY_OUTPUT_NAME ${target}-${LIBVER} SOVERSION "0.0.0") + set_target_properties(${target} PROPERTIES OUTPUT_NAME ${target}-${LIBVER} SOVERSION "0.0.0") set(target_name lib${target}-${LIBVER}.so.0.0.0) #custom command to generate symlinks diff --git a/cmake/Modules/GrPlatform.cmake b/cmake/Modules/GrPlatform.cmake index ce2e15f..5b7e886 100644 --- a/cmake/Modules/GrPlatform.cmake +++ b/cmake/Modules/GrPlatform.cmake @@ -1,17 +1,17 @@ # Copyright 2011 Free Software Foundation, Inc. -# +# # This file is part of GNU Radio -# +# # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3, or (at your option) # any later version. -# +# # GNU Radio is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with GNU Radio; see the file COPYING. If not, write to # the Free Software Foundation, Inc., 51 Franklin Street, @@ -37,10 +37,18 @@ if(LINUX AND EXISTS "/etc/redhat-release") set(REDHAT TRUE) endif() +if(LINUX AND EXISTS "/etc/slackware-version") + set(SLACKWARE TRUE) +endif() + ######################################################################## # when the library suffix should be 64 (applies to redhat linux family) ######################################################################## -if(NOT DEFINED LIB_SUFFIX AND REDHAT AND CMAKE_SYSTEM_PROCESSOR MATCHES "64$") +if (REDHAT OR SLACKWARE) + set(LIB64_CONVENTION TRUE) +endif() + +if(NOT DEFINED LIB_SUFFIX AND LIB64_CONVENTION AND CMAKE_SYSTEM_PROCESSOR MATCHES "64$") set(LIB_SUFFIX 64) endif() set(LIB_SUFFIX ${LIB_SUFFIX} CACHE STRING "lib directory suffix") diff --git a/cmake/Modules/GrPython.cmake b/cmake/Modules/GrPython.cmake index efdddf3..14f2b29 100644 --- a/cmake/Modules/GrPython.cmake +++ b/cmake/Modules/GrPython.cmake @@ -76,10 +76,11 @@ macro(GR_PYTHON_CHECK_MODULE desc mod cmd have) execute_process( COMMAND ${PYTHON_EXECUTABLE} -c " ######################################### -try: import ${mod} -except: exit(-1) -try: assert ${cmd} -except: exit(-1) +try: + import ${mod} + assert ${cmd} +except ImportError, AssertionError: exit(-1) +except: pass #########################################" RESULT_VARIABLE ${have} ) @@ -181,6 +182,10 @@ function(GR_PYTHON_INSTALL) #################################################################### file(TO_NATIVE_PATH ${PYTHON_EXECUTABLE} pyexe_native) + if (CMAKE_CROSSCOMPILING) + set(pyexe_native /usr/bin/env python) + endif() + foreach(pyfile ${GR_PYTHON_INSTALL_PROGRAMS}) get_filename_component(pyfile_name ${pyfile} NAME) get_filename_component(pyfile ${pyfile} ABSOLUTE) diff --git a/cmake/Modules/GrSwig.cmake b/cmake/Modules/GrSwig.cmake index 47e1808..175d0d7 100644 --- a/cmake/Modules/GrSwig.cmake +++ b/cmake/Modules/GrSwig.cmake @@ -1,17 +1,17 @@ # Copyright 2010-2011 Free Software Foundation, Inc. -# +# # This file is part of GNU Radio -# +# # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3, or (at your option) # any later version. -# +# # GNU Radio is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with GNU Radio; see the file COPYING. If not, write to # the Free Software Foundation, Inc., 51 Franklin Street, @@ -33,8 +33,7 @@ include(GrPython) # - GR_SWIG_DOCS_TARGET_DEPS ######################################################################## function(GR_SWIG_MAKE_DOCS output_file) - find_package(Doxygen) - if(DOXYGEN_FOUND) + if(ENABLE_DOXYGEN) #setup the input files variable list, quote formated set(input_files) @@ -76,17 +75,18 @@ function(GR_SWIG_MAKE_DOCS output_file) #call the swig_doc script on the xml files add_custom_command( OUTPUT ${output_file} - DEPENDS ${input_files} ${OUTPUT_DIRECTORY}/xml/index.xml + DEPENDS ${input_files} ${stamp-file} ${OUTPUT_DIRECTORY}/xml/index.xml COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${CMAKE_SOURCE_DIR}/docs/doxygen/swig_doc.py ${OUTPUT_DIRECTORY}/xml ${output_file} + COMMENT "Generating python docstrings for ${name}" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/docs/doxygen ) - else(DOXYGEN_FOUND) + else(ENABLE_DOXYGEN) file(WRITE ${output_file} "\n") #no doxygen -> empty file - endif(DOXYGEN_FOUND) + endif(ENABLE_DOXYGEN) endfunction(GR_SWIG_MAKE_DOCS) ######################################################################## @@ -105,12 +105,15 @@ endfunction(GR_SWIG_MAKE_DOCS) macro(GR_SWIG_MAKE name) set(ifiles ${ARGN}) + list(APPEND GR_SWIG_TARGET_DEPS ${GR_SWIG_LIBRARIES}) + #do swig doc generation if specified if (GR_SWIG_DOC_FILE) set(GR_SWIG_DOCS_SOURCE_DEPS ${GR_SWIG_SOURCE_DEPS}) set(GR_SWIG_DOCS_TAREGT_DEPS ${GR_SWIG_TARGET_DEPS}) GR_SWIG_MAKE_DOCS(${GR_SWIG_DOC_FILE} ${GR_SWIG_DOC_DIRS}) - list(APPEND GR_SWIG_SOURCE_DEPS ${GR_SWIG_DOC_FILE}) + add_custom_target(${name}_swig_doc DEPENDS ${GR_SWIG_DOC_FILE}) + list(APPEND GR_SWIG_TARGET_DEPS ${name}_swig_doc) endif() #append additional include directories diff --git a/cmake/Modules/GrTest.cmake b/cmake/Modules/GrTest.cmake index 9ec3141..4723cca 100644 --- a/cmake/Modules/GrTest.cmake +++ b/cmake/Modules/GrTest.cmake @@ -1,17 +1,17 @@ # Copyright 2010-2011 Free Software Foundation, Inc. -# +# # This file is part of GNU Radio -# +# # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3, or (at your option) # any later version. -# +# # GNU Radio is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with GNU Radio; see the file COPYING. If not, write to # the Free Software Foundation, Inc., 51 Franklin Street, @@ -33,7 +33,6 @@ set(__INCLUDED_GR_TEST_CMAKE TRUE) ######################################################################## function(GR_ADD_TEST test_name) - if(WIN32) #Ensure that the build exe also appears in the PATH. list(APPEND GR_TEST_TARGET_DEPS ${ARGN}) @@ -50,6 +49,7 @@ function(GR_ADD_TEST test_name) endif(location) endforeach(target) + if(WIN32) #SWIG generates the python library files into a subdirectory. #Therefore, we must append this subdirectory into PYTHONPATH. #Only do this for the python directories matching the following: @@ -74,15 +74,19 @@ function(GR_ADD_TEST test_name) #SET_TESTS_PROPERTIES(${test_name} PROPERTIES ENVIRONMENT "${environs}") if(UNIX) + set(LD_PATH_VAR "LD_LIBRARY_PATH") + if(APPLE) + set(LD_PATH_VAR "DYLD_LIBRARY_PATH") + endif() + set(binpath "${CMAKE_CURRENT_BINARY_DIR}:$PATH") - #set both LD and DYLD paths to cover multiple UNIX OS library paths - list(APPEND libpath "$LD_LIBRARY_PATH" "$DYLD_LIBRARY_PATH") + list(APPEND libpath "$${LD_PATH_VAR}") list(APPEND pypath "$PYTHONPATH") #replace list separator with the path separator string(REPLACE ";" ":" libpath "${libpath}") string(REPLACE ";" ":" pypath "${pypath}") - list(APPEND environs "PATH=${binpath}" "LD_LIBRARY_PATH=${libpath}" "DYLD_LIBRARY_PATH=${libpath}" "PYTHONPATH=${pypath}") + list(APPEND environs "PATH=${binpath}" "${LD_PATH_VAR}=${libpath}" "PYTHONPATH=${pypath}") #generate a bat file that sets the environment and runs the test find_program(SHELL sh) From 6c7a73702e275c04106e0f3a4d025d55eeaed734 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Thu, 23 Aug 2012 09:03:56 -0700 Subject: [PATCH 02/10] Slicer was being called with fewer samples than necessary for output. This may fix the "O" bug and should reduce CPU consumption. --- lib/air_modes_preamble.cc | 8 ++++++-- lib/air_modes_slicer.cc | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/air_modes_preamble.cc b/lib/air_modes_preamble.cc index 6bcf2e6..33dd033 100644 --- a/lib/air_modes_preamble.cc +++ b/lib/air_modes_preamble.cc @@ -90,7 +90,7 @@ static double tag_to_timestamp(gr_tag_t tstamp, uint64_t abs_sample_cnt, double ts_sample = tstamp.offset; double tstime = double(abs_sample_cnt * secs_per_sample) + last_whole_stamp + last_frac_stamp; - //std::cout << "HEY WE GOT A STAMP AT " << tstime << " TICKS AT SAMPLE " << ts_sample << " ABS SAMPLE CNT IS " << abs_sample_cnt << std::endl; + if(0) std::cout << "HEY WE GOT A STAMP AT " << tstime << " TICKS AT SAMPLE " << ts_sample << " ABS SAMPLE CNT IS " << abs_sample_cnt << std::endl; return tstime; } @@ -104,6 +104,8 @@ int air_modes_preamble::general_work(int noutput_items, const int ninputs = std::min(ninput_items[0], ninput_items[1]); //just in case float *out = (float *) output_items[0]; + if(0) std::cout << "Preamble called with " << ninputs << " samples" << std::endl; + //fixme move into .h const int pulse_offsets[4] = { 0, int(2 * d_samples_per_chip), @@ -187,13 +189,15 @@ int air_modes_preamble::general_work(int noutput_items, //std::cout << "PREAMBLE" << std::endl; - //produce only one output per work call + //produce only one output per work call -- TODO this should probably change + if(0) std::cout << "Preamble consumed " << i+240*d_samples_per_chip << ", returned 240" << std::endl; consume_each(i+240*d_samples_per_chip); return 240; } } //didn't get anything this time + if(0) std::cout << "Preamble consumed " << ninputs << ", returned 0" << std::endl; consume_each(ninputs); return 0; } diff --git a/lib/air_modes_slicer.cc b/lib/air_modes_slicer.cc index 1426d56..c6519aa 100644 --- a/lib/air_modes_slicer.cc +++ b/lib/air_modes_slicer.cc @@ -56,7 +56,7 @@ air_modes_slicer::air_modes_slicer(int channel_rate, gr_msg_queue_sptr queue) : d_check_width = 120 * d_samples_per_symbol; //how far you will have to look ahead d_queue = queue; - set_output_multiple(1+d_check_width); //how do you specify buffer size for sinks? + set_output_multiple(d_check_width*2); //how do you specify buffer size for sinks? } //this slicer is courtesy of Lincoln Labs. supposedly it is more resistant to mode A/C FRUIT. @@ -102,6 +102,8 @@ int air_modes_slicer::work(int noutput_items, { const float *in = (const float *) input_items[0]; int size = noutput_items - d_check_width; //since it's a sync block, i assume that it runs with ninput_items = noutput_items + + if(0) std::cout << "Slicer called with " << size << " samples" << std::endl; std::vector tags; uint64_t abs_sample_cnt = nitems_read(0); @@ -188,6 +190,6 @@ int air_modes_slicer::work(int noutput_items, gr_message_sptr msg = gr_make_message_from_string(std::string(d_payload.str())); d_queue->handle(msg); } - + if(0) std::cout << "Slicer consumed " << size << ", returned " << size << std::endl; return size; } From 60fd7b640f67ea634405029bd8de2113db128e1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= Date: Wed, 5 Sep 2012 11:43:28 +0200 Subject: [PATCH 03/10] Add SONAME --- CMakeLists.txt | 2 ++ lib/CMakeLists.txt | 2 ++ 2 files changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 175679e..17137e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,8 @@ ######################################################################## cmake_minimum_required(VERSION 2.6) project(gr-gr-air-modes CXX) +set(gr-gr-air-modes_VERSION_MAJOR 0) +set(gr-gr-air-modes_VERSION_MINOR 0) enable_testing() #select the release build type by default to get optimization flags diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 5a9504f..9ed79ae 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -29,6 +29,8 @@ add_library(air_modes SHARED ) target_link_libraries(air_modes ${Boost_LIBRARIES} ${GRUEL_LIBRARIES} ${GNURADIO_CORE_LIBRARIES}) set_target_properties(air_modes PROPERTIES DEFINE_SYMBOL "AIR_MODES_EXPORTS") +set_target_properties(air_modes PROPERTIES SOVERSION "${gr-gr-air-modes_VERSION_MAJOR}") +set_target_properties(air_modes PROPERTIES VERSION "${gr-gr-air-modes_VERSION_MAJOR}.${gr-gr-air-modes_VERSION_MINOR}") ######################################################################## # Install built library files From d1b69405bf07fd10d682bf246fc6e6b879b6439c Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Sat, 8 Sep 2012 10:34:26 -0700 Subject: [PATCH 04/10] Fix bitrot in modes_print. --- python/modes_print.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/modes_print.py b/python/modes_print.py index dd611c7..837666c 100644 --- a/python/modes_print.py +++ b/python/modes_print.py @@ -177,7 +177,7 @@ class modes_output_print(modes_parse.modes_parse): retstr = "Type 17 BDS6,2 (emergency) from %x type %s" % (icao24, emerg_str) else: - retstr = "Type 17 subtype %i from %x not implemented" % (subtype, icao24) + retstr = "Type 17 subtype %i from %x not implemented" % (data["me"], icao24) return retstr From 396ee330c4c606f9fd4bea27c0d80481816b9bbf Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Fri, 14 Sep 2012 09:06:51 -0700 Subject: [PATCH 05/10] Add carriage returns before linefeeds in SBS1 feed. --- python/modes_sbs1.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/python/modes_sbs1.py b/python/modes_sbs1.py index 20d6457..070fd35 100644 --- a/python/modes_sbs1.py +++ b/python/modes_sbs1.py @@ -131,9 +131,9 @@ class modes_output_sbs1(modes_parse.modes_parse): aircraft_id = self.get_aircraft_id(ecc) retstr = "MSG,7,0,%i,%06X,%i,%s,%s,%s,%s,,%s,,,,,,,,,," % (aircraft_id, ecc, aircraft_id+100, datestr, timestr, datestr, timestr, altitude) if vs: - retstr += "1\n" + retstr += "1\r\n" else: - retstr += "0\n" + retstr += "0\r\n" return retstr def pp4(self, shortdata, ecc): @@ -141,7 +141,7 @@ class modes_output_sbs1(modes_parse.modes_parse): [fs, dr, um, altitude] = self.parse4(shortdata) aircraft_id = self.get_aircraft_id(ecc) retstr = "MSG,5,0,%i,%06X,%i,%s,%s,%s,%s,,%s,,,,,,," % (aircraft_id, ecc, aircraft_id+100, datestr, timestr, datestr, timestr, altitude) - return retstr + self.decode_fs(fs) + "\n" + return retstr + self.decode_fs(fs) + "\r\n" def pp5(self, shortdata, ecc): # I'm not sure what to do with the identiifcation shortdata & 0x1FFF @@ -149,13 +149,13 @@ class modes_output_sbs1(modes_parse.modes_parse): [fs, dr, um, ident] = self.parse5(shortdata) aircraft_id = self.get_aircraft_id(ecc) retstr = "MSG,6,0,%i,%06X,%i,%s,%s,%s,%s,,,,,,,,," % (aircraft_id, ecc, aircraft_id+100, datestr, timestr, datestr, timestr) - return retstr + self.decode_fs(fs) + "\n" + return retstr + self.decode_fs(fs) + "\r\n" def pp11(self, shortdata, ecc): [datestr, timestr] = self.current_time() [icao24, interrogator, ca] = self.parse11(shortdata, ecc) aircraft_id = self.get_aircraft_id(icao24) - return "MSG,8,0,%i,%06X,%i,%s,%s,%s,%s,,,,,,,,,,,,\n" % (aircraft_id, icao24, aircraft_id+100, datestr, timestr, datestr, timestr) + return "MSG,8,0,%i,%06X,%i,%s,%s,%s,%s,,,,,,,,,,,,\r\n" % (aircraft_id, icao24, aircraft_id+100, datestr, timestr, datestr, timestr) def pp17(self, data): icao24 = data["aa"] @@ -170,7 +170,7 @@ class modes_output_sbs1(modes_parse.modes_parse): if bdsreg == 0x08: # Aircraft Identification (msg, typestring) = self.parseBDS08(data) - retstr = "MSG,1,0,%i,%06X,%i,%s,%s,%s,%s,%s,,,,,,,,,,,\n" % (aircraft_id, icao24, aircraft_id+100, datestr, timestr, datestr, timestr, msg) + retstr = "MSG,1,0,%i,%06X,%i,%s,%s,%s,%s,%s,,,,,,,,,,,\r\n" % (aircraft_id, icao24, aircraft_id+100, datestr, timestr, datestr, timestr, msg) elif bdsreg == 0x06: # Surface position measurement @@ -179,7 +179,7 @@ class modes_output_sbs1(modes_parse.modes_parse): if decoded_lat is None: #no unambiguously valid position available retstr = None else: - retstr = "MSG,2,0,%i,%06X,%i,%s,%s,%s,%s,,%i,,,%.5f,%.5f,,,,0,0,0\n" % (aircraft_id, icao24, aircraft_id+100, datestr, timestr, datestr, timestr, altitude, decoded_lat, decoded_lon) + retstr = "MSG,2,0,%i,%06X,%i,%s,%s,%s,%s,,%i,,,%.5f,%.5f,,,,0,0,0\r\n" % (aircraft_id, icao24, aircraft_id+100, datestr, timestr, datestr, timestr, altitude, decoded_lat, decoded_lon) elif bdsreg == 0x05: # Airborne position measurements @@ -188,7 +188,7 @@ class modes_output_sbs1(modes_parse.modes_parse): if decoded_lat is None: #no unambiguously valid position available retstr = None else: - retstr = "MSG,3,0,%i,%06X,%i,%s,%s,%s,%s,,%i,,,%.5f,%.5f,,,,0,0,0\n" % (aircraft_id, icao24, aircraft_id+100, datestr, timestr, datestr, timestr, altitude, decoded_lat, decoded_lon) + retstr = "MSG,3,0,%i,%06X,%i,%s,%s,%s,%s,,%i,,,%.5f,%.5f,,,,0,0,0\r\n" % (aircraft_id, icao24, aircraft_id+100, datestr, timestr, datestr, timestr, altitude, decoded_lat, decoded_lon) elif bdsreg == 0x09: # Airborne velocity measurements @@ -197,6 +197,6 @@ class modes_output_sbs1(modes_parse.modes_parse): if subtype == 0 or subtype == 1: parser = self.parseBDS09_0 if subtype == 0 else self.parseBDS09_1 [velocity, heading, vert_spd] = parser(data) - retstr = "MSG,4,0,%i,%06X,%i,%s,%s,%s,%s,,,%.1f,%.1f,,,%i,,,,,\n" % (aircraft_id, icao24, aircraft_id+100, datestr, timestr, datestr, timestr, velocity, heading, vert_spd) + retstr = "MSG,4,0,%i,%06X,%i,%s,%s,%s,%s,,,%.1f,%.1f,,,%i,,,,,\r\n" % (aircraft_id, icao24, aircraft_id+100, datestr, timestr, datestr, timestr, velocity, heading, vert_spd) return retstr From 8939a72e621bd8ae5823f1236c450ecc57c67247 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Fri, 14 Sep 2012 09:41:21 -0700 Subject: [PATCH 06/10] Preamble was sometimes consuming more samples than it was given, due to rounding issues and due to the early/late gate peak detector. --- lib/air_modes_preamble.cc | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/air_modes_preamble.cc b/lib/air_modes_preamble.cc index 33dd033..8eca29d 100644 --- a/lib/air_modes_preamble.cc +++ b/lib/air_modes_preamble.cc @@ -53,7 +53,7 @@ air_modes_preamble::air_modes_preamble(int channel_rate, float threshold_db) : str << name() << unique_id(); d_me = pmt::pmt_string_to_symbol(str.str()); d_key = pmt::pmt_string_to_symbol("preamble_found"); - set_history(d_check_width); + set_history(d_samples_per_symbol); } static void integrate_and_dump(float *out, const float *in, int chips, int samps_per_chip) { @@ -101,7 +101,13 @@ int air_modes_preamble::general_work(int noutput_items, { const float *in = (const float *) input_items[0]; const float *inavg = (const float *) input_items[1]; - const int ninputs = std::min(ninput_items[0], ninput_items[1]); //just in case + + int mininputs = std::min(ninput_items[0], ninput_items[1]); //they should be matched but let's be safe + //round number of input samples down to nearest d_samples_per_chip + //we also subtract off d_samples_per_chip to allow the bit center finder some leeway + const int ninputs = std::max(mininputs - (mininputs % d_samples_per_chip) - d_samples_per_chip, 0); + if (ninputs <= 0) { consume_each(0); return 0; } + float *out = (float *) output_items[0]; if(0) std::cout << "Preamble called with " << ninputs << " samples" << std::endl; @@ -132,15 +138,18 @@ int air_modes_preamble::general_work(int noutput_items, //get a more accurate bit center by finding the correlation peak across all four preamble bits bool late, early; + int how_late = 0; do { double now_corr = correlate_preamble(in+i, d_samples_per_chip); double late_corr = correlate_preamble(in+i+1, d_samples_per_chip); double early_corr = correlate_preamble(in+i-1, d_samples_per_chip); late = (late_corr > now_corr); //early = (early_corr > now_corr); - if(late) i++; + if(late) { i++; how_late++; } //if(early && i>0) { std::cout << "EARLY " << i << std::endl; i--; } - } while(late);// xor early); + } while(late and how_late < d_samples_per_chip);// xor early); + + if(0) std::cout << "We were " << how_late << " samples late" << std::endl; //now check to see that the non-peak symbols in the preamble //are below the peaks by threshold dB @@ -160,6 +169,7 @@ int air_modes_preamble::general_work(int noutput_items, //be sure we've got enough room in the input buffer to copy out a whole packet if(ninputs-i < 240*d_samples_per_chip) { consume_each(std::max(i-1,0)); + if(0) std::cout << "Preamble consumed " << std::max(i-1,0) << ", returned 0 (no room)" << std::endl; return 0; } @@ -190,7 +200,7 @@ int air_modes_preamble::general_work(int noutput_items, //std::cout << "PREAMBLE" << std::endl; //produce only one output per work call -- TODO this should probably change - if(0) std::cout << "Preamble consumed " << i+240*d_samples_per_chip << ", returned 240" << std::endl; + if(0) std::cout << "Preamble consumed " << i+240*d_samples_per_chip << "with i=" << i << ", returned 240" << std::endl; consume_each(i+240*d_samples_per_chip); return 240; } From 32da8704a9b3d1e2af4e31d99d57d342ec7fb452 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Mon, 17 Sep 2012 14:17:07 -0700 Subject: [PATCH 07/10] Fix bug in print on unknown FTC type. --- python/modes_print.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/modes_print.py b/python/modes_print.py index 837666c..4791911 100644 --- a/python/modes_print.py +++ b/python/modes_print.py @@ -177,7 +177,7 @@ class modes_output_print(modes_parse.modes_parse): retstr = "Type 17 BDS6,2 (emergency) from %x type %s" % (icao24, emerg_str) else: - retstr = "Type 17 subtype %i from %x not implemented" % (data["me"], icao24) + retstr = "Type 17 with FTC=%i from %x not implemented" % (data["ftc"], icao24) return retstr From f1a5c676b7840bd8ea03cfa0332d62390b6b8171 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Sun, 30 Sep 2012 11:47:50 -0700 Subject: [PATCH 08/10] Fixed erroneous include dir variable FindGnuradioCore was only working if GNU Radio was installed in typical paths, since the pkg-config variable was wrong. This was fixed in GNU Radio HOWTO a while back. --- cmake/Modules/FindGnuradioCore.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Modules/FindGnuradioCore.cmake b/cmake/Modules/FindGnuradioCore.cmake index 34e85db..87012ab 100644 --- a/cmake/Modules/FindGnuradioCore.cmake +++ b/cmake/Modules/FindGnuradioCore.cmake @@ -5,7 +5,7 @@ FIND_PATH( GNURADIO_CORE_INCLUDE_DIRS NAMES gr_random.h HINTS $ENV{GNURADIO_CORE_DIR}/include/gnuradio - ${PC_GNURADIO_CORE_INCLUDE_DIR} + ${PC_GNURADIO_CORE_INCLUDEDIR} PATHS /usr/local/include/gnuradio /usr/include/gnuradio ) From c0d24f12c96ca52dd38f08d42d6bdedf69474bba Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Sat, 6 Oct 2012 08:44:33 -0700 Subject: [PATCH 09/10] modes_kml: fix case where KML generation thread dies SQLite does not deal well with concurrency. Avoid database locked errors by synchronizing database access using a threading.Lock(). --- python/modes_kml.py | 8 ++++---- python/modes_sql.py | 23 +++++++++++++++-------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/python/modes_kml.py b/python/modes_kml.py index c324373..d3b1ba0 100644 --- a/python/modes_kml.py +++ b/python/modes_kml.py @@ -93,14 +93,14 @@ class modes_kml(threading.Thread, modes_output_sql): #read the database and add KML q = "select distinct icao from positions where seen > datetime('now', '-5 minute')" c = self._db.cursor() - c.execute(q) + self.locked_execute(c, q) icaolist = c.fetchall() #now we have a list icaolist of all ICAOs seen in the last 5 minutes for icao in icaolist: #print "ICAO: %x" % icao q = "select * from positions where icao=%i and seen > datetime('now', '-2 hour') ORDER BY seen DESC" % icao - c.execute(q) + self.locked_execute(c, q) track = c.fetchall() #print "Track length: %i" % len(track) if len(track) != 0: @@ -128,7 +128,7 @@ class modes_kml(threading.Thread, modes_output_sql): #now get metadata q = "select ident from ident where icao=%i" % icao - c.execute(q) + self.locked_execute(c, q) r = c.fetchall() if len(r) != 0: ident = r[0][0] @@ -136,7 +136,7 @@ class modes_kml(threading.Thread, modes_output_sql): #if ident is None: ident = "" #get most recent speed/heading/vertical q = "select seen, speed, heading, vertical from vectors where icao=%i order by seen desc limit 1" % icao - c.execute(q) + self.locked_execute(c, q) r = c.fetchall() if len(r) != 0: seen = r[0][0] diff --git a/python/modes_sql.py b/python/modes_sql.py index 54385d2..be2316f 100644 --- a/python/modes_sql.py +++ b/python/modes_sql.py @@ -19,7 +19,7 @@ # Boston, MA 02110-1301, USA. # -import time, os, sys +import time, os, sys, threading from string import split, join import modes_parse import sqlite3 @@ -28,6 +28,8 @@ from modes_exceptions import * class modes_output_sql(modes_parse.modes_parse): def __init__(self, mypos, filename): modes_parse.modes_parse.__init__(self, mypos) + + self._lock = threading.Lock() #create the database self.db = sqlite3.connect(filename) #now execute a schema to create the tables you need @@ -39,7 +41,7 @@ class modes_output_sql(modes_parse.modes_parse): "lat" REAL, "lon" REAL );""" - c.execute(query) + self.locked_execute(c, query) query = """CREATE TABLE IF NOT EXISTS "vectors" ( "icao" INTEGER KEY NOT NULL, "seen" TEXT NOT NULL, @@ -47,26 +49,31 @@ class modes_output_sql(modes_parse.modes_parse): "heading" REAL, "vertical" REAL );""" - c.execute(query) + self.locked_execute(c, query) query = """CREATE TABLE IF NOT EXISTS "ident" ( "icao" INTEGER PRIMARY KEY NOT NULL, "ident" TEXT NOT NULL );""" - c.execute(query) + self.locked_execute(c, query) c.close() self.db.commit() def __del__(self): self.db.close() + def locked_execute(self, c, query): + with self._lock: + c.execute(query) + def output(self, message): try: query = self.make_insert_query(message) if query is not None: - c = self.db.cursor() - c.execute(query) - c.close() - self.db.commit() + with self._lock: + c = self.db.cursor() + c.execute(query) + c.close() + self.db.commit() except ADSBError: pass From 20630ec6d1eac18ddcd09a074c1edf18c4e9f27f Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Sat, 6 Oct 2012 07:57:18 -0700 Subject: [PATCH 10/10] cmake: additional fixes from GNU Radio HOWTO * Fix include dir in FindGruel * Remove QUIET option that requires CMake 2.8.2, not yet on all distros --- cmake/Modules/FindGnuradioCore.cmake | 2 +- cmake/Modules/FindGruel.cmake | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/FindGnuradioCore.cmake b/cmake/Modules/FindGnuradioCore.cmake index 87012ab..3773588 100644 --- a/cmake/Modules/FindGnuradioCore.cmake +++ b/cmake/Modules/FindGnuradioCore.cmake @@ -1,5 +1,5 @@ INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(PC_GNURADIO_CORE gnuradio-core QUIET) +PKG_CHECK_MODULES(PC_GNURADIO_CORE gnuradio-core) FIND_PATH( GNURADIO_CORE_INCLUDE_DIRS diff --git a/cmake/Modules/FindGruel.cmake b/cmake/Modules/FindGruel.cmake index 190c2e3..c7a10a4 100644 --- a/cmake/Modules/FindGruel.cmake +++ b/cmake/Modules/FindGruel.cmake @@ -1,11 +1,11 @@ INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(PC_GRUEL gnuradio-core QUIET) +PKG_CHECK_MODULES(PC_GRUEL gnuradio-core) FIND_PATH( GRUEL_INCLUDE_DIRS NAMES gruel/attributes.h HINTS $ENV{GRUEL_DIR}/include - ${PC_GRUEL_INCLUDE_DIR} + ${PC_GRUEL_INCLUDEDIR} PATHS /usr/local/include /usr/include )