From 885250fb42136a91738c033158a7879c23a0b025 Mon Sep 17 00:00:00 2001 From: Brandon Smith Date: Wed, 18 Jan 2023 15:06:38 -0500 Subject: [PATCH 1/3] 3.0.0.7 - Added check of timestamp difference. Not tested, no HDW availible --- gr-CyberRadio/CMakeLists.txt | 2 +- gr-CyberRadio/lib/vita_udp_rx_impl.cc | 34 ++++++++++++++++++++++----- gr-CyberRadio/lib/vita_udp_rx_impl.h | 1 + 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/gr-CyberRadio/CMakeLists.txt b/gr-CyberRadio/CMakeLists.txt index 29a5034..2229207 100644 --- a/gr-CyberRadio/CMakeLists.txt +++ b/gr-CyberRadio/CMakeLists.txt @@ -33,7 +33,7 @@ list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/Modules) set(VERSION_MAJOR 3) set(VERSION_API 0) set(VERSION_ABI 0) -set(VERSION_PATCH 6) +set(VERSION_PATCH 7) cmake_policy(SET CMP0011 NEW) diff --git a/gr-CyberRadio/lib/vita_udp_rx_impl.cc b/gr-CyberRadio/lib/vita_udp_rx_impl.cc index 438fb53..59899d0 100644 --- a/gr-CyberRadio/lib/vita_udp_rx_impl.cc +++ b/gr-CyberRadio/lib/vita_udp_rx_impl.cc @@ -94,6 +94,11 @@ std::map ndr358_551_ddc_map = { { 40, 128e6 } }; +std::map ndr358_551_timestamp_diffs = { + {40, 2000} , {39, 4000} , {38, 8000} , {37, 8000} , {36, 16000}, + {35, 16000}, {34, 16000}, {33, 32000}, {32, 32000} +}; + void raise_error(std::string tag, int sock) { // see http://www.club.cc.cmu.edu/~cmccabe/blog_strerror.html for problems with @@ -176,6 +181,7 @@ namespace gr { d_first_packet(true), d_packetCounter(0), d_buffer(), + d_frac_last_timestamp( 0 ), d_use_vector_output( vector_output ) { if( this->d_use_vector_output ) @@ -390,12 +396,20 @@ namespace gr { *******************************************************************************/ auto vita_udp_rx_impl::tag_packet(int stream, int offset) -> void { + uint32_t __ddc_filter = 0; if (d_tag_packets) { auto hdr = reinterpret_cast(d_buffer.data()); uint64_t tag_item = nitems_written(0) + offset; // Note if we setup byte swap, it's already been done in place + { + // Moved so I have the information for DDC Rate + auto ddc_filter = ((hdr->ddc_2 >> 20) & 0x0FFF); + auto tag = pmt::from_float(ndr358_551_ddc_map.at(ddc_filter)); + add_item_tag(stream, tag_item, pmt::mp("ddc_rate"), tag); + __ddc_filter = ddc_filter; + } // timestamp { @@ -405,6 +419,20 @@ namespace gr { auto tag = pmt::cons(pmt::from_long(hdr->int_timestamp), pmt::from_uint64(fractionalTs)); add_item_tag(stream, tag_item, pmt::mp("timestamp"), tag); + + if( d_first_packet ) + { + d_frac_last_timestamp = fractionalTs; + } else { + uint32_t expected_diff = ndr358_551_timestamp_diffs.at(__ddc_filter); + if ( (fractionalTs - d_frac_last_timestamp) != expected_diff ) + { + txStatusMsg(); + std::cout + << "gr::CyberRadio::vita_udp_rx_impl: packet loss detected: expected " + << expected_diff << ", received " << (fractionalTs - d_frac_last_timestamp) << std::endl; + } + } } // stream id @@ -431,12 +459,6 @@ namespace gr { } } - { - auto ddc_filter = ((hdr->ddc_2 >> 20) & 0x0FFF); - auto tag = pmt::from_float(ndr358_551_ddc_map.at(ddc_filter)); - add_item_tag(stream, tag_item, pmt::mp("ddc_rate"), tag); - } - { auto tag = pmt::from_long((hdr->ddc_2 >> 0) & 0x0001FFFF); add_item_tag(stream, tag_item, pmt::mp("delay_time"), tag); diff --git a/gr-CyberRadio/lib/vita_udp_rx_impl.h b/gr-CyberRadio/lib/vita_udp_rx_impl.h index 14de2e4..7b19bd6 100644 --- a/gr-CyberRadio/lib/vita_udp_rx_impl.h +++ b/gr-CyberRadio/lib/vita_udp_rx_impl.h @@ -49,6 +49,7 @@ namespace gr { bool d_first_packet; unsigned d_packetCounter : 4; bool d_use_vector_output; + uint64_t d_frac_last_timestamp; std::vector d_buffer; protected: From 93eb20bf6eb0aa651393988831c45b6ea1cced65 Mon Sep 17 00:00:00 2001 From: Brandon Smith Date: Fri, 20 Jan 2023 09:46:18 -0500 Subject: [PATCH 2/3] 3.0.0.8 - Fixed timestamp check settings and wraparound on 1 second --- gr-CyberRadio/CMakeLists.txt | 2 +- gr-CyberRadio/lib/vita_udp_rx_impl.cc | 24 ++++++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/gr-CyberRadio/CMakeLists.txt b/gr-CyberRadio/CMakeLists.txt index 2229207..31b55e4 100644 --- a/gr-CyberRadio/CMakeLists.txt +++ b/gr-CyberRadio/CMakeLists.txt @@ -33,7 +33,7 @@ list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/Modules) set(VERSION_MAJOR 3) set(VERSION_API 0) set(VERSION_ABI 0) -set(VERSION_PATCH 7) +set(VERSION_PATCH 8) cmake_policy(SET CMP0011 NEW) diff --git a/gr-CyberRadio/lib/vita_udp_rx_impl.cc b/gr-CyberRadio/lib/vita_udp_rx_impl.cc index 59899d0..f53ae7b 100644 --- a/gr-CyberRadio/lib/vita_udp_rx_impl.cc +++ b/gr-CyberRadio/lib/vita_udp_rx_impl.cc @@ -95,8 +95,8 @@ std::map ndr358_551_ddc_map = { }; std::map ndr358_551_timestamp_diffs = { - {40, 2000} , {39, 4000} , {38, 8000} , {37, 8000} , {36, 16000}, - {35, 16000}, {34, 16000}, {33, 32000}, {32, 32000} + {40, 2048} , {39, 4096} , {38, 8192} , {37, 8192} , {36, 16384}, + {35, 16384}, {34, 16384}, {33, 32768}, {32, 32768} }; void raise_error(std::string tag, int sock) @@ -425,13 +425,25 @@ namespace gr { d_frac_last_timestamp = fractionalTs; } else { uint32_t expected_diff = ndr358_551_timestamp_diffs.at(__ddc_filter); - if ( (fractionalTs - d_frac_last_timestamp) != expected_diff ) + // wrapping at 1second. + uint32_t diff = 0; + if ( fractionalTs < d_frac_last_timestamp ) + { + //d_logger->warn("frac = {}", fractionalTs); + // diff = (max - last) + current + //d_logger->warn("({} - {}) + {}", 256000000ull,d_frac_last_timestamp,fractionalTs); + diff = (256000000ull - d_frac_last_timestamp) + fractionalTs; + } + else { + diff = fractionalTs - d_frac_last_timestamp; + } + if ( diff != expected_diff ) { txStatusMsg(); - std::cout - << "gr::CyberRadio::vita_udp_rx_impl: packet loss detected: expected " - << expected_diff << ", received " << (fractionalTs - d_frac_last_timestamp) << std::endl; + d_logger->warn("gr::CyberRadio::vita_udp_rx_impl: packet loss detected: expected {}, recieved {}", + expected_diff, diff); } + d_frac_last_timestamp = fractionalTs; } } From ecab6d31ddee2b502a4d0745fe322cef3d976f7b Mon Sep 17 00:00:00 2001 From: Brandon Smith Date: Thu, 26 Jan 2023 07:32:03 -0500 Subject: [PATCH 3/3] Will publish the message "valid data count < d_samples_per_packet" if we detect a packet that is under the d_sample_per_packet set in the block --- gr-CyberRadio/lib/vita_udp_rx_impl.cc | 41 +++++++++++++-------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/gr-CyberRadio/lib/vita_udp_rx_impl.cc b/gr-CyberRadio/lib/vita_udp_rx_impl.cc index f53ae7b..8afd8e3 100644 --- a/gr-CyberRadio/lib/vita_udp_rx_impl.cc +++ b/gr-CyberRadio/lib/vita_udp_rx_impl.cc @@ -404,7 +404,7 @@ namespace gr { // Note if we setup byte swap, it's already been done in place { - // Moved so I have the information for DDC Rate + // Moved so I have the information for DDC Rate auto ddc_filter = ((hdr->ddc_2 >> 20) & 0x0FFF); auto tag = pmt::from_float(ndr358_551_ddc_map.at(ddc_filter)); add_item_tag(stream, tag_item, pmt::mp("ddc_rate"), tag); @@ -425,25 +425,20 @@ namespace gr { d_frac_last_timestamp = fractionalTs; } else { uint32_t expected_diff = ndr358_551_timestamp_diffs.at(__ddc_filter); - // wrapping at 1second. - uint32_t diff = 0; - if ( fractionalTs < d_frac_last_timestamp ) - { - //d_logger->warn("frac = {}", fractionalTs); - // diff = (max - last) + current - //d_logger->warn("({} - {}) + {}", 256000000ull,d_frac_last_timestamp,fractionalTs); - diff = (256000000ull - d_frac_last_timestamp) + fractionalTs; - } - else { - diff = fractionalTs - d_frac_last_timestamp; - } - if ( diff != expected_diff ) - { + // wrapping at 1second. + uint32_t diff = 0; + if ( fractionalTs < d_frac_last_timestamp ) { + diff = (256000000ull - d_frac_last_timestamp) + fractionalTs; + } + else { + diff = fractionalTs - d_frac_last_timestamp; + } + if ( diff != expected_diff ) { txStatusMsg(); - d_logger->warn("gr::CyberRadio::vita_udp_rx_impl: packet loss detected: expected {}, recieved {}", - expected_diff, diff); + d_logger->warn("gr::CyberRadio::vita_udp_rx_impl: packet loss detected: expected {}, recieved {}", + expected_diff, diff); } - d_frac_last_timestamp = fractionalTs; + d_frac_last_timestamp = fractionalTs; } } @@ -514,8 +509,13 @@ namespace gr { } { - auto tag = pmt::from_long(((hdr->ddc_4 >> 0) & 0x000007FF)); + uint16_t valid_data_samples = ((hdr->ddc_4 >> 0) & 0x000007FF); + auto tag = pmt::from_long(valid_data_samples); add_item_tag(stream, tag_item, pmt::mp("valid_data_count"), tag); + if( d_samples_per_packet != valid_data_samples ) { + auto msg = pmt::cons(pmt::mp("valid data count < d_samples_per_packet"), pmt::PMT_NIL); + message_port_pub(status_port, msg); + } } { @@ -560,8 +560,7 @@ namespace gr { *******************************************************************************/ void vita_udp_rx_impl::rxControlMsg(pmt::pmt_t msg) { - std::cout << "**** vita_udp_rx_impl::rxControlMsg: " << msg << " ****" - << std::endl; + d_logger->debug("vita_udp_rx_impl::rxControlMsg \"{}\"", pmt::symbol_to_string(msg)); // What did we receive? pmt::pmt_t msgId = pmt::car(msg); pmt::pmt_t content = pmt::cdr(msg);