From f64b60a1c60bc5ee559b9f80d80167d78bf2874c Mon Sep 17 00:00:00 2001 From: Hayley Date: Wed, 19 Jun 2019 15:54:47 -0500 Subject: [PATCH] msSince() function added to utils --- DSP_API/SmartSDR_Interface/utils.c | 9 +++++++++ DSP_API/SmartSDR_Interface/utils.h | 1 + 2 files changed, 10 insertions(+) diff --git a/DSP_API/SmartSDR_Interface/utils.c b/DSP_API/SmartSDR_Interface/utils.c index 2dd9860..f35c62b 100644 --- a/DSP_API/SmartSDR_Interface/utils.c +++ b/DSP_API/SmartSDR_Interface/utils.c @@ -86,6 +86,7 @@ float tsfSubtract(struct timespec time1, struct timespec time2) return result; } + //! get time since a certain time in microseconds uint32 usSince(struct timespec time) { @@ -95,6 +96,14 @@ uint32 usSince(struct timespec time) return diff_us; } +uint32 msSince(struct timespec time) +{ + struct timespec delay; + clock_gettime(CLOCK_MONOTONIC, &delay); + uint32 diff_ms = (uint32)(tsSubtract(delay, time)); + return diff_ms; +} + uint32 getIP(char* text) { uint32 ip; diff --git a/DSP_API/SmartSDR_Interface/utils.h b/DSP_API/SmartSDR_Interface/utils.h index 8f6fe52..22d6371 100644 --- a/DSP_API/SmartSDR_Interface/utils.h +++ b/DSP_API/SmartSDR_Interface/utils.h @@ -40,6 +40,7 @@ void output(const char *fmt,...); void tsAdd(struct timespec* time1, struct timespec time2); float tsfSubtract(struct timespec time1, struct timespec time2); uint32 usSince(struct timespec time); +uint32 msSince(struct timespec time); uint32 getIP(char* text); void lock_malloc_init(void); void* safe_malloc(size_t size);