Important: Please read the Qt Code of Conduct -

How to sync data from to different embedded Device?

  • Hello,

    I do have two device, Device_A and Device_B. They are emitting signals, ExperimentDCdataArraived
    and Experiment 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 from Device_A. It is also emit from Device_B but slot are just return without creating new csv file.

    I would like to executable slot of ExperimentNodeBeaggingif both device sent same number of data to software. Otherwise wait for Device_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()));
       				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 because loopPtr->exec();

    As If I am not wrong then its look like doing something like below

    1. emit the ExperimentNodeBeagging.
    2. wait for exit code at lootpPtr->exec().
    3. emit the ExperimentNodeBeagging.
    4. wait for exit code at lootpPtr->exec().
    5. get the exit code from step 2
    6. execute the remaining Slot of ExperimentNodeBeagging
    7. get the exit code from step 4
    8. 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 ). Here Device_A is not getting the response ExperimentNodeBeagging within certain amount of time that's why Device_A again sent signal ExperimentNodeBeagging.

    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?

  • Lifetime Qt Champion


    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.

  • Lifetime Qt Champion

    Do you really need two different objects to communicate with these devices ?