Changeset - 87f05e438f7f
[Not reviewed]
default
0 1 0
Hasan Yavuz Ă–ZDERYA - 10 years ago 2015-11-07 14:56:52
hy@ozderya.net
when paused preserve 'package' synchronization
1 file changed with 9 insertions and 9 deletions:
0 comments (0 inline, 0 general)
dataformatpanel.cpp
Show inline comments
 
@@ -211,16 +211,18 @@ void DataFormatPanel::demoTimerTimeout()
 

	
 
void DataFormatPanel::onDataReady()
 
{
 
    // TODO: discard data in the size of packageSize
 
    if (paused)
 
    {
 
        serialPort->clear(QSerialPort::Input);
 
        return;
 
    }
 

	
 
    // a package is a set of channel data like {CHAN0_SAMPLE, CHAN1_SAMPLE...}
 
    int packageSize = sampleSize * _numOfChannels;
 
    int bytesAvailable = serialPort->bytesAvailable();
 
    int numOfPackagesToRead =
 
        (bytesAvailable - (bytesAvailable % packageSize)) / packageSize;
 

	
 
    if (paused)
 
    {
 
        // read and discard data
 
        serialPort->read(numOfPackagesToRead*packageSize);
 
        return;
 
    }
 

	
 
    if (bytesAvailable > 0 && skipByteRequested)
 
    {
 
@@ -231,8 +233,6 @@ void DataFormatPanel::onDataReady()
 

	
 
    if (bytesAvailable < packageSize) return;
 

	
 
    int numOfPackagesToRead =
 
        (bytesAvailable - (bytesAvailable % packageSize)) / packageSize;
 
    double* channelSamples = new double[numOfPackagesToRead*_numOfChannels];
 

	
 
    for (int i = 0; i < numOfPackagesToRead; i++)
0 comments (0 inline, 0 general)