From eed9504ecd543540e326795210bab7575c578d19 Mon Sep 17 00:00:00 2001 From: Alvaro Date: Fri, 16 Apr 2021 08:48:25 +0100 Subject: [PATCH] #72: fix issues with spectfd, extend local API --- esp32/main/spectfd.c | 40 +++++++++++++++++++++++++++++++++++++--- esp32/main/spectfd.h | 4 +++- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/esp32/main/spectfd.c b/esp32/main/spectfd.c index fae60d6a..1f8dac3b 100644 --- a/esp32/main/spectfd.c +++ b/esp32/main/spectfd.c @@ -1,8 +1,10 @@ #include "spectfd.h" #include #include +#include #define MAX_SPECT_FD 16 +#define SPECTFD_RESERVED (0) static int spectfd_map[MAX_SPECT_FD]; @@ -11,11 +13,21 @@ void spectfd__init(void) memset(spectfd_map, 0xFF, sizeof(spectfd_map)); } +static bool spectfd__is_valid_system(int index) +{ + return (spectfd_map[index]>SPECTFD_RESERVED); +} + +static bool spectfd__is_valid_system_or_reserved(int index) +{ + return (spectfd_map[index]>SPECTFD_RESERVED); +} + void spectfd__close_all(void) { unsigned i; for (i=0;i - /** * \defgrou Spectrum file descriptors * \ingroup misc @@ -16,5 +15,8 @@ void spectfd__init(void); void spectfd__close_all(void); int spectfd__spect_to_system(spectfd_t fd); spectfd_t spectfd__alloc(int systemfd); +spectfd_t spectfd__prealloc(); +void spectfd__update_systemfd(spectfd_t fd, int systemfd); +int spectfd__close(spectfd_t fd); #endif