Commit fd755758 authored by Manolis Surligas's avatar Manolis Surligas

Merge branch 'LongHairedHacker/gr-satnogs-noaa-apt-sink'

parents 8dedb9b1 abc385ae
......@@ -48,7 +48,7 @@ list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/Modules)
# Set the version information here
set(VERSION_INFO_MAJOR_VERSION 1)
set(VERSION_INFO_API_COMPAT 2)
set(VERSION_INFO_MINOR_VERSION 1)
set(VERSION_INFO_MINOR_VERSION 2)
set(VERSION_INFO_MAINT_VERSION git)
########################################################################
......@@ -130,11 +130,12 @@ find_package(Doxygen)
find_package(Volk REQUIRED)
find_package(OggVorbis REQUIRED)
find_package(PNG REQUIRED)
find_package(png++ REQUIRED)
########################################################################
# Include or not into the module blocks for debugging
########################################################################
option(INCLUDE_DEBUG_BLOCKS
option(INCLUDE_DEBUG_BLOCKS
"Enable/Disable blocks that are used for debugging purposes" ON)
......
......@@ -9,9 +9,10 @@ for decoding signals from various scientific and academic sattelites.
* CMake ( > 3.1)
* G++ (with C++11 support)
* VOLK
* libogg
* libogg
* libvorbis
* libpng
* libpng++
* git
**Optional**
......@@ -34,12 +35,12 @@ If this is the first time you are building the gr-satnogs module run
By default, the **SatNOGS** module will use the default installation prefix.
This highly depends on the Linux distribution. You can use the `CMAKE_INSTALL_PREFIX`
variable to alter the default installation path.
E.g:
E.g:
`cmake -DCMAKE_INSTALL_PREFIX=/usr ..`
Also, by default the build system enables a set of blocks used for debugging
during the development. The enable/disable switch is controled through the
during the development. The enable/disable switch is controled through the
`INCLUDE_DEBUG_BLOCKS` boolean variable. If for example, you want to disable the
debugging blocks, the **CMake** command would be:
......@@ -62,6 +63,6 @@ For more indormation about SatNOGS please visit our [site](https://satnogs.org/)
## License
© 2016,2017 [Libre Space Foundation](http://librespacefoundation.org).
© 2016,2017,2018 [Libre Space Foundation](http://librespacefoundation.org).
Licensed under the [GPLv3](LICENSE).
\ No newline at end of file
Licensed under the [GPLv3](LICENSE).
# - Try to find png++
#
# The following variables are optionally searched for defaults
# png++_ROOT_DIR: Base directory where all GLOG components are found
#
# The following are set after configuration is done:
# png++_FOUND
# png++_INCLUDE_DIRS
# png++_LIBRARIES
find_package(PNG REQUIRED)
include(FindPackageHandleStandardArgs)
set(png++_ROOT_DIR "" CACHE PATH "Folder contains png++")
find_path(png++_INCLUDE_DIR
NAMES
png++/color.hpp
png++/config.hpp
png++/consumer.hpp
png++/convert_color_space.hpp
png++/end_info.hpp
png++/error.hpp
png++/ga_pixel.hpp
png++/generator.hpp
png++/gray_pixel.hpp
png++/image.hpp
png++/image_info.hpp
png++/index_pixel.hpp
png++/info.hpp
png++/info_base.hpp
png++/io_base.hpp
png++/packed_pixel.hpp
png++/palette.hpp
png++/pixel_buffer.hpp
png++/pixel_traits.hpp
png++/png.hpp
png++/reader.hpp
png++/require_color_space.hpp
png++/rgb_pixel.hpp
png++/rgba_pixel.hpp
png++/streaming_base.hpp
png++/tRNS.hpp
png++/types.hpp
png++/writer.hpp
PATHS
${png++_ROOT_DIR}
PATH_SUFFIXES
src)
set(png++_INCLUDE_DIRS ${png++_INCLUDE_DIR} ${PNG_INCLUDE_DIRS})
set(png++_LIBRARIES ${PNG_LIBRARIES})
find_package_handle_standard_args(png++ DEFAULT_MSG
png++_INCLUDE_DIR)
if(png++_FOUND)
set(png++_INCLUDE_DIRS ${png++_INCLUDE_DIR})
set(png++_LIBRARIES ${png++_LIBRARY})
endif()
\ No newline at end of file
......@@ -28,6 +28,7 @@ include_directories(
${VORBIS_INCLUDE_DIR}
${OGG_INCLUDE_DIR}
${PNG_INCLUDE_DIR}
${png++_INCLUDE_DIRS}
)
link_directories(${Boost_LIBRARY_DIRS})
......@@ -36,14 +37,14 @@ list(APPEND satnogs_debug_sources
morse_debug_source_impl.cc
debug_msg_source_impl.cc
debug_msg_source_raw_impl.cc
leo_channel_impl.cc
leo_channel_impl.cc
cw_encoder_impl.cc
)
list(APPEND satnogs_sources
morse_tree.cc
morse_decoder_impl.cc
multi_format_msg_sink_impl.cc
ogg_encoder_impl.cc
ogg_encoder_impl.cc
cw_to_symbol_impl.cc
sine_matched_filter_ff_impl.cc
udp_msg_source_impl.cc
......@@ -77,16 +78,17 @@ if(NOT satnogs_sources)
endif(NOT satnogs_sources)
add_library(gnuradio-satnogs SHARED ${satnogs_sources})
target_link_libraries(gnuradio-satnogs
${Boost_LIBRARIES}
target_link_libraries(gnuradio-satnogs
${Boost_LIBRARIES}
${GNURADIO_ALL_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${NOVA_LIBRARIES}
${VOLK_LIBRARIES}
${OGGVORBIS_LIBRARIES}
${PNG_LIBRARIES}
${png++_LIBRARIES}
)
set_target_properties(gnuradio-satnogs PROPERTIES DEFINE_SYMBOL "gnuradio_satnogs_EXPORTS")
if(APPLE)
......
This diff is collapsed.
......@@ -2,7 +2,7 @@
/*
* gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module
*
* Copyright (C) 2017, Libre Space Foundation <http://librespacefoundation.org/>
* Copyright (C) 2017,2018 Libre Space Foundation <http://librespacefoundation.org/>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -23,63 +23,103 @@
#include <satnogs/noaa_apt_sink.h>
#define PNG_DEBUG 3
#include <png.h>
#include <png++/png.hpp>
#include <chrono>
namespace gr
{
namespace satnogs
{
enum class noaa_apt_sync_marker {SYNC_A, SYNC_B, NONE};
class noaa_apt_sink_impl : public noaa_apt_sink
{
private:
uint32_t d_sync_word;
uint32_t d_constructed_word;
float d_slicer_threshold;
bool d_sync_found;
float d_max_value;
float d_min_value;
size_t d_norm_window;
size_t d_sample_counter;
const char* d_filename_png;
// Factor exponential smoothing average,
// which is used for sync pattern detection
const float f_average_alpha;
// The images are written to disk every d_row_write_threshold lines
// so in case something goes horribly wrong, partial images will be available
const size_t d_row_write_threshold;
static const bool synca_seq[];
static const bool syncb_seq[];
std::string d_filename_png;
size_t d_width;
size_t d_height;
bool d_split;
size_t d_history_length;
bool d_synchronize_opt;
png_structp* d_png_ptr;
png_infop* d_info_ptr;
uint8_t* d_row_buffer;
png_byte d_color_type;
png_byte d_bit_depth;
FILE** d_png_fd;
size_t d_images_per_frame;
size_t d_row_counter;
size_t d_num_images;
size_t d_current_buffered_samples;
std::vector<std::string> d_png_fn;
bool d_flip;
size_t d_history_length;
bool d_has_sync;
png::image<png::gray_pixel> d_full_image;
png::image<png::gray_pixel> d_left_image;
png::image<png::gray_pixel> d_right_image;
std::string d_full_filename;
std::string d_left_filename;
std::string d_right_filename;
size_t d_current_x;
size_t d_current_y;
size_t d_num_images;
float f_max_level;
float f_min_level;
float f_average;
public:
noaa_apt_sink_impl (const char *filename_png, size_t width, size_t height,
bool split, bool sync, bool flip);
~noaa_apt_sink_impl ();
void
write_png_row ();
void
init_png ();
void
flip_image ();
// Where all the action really happens
int
work (int noutput_items, gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
// For teardown actions, like writing the remaining images to disk
bool
stop ();
private:
// Generates new empty images and the filenames for them
void
init_images ();
/*
* Checks if the history portion of the input contains a sync marker.
* Matches the 40 samples before pos against the patterns.
*/
noaa_apt_sync_marker
is_marker (size_t pos, const float *samples);
// Sets the pixel indicated by coordinates in the images (both full and split)
void
set_pixel (size_t x, size_t y, float sample);
/*
* Updates d_current_x to new_x,
* while using historical samples to fill any resulting gaps in the images.
*/
void
skip_to (size_t new_x, size_t pos, const float *samples);
// Writes all images to disk
void
write_images ();
// Writes a single image to disk, also takes care of flipping
void
write_image (png::image<png::gray_pixel> image, std::string filename);
};
} // namespace satnogs
} // namespace gr
#endif /* INCLUDED_SATNOGS_NOAA_APT_SINK_IMPL_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment