BUGFIX : Missed data causes timestamp slip
The Mutex on the RTL data reader thread does not "force" the data processing thread to execute. Therefore, if the processor is busy, it is possible for a second RTL callback to occur before the data from the first has been processed. This will cause the loss of the first data, but worse, it will cause a slip in the timestamp. This upsets Beamfinder and MLAT operation in PlanePlotter. To solve this, keep a Fifo buffer which is filled by the callback thread, and emptied by the data processing thread. The fifo is the same size as the number of buffers requested in the call to rtlsdr_read_async(). Note - we only put the value of the pointer supplied in the callback into the fifo. We do not attempt to cache the data in the buffer pointed to by the pointer. This would require us to memcopy() 2Mbytes per second, which we don't want to do if we don't have to because it will only make the processor loading worse. Instead, we assume that the data in the buffer will remain valid after the callback returns, at least until it is overwritten by new data. It is still possible for us to lose data if we can't process it quickly enough. However, we can now detect this loss of data when the fifo is almost full, and correct the timestamp for the lost block/blocks.
This commit is contained in:
parent
24080a22b1
commit
75a4c6ee21
4 changed files with 108 additions and 48 deletions
3
mode_s.c
3
mode_s.c
|
@ -1372,9 +1372,8 @@ void displayModesMessage(struct modesMessage *mm) {
|
|||
// Turn I/Q samples pointed by Modes.data into the magnitude vector
|
||||
// pointed by Modes.magnitude.
|
||||
//
|
||||
void computeMagnitudeVector(void) {
|
||||
void computeMagnitudeVector(uint16_t *p) {
|
||||
uint16_t *m = &Modes.magnitude[MODES_PREAMBLE_SAMPLES+MODES_LONG_MSG_SAMPLES];
|
||||
uint16_t *p = Modes.data;
|
||||
uint32_t j;
|
||||
|
||||
memcpy(Modes.magnitude,&Modes.magnitude[MODES_ASYNC_BUF_SAMPLES], MODES_PREAMBLE_SIZE+MODES_LONG_MSG_SIZE);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue