Use fsleep instead of nanosleep

This commit is contained in:
Thomas Kolb 2024-01-03 17:29:51 +01:00
parent fb9c26ccd5
commit 8689ed5b27
2 changed files with 6 additions and 8 deletions

View file

@ -301,8 +301,7 @@ int main(void)
}
if(n_rf_samples == 0) {
struct timespec ts_1ms = {0, 1000000};
nanosleep(&ts_1ms, NULL);
fsleep(1e-3);
continue;
}

View file

@ -6,10 +6,10 @@
#include <complex.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <assert.h>
#include "config.h"
#include "utils.h"
#include "sdr.h"
@ -141,10 +141,9 @@ static result_t stop_streaming(sdr_ctx_t *ctx)
return OK;
}
struct timespec ts_1ms = {0, 1000000};
while(hackrf_is_streaming(ctx->hackrf) == HACKRF_TRUE) {
puts("wr");
nanosleep(&ts_1ms, NULL);
fsleep(1e-3);
}
ctx->status = SDR_STATUS_IDLE;
@ -342,9 +341,9 @@ result_t sdr_receive(sdr_ctx_t *ctx, float complex *samples, size_t *nsamples, l
result_t sdr_flush_tx_buffer(sdr_ctx_t *ctx)
{
while(!ctx->tx_done) {
struct timespec ts_1ms = {0, 1000000};
nanosleep(&ts_1ms, NULL);
// block until all samples have been transmitted
while(!ctx->tx_done || (get_hires_time() < (ctx->tx_start_time + ctx->tx_duration))) {
fsleep(1e-3);
}
return OK;