2022-02-27 16:02:51 +01:00
|
|
|
#ifndef RESULTS_H
|
|
|
|
#define RESULTS_H
|
2021-10-17 19:26:38 +02:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
OK,
|
|
|
|
ERR_INVALID_STATE,
|
2024-04-27 20:08:04 +02:00
|
|
|
ERR_INVALID_PARAM, // invalid / nonsense parameters given
|
|
|
|
ERR_NO_MEM, // not enough memory or allocation error
|
|
|
|
ERR_SIZE, // a given size is invalid
|
2022-03-03 22:18:19 +01:00
|
|
|
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.
|
2024-01-02 22:49:16 +01:00
|
|
|
ERR_SDR, // an error occurred in the SDR interface.
|
2021-10-17 19:26:38 +02:00
|
|
|
} result_t;
|
|
|
|
|
|
|
|
#ifdef DEBUG_LIQUID
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2023-05-17 22:28:18 +02:00
|
|
|
#include <liquid/liquid.h>
|
|
|
|
|
|
|
|
#define ERR_CHECK_LIQUID(call) \
|
2021-10-17 19:26:38 +02:00
|
|
|
do { \
|
2022-02-27 20:21:14 +01:00
|
|
|
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)); \
|
2021-10-17 19:26:38 +02:00
|
|
|
return ERR_LIQUID; \
|
|
|
|
} \
|
|
|
|
} while(0);
|
|
|
|
#else
|
|
|
|
# define ERR_CHECK_LIQUID(call) if((call) != LIQUID_OK) { return ERR_LIQUID; }
|
|
|
|
#endif
|
|
|
|
|
2022-02-27 20:21:14 +01:00
|
|
|
#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);
|
|
|
|
|
2022-02-27 16:02:51 +01:00
|
|
|
#endif // RESULTS_H
|