diff --git a/src/DataVampire.cpp b/src/DataVampire.cpp index b06b77dd42a2181e9c1125719ef0006b746db051..67b0576d6757eac11d39f4729c8e4c981fe45937 100644 --- a/src/DataVampire.cpp +++ b/src/DataVampire.cpp @@ -2907,6 +2907,8 @@ int32_t DataVampire::get_start_index(int32_t mode, int32_t num_samples, int32_t { int32_t last_idx, start = -1, end = -1; bool bn_found = false; + int32_t bn_samples = 0; + // last valid sample index stored in circular buffer last_idx = (array_idx - 1 + DATAVAMPIRE_MAX_SIZE) % DATAVAMPIRE_MAX_SIZE; @@ -2925,10 +2927,20 @@ int32_t DataVampire::get_start_index(int32_t mode, int32_t num_samples, int32_t if (acq_array[idx].bn == bn_start) { start = idx; } + if (end != -1) { + //printf("INCREMENT bn_samples=%d\n",bn_samples); + bn_samples++; + } if ((end != -1) && (start != -1)) { bn_found = true; break; } } + if ((bn_end - bn_start + 1) != bn_samples) { + Tango::Except::throw_exception( + (const char *) "Failed to find buffer indexes", + (const char *) "Data missing", + __FUNCTION__, Tango::ERR); + } if (bn_found) { return start;