From 7144190fea093875d653166c13ccb59b5172a149 Mon Sep 17 00:00:00 2001 From: Markus Mirz Date: Mon, 18 Feb 2019 15:44:01 +0100 Subject: [PATCH 1/3] hooks: fix datatype for bitmask --- lib/hooks/average.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/hooks/average.c b/lib/hooks/average.c index f50f8a982..010c76e2d 100644 --- a/lib/hooks/average.c +++ b/lib/hooks/average.c @@ -31,7 +31,7 @@ #include struct average { - int mask; + uint64_t mask; int offset; }; @@ -42,7 +42,7 @@ static int average_parse(struct hook *h, json_t *cfg) int ret; json_error_t err; - ret = json_unpack_ex(cfg, &err, 0, "{ s: i, s: i }", + ret = json_unpack_ex(cfg, &err, 0, "{ s: i, s: I }", "offset", &p->offset, "mask", &p->mask ); @@ -62,7 +62,7 @@ static int average_process(struct hook *h, struct sample *smps[], unsigned *cnt) int n = 0; for (int k = 0; k < smp->length; k++) { - if (!(p->mask & (1 << k))) + if (!(p->mask & (1LL << k))) continue; switch (sample_format(smps[i], k)) { From db1c9eaa97233dc9afcfeea288a35aed5db38be2 Mon Sep 17 00:00:00 2001 From: Manuel Pitz Date: Wed, 20 Feb 2019 18:59:23 +0000 Subject: [PATCH 2/3] fix race condition between usb buffer and data transfer buffer --- etc/uldaq.conf | 2 +- lib/nodes/uldaq.c | 16 ++++------------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/etc/uldaq.conf b/etc/uldaq.conf index cc72d2946..06ead6346 100644 --- a/etc/uldaq.conf +++ b/etc/uldaq.conf @@ -37,7 +37,7 @@ nodes = { }, out = { vectorize = 100 - address = "192.168.104.10:13000" + address = "10.100.1.125:13000" } } } diff --git a/lib/nodes/uldaq.c b/lib/nodes/uldaq.c index 67b046f30..79c0ba2b6 100644 --- a/lib/nodes/uldaq.c +++ b/lib/nodes/uldaq.c @@ -598,26 +598,18 @@ int uldaq_read(struct node *n, struct sample *smps[], unsigned cnt, unsigned *re { struct uldaq *u = (struct uldaq *) n->_vd; - size_t buffer_incr = n->in.vectorize * u->in.channel_count; - pthread_mutex_lock(&u->in.mutex); - /* Wait for data available condition triggered by event callback */ - if (u->in.buffer_pos + buffer_incr < u->in.transfer_status.currentIndex) - pthread_cond_wait(&u->in.cv, &u->in.mutex); - -#if 1 - debug(2, "Total count = %lld", u->in.transfer_status.currentTotalCount); - debug(2, "Index = %lld", u->in.transfer_status.currentIndex); - debug(2, "Scan count = %lld", u->in.transfer_status.currentScanCount); - debug(2, "Buffer pos = %zu", u->in.buffer_pos); -#endif if (u->in.status != SS_RUNNING) return -1; long long start_index = u->in.buffer_pos; + /* Wait for data available condition triggered by event callback */ + if (start_index + n->in.vectorize * u->in.channel_count > u->in.transfer_status.currentScanCount) + pthread_cond_wait(&u->in.cv, &u->in.mutex); + for (int j = 0; j < cnt; j++) { struct sample *smp = smps[j]; From f9ec9fe64da624104a4e7543380ac7fbc6887c8d Mon Sep 17 00:00:00 2001 From: Manuel Pitz Date: Wed, 20 Feb 2019 19:36:01 +0000 Subject: [PATCH 3/3] removed out: since unused parameter --- lib/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/memory.c b/lib/memory.c index a2f0b58d6..9ee08c28d 100644 --- a/lib/memory.c +++ b/lib/memory.c @@ -104,7 +104,7 @@ int memory_lock(size_t lock) debug(LOG_MEM | 2, "Increased ressource limit of locked memory to %zd bytes", lock); } #endif /* __arm__ */ -out: + #ifdef _POSIX_MEMLOCK /* Lock all current and future memory allocations */ ret = mlockall(MCL_CURRENT | MCL_FUTURE);