Changeset - e097ff97da17
[Not reviewed]
default
0 1 0
Hasan Yavuz ÖZDERYA - 6 years ago 2020-01-25 07:59:10
hy@ozderya.net
fix "Custom Frame" data format number of channels not being set correctly
1 file changed with 2 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/framedreader.cpp
Show inline comments
 
/*
 
  Copyright © 2019 Hasan Yavuz Özderya
 
  Copyright © 2020 Hasan Yavuz Özderya
 

	
 
  This file is part of serialplot.
 

	
 
  serialplot is free software: you can redistribute it and/or modify
 
  it under the terms of the GNU General Public License as published by
 
  the Free Software Foundation, either version 3 of the License, or
 
  (at your option) any later version.
 

	
 
  serialplot is distributed in the hope that it will be useful,
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  GNU General Public License for more details.
 

	
 
  You should have received a copy of the GNU General Public License
 
  along with serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include <QtDebug>
 
#include <QtEndian>
 
#include "floatswap.h"
 

	
 
#include "framedreader.h"
 

	
 
FramedReader::FramedReader(QIODevice* device, QObject* parent) :
 
@@ -138,48 +138,49 @@ void FramedReader::checkSettings()
 
    // show an error message
 
    if (settingsInvalid & SYNCWORD_INVALID)
 
    {
 
        _settingsWidget.showMessage("Sync word is invalid!", true);
 
    }
 
    else if (settingsInvalid & FRAMESIZE_INVALID)
 
    {
 
        QString errorMessage =
 
            QString("Frame size must be multiple of %1 (#channels * sample size)!")\
 
            .arg(_numChannels * sampleSize);
 

	
 
        _settingsWidget.showMessage(errorMessage, true);
 
    }
 
    else
 
    {
 
        _settingsWidget.showMessage("All is well!");
 
    }
 
}
 

	
 
void FramedReader::onNumOfChannelsChanged(unsigned value)
 
{
 
    _numChannels = value;
 
    checkSettings();
 
    reset();
 
    updateNumChannels();
 
    emit numOfChannelsChanged(value);
 
}
 

	
 
void FramedReader::onSyncWordChanged(QByteArray word)
 
{
 
    syncWord = word;
 
    checkSettings();
 
    reset();
 
}
 

	
 
void FramedReader::onFrameSizeChanged(unsigned value)
 
{
 
    if (value == 0)
 
    {
 
        hasSizeByte = true;
 
    }
 
    else
 
    {
 
        hasSizeByte = false;
 
        frameSize = value;
 
    }
 
    checkSettings();
 
    reset();
 
}
0 comments (0 inline, 0 general)