Changeset - ed44540644c7
[Not reviewed]
default
0 1 0
Hasan Yavuz Ă–ZDERYA - 11 years ago 2015-04-04 11:31:49
hy@ozderya.net
removed obscure debug code
1 file changed with 0 insertions and 1 deletions:
0 comments (0 inline, 0 general)
mainwindow.cpp
Show inline comments
 
@@ -189,97 +189,96 @@ void MainWindow::togglePort()
 
    }
 
}
 

	
 
void MainWindow::selectPort(QString portName)
 
{
 
    // has selection actually changed
 
    if (portName != serialPort.portName())
 
    {
 
        // if another port is already open, close it by toggling
 
        if (serialPort.isOpen())
 
        {
 
            togglePort();
 

	
 
            // open new selection by toggling
 
            togglePort();
 
        }
 
    }
 
}
 

	
 
void MainWindow::selectBaudRate(QString baudRate)
 
{
 
    if (serialPort.isOpen())
 
    {
 
        if (!serialPort.setBaudRate(baudRate.toInt()))
 
        {
 
            qDebug() << "Set baud rate failed during select: "
 
                     << serialPort.error();
 
        }
 
        else
 
        {
 
            qDebug() << "Baud rate changed: " << serialPort.baudRate();
 
        }
 
    }
 
}
 

	
 
void MainWindow::selectParity(int parity)
 
{
 
    if (serialPort.isOpen())
 
    {
 
        if(!serialPort.setParity((QSerialPort::Parity) parity))
 
        {
 
            qDebug() << "Set parity failed: " << serialPort.error();
 
        }
 
    }
 
}
 

	
 
void MainWindow::selectDataBits(int dataBits)
 
{
 
    qDebug() << dataBits;
 
    if (serialPort.isOpen())
 
    {
 
        if(!serialPort.setDataBits((QSerialPort::DataBits) dataBits))
 
        {
 
            qDebug() << "Set data bits failed: " << serialPort.error();
 
        }
 
    }
 
}
 

	
 
void MainWindow::onPortToggled(bool open)
 
{
 
    ui->pbOpenPort->setChecked(open);
 
}
 

	
 
void MainWindow::onDataReady()
 
{
 
    if (!ui->actionPause->isChecked())
 
    {
 
        int bytesAvailable = serialPort.bytesAvailable();
 
        if (bytesAvailable < sampleSize)
 
        {
 
            return;
 
        }
 
        else
 
        {
 
            int numOfSamplesToRead =
 
                (bytesAvailable - (bytesAvailable % sampleSize)) / sampleSize;
 
            QVector<double> samples(numOfSamplesToRead);
 
            int i = 0;
 
            while(i < numOfSamplesToRead)
 
            {
 
                samples.replace(i, (this->*readSample)());
 
                i++;
 
            }
 
            addData(samples);
 
        }
 
    }
 
    else
 
    {
 
        serialPort.clear(QSerialPort::Input);
 
    }
 
}
 

	
 
void MainWindow::onPortError(QSerialPort::SerialPortError error)
 
{
 
    switch(error)
 
    {
 
        case QSerialPort::NoError :
0 comments (0 inline, 0 general)