cancel
Showing results for 
Search instead for 
Did you mean: 

proper way to read /dev/ttyrpmsg0

IYetk
Associate III

Hi,

I am executing echo_tty_echo example and trying to get the messages coming from m4 inside qt program as follows:

   QString line;

   QStringList list1;

   char buff[100];

   while (1) {

       QProcess::execute("echo hello > /dev/ttyRPMSG0");

       QFile armIpcReadMsg("/dev/ttyRPMSG0");

       if(armIpcReadMsg.exists())

       {

           if(armIpcReadMsg.open(QIODevice::ReadOnly | QIODevice::Unbuffered)

           {

               armIpcReadMsg.read(buff,100);

               line = QString::fromLatin1(buff);

               list1 = line.split(",");

               ui->label->setText(list1.at(0));

               ui->label_2->setText(list1.at(1));

               ui->label_3->setText(list1.at(2));

               armIpcReadMsg.close();

           }

       }

       memset(&buff[0], 0, sizeof(buff));

       delay(500);

   }

As you see, the command "echo hello > /dev/ttyRPMSG0" is inside my while loop. When I run this code, the command is executed just once and nothing can be read from the port.

As I modified the code so that our command is run as a seperate thread, it continues to run infinitely in the loop but out port can read nothing again.

As a third scenario, I execute my command not inside my qt program but from linux bash, Our port can read something but usually what it reads in the variable 'buff' is spoiled and erroneous.

Any ideas to read /dev/ttyrpmsg0 properly ? Should I add a delay while sending the command or while reading the port ? How long delay ?

tnx

1 ACCEPTED SOLUTION

Accepted Solutions
IYetk
Associate III

I solved the problem with "QtSerialPort".

View solution in original post

1 REPLY 1
IYetk
Associate III

I solved the problem with "QtSerialPort".