1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

fix race condition between usb buffer and data transfer buffer

This commit is contained in:
Manuel Pitz 2019-02-20 18:59:23 +00:00
parent e34c5f0036
commit db1c9eaa97
2 changed files with 5 additions and 13 deletions

View file

@ -37,7 +37,7 @@ nodes = {
},
out = {
vectorize = 100
address = "192.168.104.10:13000"
address = "10.100.1.125:13000"
}
}
}

View file

@ -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];