Clear memory in shm_td_iq_channel after RX

Clear memory in shm_td_iq_channel after RX. This prevents the IQ
from being read twice. This can happen if the application crashes
and will keep the other side reading historical IQ samples.
This commit is contained in:
Bartosz Podrygajlo
2026-01-12 11:50:39 +01:00
parent 699a5453a0
commit 407d175f5d
@@ -208,8 +208,11 @@ IQChannelErrorType shm_td_iq_channel_rx(ShmTDIQChannel *channel,
size_t num_samples_first_copy = CIRCULAR_BUFFER_SIZE - first_sample;
memcpy(tx_iq_data, base_ptr + first_sample, num_samples_first_copy * sizeof(sample_t));
memcpy(tx_iq_data + num_samples_first_copy, base_ptr, (num_samples - num_samples_first_copy) * sizeof(sample_t));
memset(base_ptr + first_sample, 0, num_samples_first_copy * sizeof(sample_t));
memset(base_ptr, 0, (num_samples - num_samples_first_copy) * sizeof(sample_t));
} else {
memcpy(tx_iq_data, base_ptr + first_sample, num_samples * sizeof(sample_t));
memset(base_ptr + first_sample, 0, num_samples * sizeof(sample_t));
}
return CHANNEL_NO_ERROR;
}