Skip to content

Commit

Permalink
3.0.0.7 - Added check of timestamp difference. Not tested, no HDW ava…
Browse files Browse the repository at this point in the history
…ilible
  • Loading branch information
Brandon Smith committed Jan 18, 2023
1 parent 70c39b8 commit 885250f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gr-CyberRadio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
34 changes: 28 additions & 6 deletions gr-CyberRadio/lib/vita_udp_rx_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ std::map<int, float> ndr358_551_ddc_map = {
{ 40, 128e6 }
};

std::map<int, int> 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
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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<V49_0_Header*>(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
{
Expand All @@ -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
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions gr-CyberRadio/lib/vita_udp_rx_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t> d_buffer;
protected:
Expand Down

0 comments on commit 885250f

Please sign in to comment.