@@ -106,48 +106,49 @@ void AsciiReader::onDataReady()
// system CR is converted to LF for some reason. This causes
// empty lines in the input when the port is just opened.
if (line.isEmpty())
{
continue;
}
const SamplePack* samples = parseLine(line);
if (samples != nullptr) {
// update number of channels if in auto mode
if (autoNumOfChannels ) {
unsigned nc = samples->numChannels();
if (nc != _numChannels) {
_numChannels = nc;
updateNumChannels();
// TODO: is `numOfChannelsChanged` signal still used?
emit numOfChannelsChanged(nc);
Q_ASSERT(samples->numChannels() == _numChannels);
// commit data
feedOut(*samples);
delete samples;
SamplePack* AsciiReader::parseLine(const QString& line) const
auto separatedValues = line.split(delimiter, QString::SkipEmptyParts);
unsigned numComingChannels = separatedValues.length();
// check number of channels (skipped if auto num channels is enabled)
if ((!numComingChannels) || (!autoNumOfChannels && numComingChannels != _numChannels))
qWarning() << "Line parsing error: invalid number of channels!";
qWarning() << "Read line: " << line;
return nullptr;
// parse data per channel
auto samples = new SamplePack(1, numComingChannels);
for (unsigned ci = 0; ci < numComingChannels; ci++)
bool ok;
samples->data(ci)[0] = separatedValues[ci].toDouble(&ok);
if (!ok)
Status change: