Changeset - b12c2ff3d038
[Not reviewed]
default
0 2 0
Hasan Yavuz Ă–ZDERYA - 11 years ago 2015-03-07 16:03:22
hy@ozderya.net
enabled serial port error reporting to stdout
2 files changed with 10 insertions and 0 deletions:
0 comments (0 inline, 0 general)
mainwindow.cpp
Show inline comments
 
@@ -32,6 +32,10 @@ MainWindow::MainWindow(QWidget *parent) 
 
    QObject::connect(&(this->serialPort), &QSerialPort::readyRead,
 
                     this, &MainWindow::onDataReady);
 

	
 
	// init port signals
 
	QObject::connect(&(this->serialPort), SIGNAL(error(QSerialPort::SerialPortError)),
 
                     this, SLOT(onPortError(QSerialPort::SerialPortError)));
 

	
 
    loadPortList();
 
    loadBaudRateList();
 
    ui->cbBaudRate->setCurrentIndex(ui->cbBaudRate->findText("9600"));
 
@@ -161,6 +165,11 @@ void MainWindow::onDataReady()
 
	addData((unsigned char)(data[0]));
 
}
 

	
 
void MainWindow::onPortError(QSerialPort::SerialPortError error)
 
{
 
	qDebug() << "Port error happened: " << serialPort.error();
 
}
 

	
 
void MainWindow::addData(double data)
 
{
 
	// shift data array and place new data at the end
mainwindow.h
Show inline comments
 
@@ -38,6 +38,7 @@ private slots:
 
    void selectBaudRate(QString baudRate);
 

	
 
    void onDataReady();
 
    void onPortError(QSerialPort::SerialPortError error);
 

	
 
signals:
 
    void portToggled(bool open);
0 comments (0 inline, 0 general)