QSocketNotifier always fire once on startup
-
Hi,
The notifier is used to monitor a GPIO, who's edge = falling.
After setting up, it immediately fire a signal. but I haven't press that button yet.What could be the cause?
@MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{ui->setupUi(this); QFile edge_file("/sys/class/gpio/gpio19/edge"); if (!edge_file.open(QIODevice::WriteOnly)) { return; } QTextStream out_edge(&edge_file); out_edge << "falling"; edge_file.close(); //http://meecom.blogspot.com/2014/06/qt-beagle-bb-gpio-tcp-client.html keyValueFile.setFileName("/sys/class/gpio/gpio19/value"); keyValueFile.open(QFile::ReadOnly); _gpioNotifier = new QSocketNotifier(keyValueFile.handle(), QSocketNotifier::Exception); connect(_gpioNotifier, SIGNAL(activated(int)), this, SLOT(readyRead(int)));
}
/**- @brief MainWindow::readyRead
- Need read values to prevent reentry.
- @param value
*/
void MainWindow::readyRead(int value)
{
QByteArray line;
keyValueFile.seek(0);
line = keyValueFile.readAll();
qDebug() << line;
}@
Thanks