How to sync data from to different embedded Device?
-
Hello,
I do have two device,
Device_A
andDevice_B.
They are emitting signals,ExperimentDCdataArraived
andExperiment NodeBeagging
Signals.ExperimentDCdataArraived
is emit on arrival of DC data.
Sample rate is set same in both device, I would like to place both devices data in single csv file.On emit of
ExperimentNodeBeagging
signal, new csv file are created. It is mostly emit fromDevice_A
. It is also emit fromDevice_B
but slot are just return without creating new csv file.I would like to executable slot of
ExperimentNodeBeagging
if both device sent same number of data to software. Otherwise wait forDevice_B
sent the data point.if (oldData.container.contains(DCDATA_RING_CURRENT)) { auto len1 = oldData.container[DCDATA_RING_CURRENT].numberOfDataPoints(); auto len2 = oldData.container[DCDATA_ELAPSED_TIME_S].numberOfDataPoints(); while (len1 != len2) { QEventLoop loop; QEventLoop* loopPtr = &loop; QTimer::singleShot(20, loopPtr, SLOT(quit())); loopPtr->exec(); len1 = oldData.container[DCDATA_RING_CURRENT].numberOfDataPoints(); len2 = oldData.container[DCDATA_ELAPSED_TIME_S].numberOfDataPoints(); } }
I place this code in slot of
ExperimentNodeBeagging
but it is crashing for some sampling rate becauseloopPtr->exec();
As If I am not wrong then its look like doing something like below
- emit the ExperimentNodeBeagging.
- wait for exit code at lootpPtr->exec().
- emit the ExperimentNodeBeagging.
- wait for exit code at lootpPtr->exec().
- get the exit code from step 2
- execute the remaining Slot of ExperimentNodeBeagging
- get the exit code from step 4
- execute the remaining Slot of ExperimentNodeBeagging (Here my Software is crash)
In Normal execution
ExperimentNodeBeagging
is not emit the second time (step 7 and 8 ). HereDevice_A
is not getting the responseExperimentNodeBeagging
within certain amount of time that's whyDevice_A
again sent signalExperimentNodeBeagging
.I am calling
loopPtr->exec();
because before creating the CSV file I need wait data from Device_B.Is there any good way to sync both Device?
-
Hi,
If you want to have both data before going further, why not store them rather than artificially wait ? Then once you have both write them to the file you want.
-
@SGaist I am doing the that thing but the issue is created at last point.
So, Whenever the Device_A send the last data point, and immediately send the
ExperimentNodeBeagging
, So new csv file created.Whenever the Device_B send the data point at that time it will place in new csv file instead of old csv file because of ExperimentNodeBeagging.
-
Do you really need two different objects to communicate with these devices ?