Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing QSocketNotifier to select on a char device.
    primarykey
    data
    text
    <p>I wrote a char device driver and am now writing a QT "wrapper" which part of it is to get a signal to fire when the device becomes readable via the poll mechanism. I had tried to do:</p> <pre><code>QFile file("/dev/testDriver"); if(file.open(QFile::ReadOnly)) { QSocketNotifier sn(file.handle(), , QSocketNotifier::Read); sn.setEnabled(true); connect(&amp;sn, SIGNAL(activated(int)), &amp;this, SLOT(readyRead())); } </code></pre> <p>But readyRead was never called and my driver never reported having its poll method called.</p> <p>I was able to get the following code to work so I know my driver is working</p> <pre><code>QFile file("/dev/testDriver"); if(file.open(QFile::ReadOnly)) { struct pollfd fd; fd.fd = file.handle(); fd.events = POLLIN; struct pollfd fds[] = {fd}; int ready; qDebug() &lt;&lt; "Started poll"; ready = poll(fds, 1, -1); qDebug() &lt;&lt; "Poll returned: " &lt;&lt; ready; QTextStream in(&amp;file); QTextStream out(stdout); out &lt;&lt; in.readAll(); } </code></pre> <p>This properly waits for my driver to call wake_up and I can see two poll calls from my driver. One for the initial poll registration and one for when the wake_up happens. </p> <p>Doing it this way I would probably have to spawn a separate thread which all it did was poll on this device and throw a signal and loop. </p> <p>Is it possible to use <a href="http://doc.qt.nokia.com/latest/qsocketnotifier.html" rel="nofollow">QSocketNotifier</a> in this way? The documentation of <a href="http://doc.qt.nokia.com/latest/qfile.html#handle" rel="nofollow">QFile::handle()</a> seems to indicate it should be.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload