Thomas Kolb
c6ea578808
sdr_rf_to_baseband() processes samples in blocks of size SDR_OVERSAMPLING. If the total number of samples does not align with this block size, the leftover samples are lost and phase and timing glitches result. To mitigate this, sdr_receive() now has an additional parameter that specifies the alignment of the returned data. The number of samples returned is always a multiple of this alignment factor. This feature is used to ensure that the number of returned samples is a multiple of SDR_OVERSAMPLING and therefore no samples are lost in sdr_rf_to_baseband(). sdr_rf_to_baseband() now has an additional check that makes the function fail if the alignment is incorrect.
43 lines
1.2 KiB
C
43 lines
1.2 KiB
C
#ifndef RESULTS_H
|
|
#define RESULTS_H
|
|
|
|
typedef enum {
|
|
OK,
|
|
ERR_INVALID_STATE,
|
|
ERR_INVALID_PARAM, // invalid / nonsense parameters given
|
|
ERR_NO_MEM, // not enough memory or allocation error
|
|
ERR_SIZE, // a given size is invalid
|
|
ERR_LIQUID, // an error occurred in the LiquidDSP library.
|
|
ERR_SYSCALL, // a syscall failed. Use errno to determine the cause.
|
|
ERR_SOAPY, // an error occurred in the SoapySDR library.
|
|
ERR_SDR, // an error occurred in the SDR interface.
|
|
} result_t;
|
|
|
|
#ifdef DEBUG_LIQUID
|
|
#include <stdio.h>
|
|
|
|
#include <liquid/liquid.h>
|
|
|
|
#define ERR_CHECK_LIQUID(call) \
|
|
do { \
|
|
liquid_error_code lq_result; \
|
|
if((lq_result = (call)) != LIQUID_OK) { \
|
|
fprintf(stderr, "Liquid call failed in %s:%d: %s\n", __FILE__, __LINE__, liquid_error_info(lq_result)); \
|
|
return ERR_LIQUID; \
|
|
} \
|
|
} while(0);
|
|
#else
|
|
# define ERR_CHECK_LIQUID(call) if((call) != LIQUID_OK) { return ERR_LIQUID; }
|
|
#endif
|
|
|
|
#define ERR_CHECK(call) \
|
|
do { \
|
|
result_t err_check_result = call; \
|
|
if(err_check_result != OK) { \
|
|
fprintf(stderr, "Error detected at %s:%d: %d\n", __FILE__, __LINE__, err_check_result); \
|
|
return err_check_result; \
|
|
} \
|
|
} while(0);
|
|
|
|
#endif // RESULTS_H
|