Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QSocketNotifier always fire once on startup
Qt 6.11 is out! See what's new in the release blog

QSocketNotifier always fire once on startup

Scheduled Pinned Locked Moved Mobile and Embedded
1 Posts 1 Posters 769 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sharethl
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved