Unsolved Reading devices under /dev/.
-
@jigarp You read like any other file
-
In this way i'm trying to write data to rpmsg
QFile armIpcWriteMsg("/dev/rpmsg_pru30"); QTextStream outstream(&armIpcWriteMsg); qDebug() << "Writing PRU Data"; if(armIpcWriteMsg.open(QIODevice::WriteOnly)) { outstream << "Hello"; armIpcWriteMsg.close(); }
In this way i'm trying to read.
QFile armIpcReadMsg("/dev/rpmsg_pru30"); if(armIpcReadMsg.exists()) { if(armIpcReadMsg.open(QIODevice::ReadOnly | QIODevice::Unbuffered)) { char buff[20]; armIpcReadMsg.read(buff,1); qDebug() << "PRU2ARM:" << buff; armIpcReadMsg.close(); } }
Is it the right way?
-
@jigarp Should be OK. Did you try it out?
-
I've tried it.
I'm able to write successfully.But while trying to read file it waits until data became available.
I wan't to check for data availability before reading that file.I've tried QFileinfo by monitoring its size but it is always zero.
Is there any way to check for ready read. -
@jigarp I don't think there is anything in Qt for that.
I see two possibilities:- Use a second thread where you call read()
- Use C API call select() (see man select)
-
I agree!
Create a separate thread to handle the device, use (select () or poll ()) and signals to notify other classes or get to the GUI.
-
Hi,
QFileSystemWatcher might be of interest.
-
@Cleiton-Bueno @jsulm
In my case i'm reading this file in a thread but there are some more work involved so it is necessory to check whether data available or not.I can not wait until data available.
Is there any way to check data available like size or any other.
File.size() always responds with 0Create a separate thread to handle the device, use (select () or poll ()) and signals to notify other classes or get to the GUI.
How to use Can you provide any samples???
-
-
-
@jigarp said in Reading devices under /dev/.:
Not Working..
Well, with such information it is impossible to say why it is not working.
Can you show what you tried and what the result was?