KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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: QFile file("/dev/testDriver"); if(file.open(QFile::ReadOnly)) { QSocketNotifier sn(file.handle(), , QSocketNotifier::Read); sn.setEnabled(true); connect(&sn, SIGNAL(activated(int)), &this, SLOT(readyRead())); } But readyRead was never called and my driver never reported having its poll method called. I was able to get the following code to work so I know my driver is working 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() << "Started poll"; ready = poll(fds, 1, -1); qDebug() << "Poll returned: " << ready; QTextStream in(&file); QTextStream out(stdout); out << in.readAll(); } 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. 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. Is it possible to use QSocketNotifier in this way? The documentation of QFile::handle() seems to indicate it should be.
Tags (comma-separated)
Save Edits
Cancel