rx: reset internal state when restarting after a transmission
This commit is contained in:
parent
d5aeb6c0bc
commit
91facbf699
|
@ -76,6 +76,15 @@ void correlator_free(correlator_ctx_t *ctx)
|
||||||
ctx->search_sequence_len = 0;
|
ctx->search_sequence_len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void correlator_reset(correlator_ctx_t *ctx)
|
||||||
|
{
|
||||||
|
// Clear the history buffer
|
||||||
|
memset(ctx->input_history, 0, ctx->buffer_size * sizeof(ctx->input_history[0]));
|
||||||
|
|
||||||
|
// start writing from the beginning
|
||||||
|
ctx->history_ptr = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
float complex correlator_step(correlator_ctx_t *ctx, float complex sample)
|
float complex correlator_step(correlator_ctx_t *ctx, float complex sample)
|
||||||
{
|
{
|
||||||
|
|
|
@ -67,6 +67,16 @@ bool correlator_init(correlator_ctx_t *ctx, const float complex *search_seq, siz
|
||||||
*/
|
*/
|
||||||
void correlator_free(correlator_ctx_t *ctx);
|
void correlator_free(correlator_ctx_t *ctx);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Reset a correlator.
|
||||||
|
*
|
||||||
|
* \details
|
||||||
|
* Erases all data in the history buffer and starts writing from the beginning.
|
||||||
|
*
|
||||||
|
* \param ctx The correlator context to reset.
|
||||||
|
*/
|
||||||
|
void correlator_reset(correlator_ctx_t *ctx);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Process one sample in the correlator.
|
* \brief Process one sample in the correlator.
|
||||||
*
|
*
|
||||||
|
|
|
@ -600,6 +600,24 @@ result_t layer1_rx_shutdown(layer1_rx_t *rx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
result_t layer1_rx_reset(layer1_rx_t *rx)
|
||||||
|
{
|
||||||
|
// reset the state machine
|
||||||
|
rx->state = RX_STATE_ACQUISITION;
|
||||||
|
|
||||||
|
// reset the correlator (to avoid spurious preamble detection)
|
||||||
|
correlator_reset(&rx->preamble_correlator);
|
||||||
|
|
||||||
|
// reset symbol synchronizer
|
||||||
|
symsync_crcf_reset(rx->symsync);
|
||||||
|
|
||||||
|
// drop partial debug info
|
||||||
|
reset_packet_debug_info(rx);
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool layer1_rx_is_busy(const layer1_rx_t *rx)
|
bool layer1_rx_is_busy(const layer1_rx_t *rx)
|
||||||
{
|
{
|
||||||
return is_squelch_open(rx);
|
return is_squelch_open(rx);
|
||||||
|
|
|
@ -114,7 +114,7 @@ result_t layer1_rx_shutdown(layer1_rx_t *rx);
|
||||||
* \param rx Pointer to the receiver context.
|
* \param rx Pointer to the receiver context.
|
||||||
* \param samples Pointer to the samples to process.
|
* \param samples Pointer to the samples to process.
|
||||||
* \param sample_count Number of samples to process.
|
* \param sample_count Number of samples to process.
|
||||||
* \returns The result of the shutdown.
|
* \returns The result of the sample processing.
|
||||||
*/
|
*/
|
||||||
result_t layer1_rx_process(layer1_rx_t *rx, const float complex *samples, size_t sample_count);
|
result_t layer1_rx_process(layer1_rx_t *rx, const float complex *samples, size_t sample_count);
|
||||||
|
|
||||||
|
@ -142,4 +142,20 @@ bool layer1_rx_is_busy(const layer1_rx_t *rx);
|
||||||
*/
|
*/
|
||||||
float layer1_rx_get_coarse_carrier_frequency(const layer1_rx_t *rx);
|
float layer1_rx_get_coarse_carrier_frequency(const layer1_rx_t *rx);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Reset the receiver.
|
||||||
|
*
|
||||||
|
* This ensures that the receiver can lock on to newly received packets in a
|
||||||
|
* defined way. The following submodules are reset:
|
||||||
|
*
|
||||||
|
* - Correlator
|
||||||
|
* - RX state machine
|
||||||
|
* - Symbol synchronization
|
||||||
|
*
|
||||||
|
* \param rx Pointer to the receiver context.
|
||||||
|
* \returns The result of the reset.
|
||||||
|
*/
|
||||||
|
result_t layer1_rx_reset(layer1_rx_t *rx);
|
||||||
|
|
||||||
#endif // LAYER1_RX_H
|
#endif // LAYER1_RX_H
|
||||||
|
|
|
@ -317,6 +317,7 @@ int main(int argc, char **argv)
|
||||||
} else if(on_air) { // ret == 0
|
} else if(on_air) { // ret == 0
|
||||||
fprintf(stderr, "TX -> RX\n");
|
fprintf(stderr, "TX -> RX\n");
|
||||||
RESULT_CHECK(sdr_flush_tx_buffer(&sdr));
|
RESULT_CHECK(sdr_flush_tx_buffer(&sdr));
|
||||||
|
RESULT_CHECK(layer1_rx_reset(&rx));
|
||||||
|
|
||||||
RESULT_CHECK(sdr_stop_tx(&sdr));
|
RESULT_CHECK(sdr_stop_tx(&sdr));
|
||||||
RESULT_CHECK(sdr_start_rx(&sdr));
|
RESULT_CHECK(sdr_start_rx(&sdr));
|
||||||
|
|
Loading…
Reference in a new issue