Changeset - 70f95e53d915
[Not reviewed]
default
0 1 0
Hasan Yavuz Ă–ZDERYA - 11 years ago 2015-03-07 17:57:44
hy@ozderya.net
enabled Start toolbar button
1 file changed with 5 insertions and 2 deletions:
0 comments (0 inline, 0 general)
mainwindow.cpp
Show inline comments
 
@@ -143,50 +143,53 @@ void MainWindow::selectPort(QString port
 

	
 
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::onPortToggled(bool open)
 
{
 
    ui->pbOpenPort->setChecked(open);
 
}
 

	
 
void MainWindow::onDataReady()
 
{
 
    QByteArray data = serialPort.readAll();
 
    addData((unsigned char)(data[0]));
 
    if (ui->actionStart->isChecked())
 
    {
 
        QByteArray data = serialPort.readAll();
 
        addData((unsigned char)(data[0]));
 
    }
 
}
 

	
 
void MainWindow::onPortError(QSerialPort::SerialPortError error)
 
{
 
    switch(error)
 
    {
 
        case QSerialPort::NoError :
 
            break;
 
        case QSerialPort::ResourceError :
 
            qDebug() << "Port error: resource unavaliable; most likely device removed.";
 
            if (serialPort.isOpen())
 
            {
 
                qDebug() << "Closing port on resource error: " << serialPort.portName();
 
                togglePort();
 
            }
 
            loadPortList();
 
            break;
 
        default:
 
            qDebug() << "Unhandled port error: " << error;
 
            break;
 
    }
 

	
 
}
 

	
0 comments (0 inline, 0 general)