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. C API not working with QtApplication
Forum Updated to NodeBB v4.3 + New Features

C API not working with QtApplication

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 2 Posters 673 Views
  • 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.
  • R Offline
    R Offline
    Rohith
    wrote on last edited by
    #1

    Hi,

    I am using WiFi API(which is written in C) in my GUI based Qt application for my embedded device but it is getting hanged.

    When i am using same API in non-GUI based Qt Application then it is working fine.

    I am using Qt-5.5.1 version in my target embedded device.

    GUI-Qt Application Code :

        #include <QApplication>
        #include <QDebug>
        #include<unistd.h>
        extern "C"
        {
            #include "embeddedDev.h"
        }
        int main(int argc, char *argv[])
        {
                QApplication a(argc, argv);
         
                int iodev = iodev_open();
                (iodev == 0) ? qDebug()<<"===>IODEV Open Success<===" : qDebug()<<"===>IODEV Open Failed<===";
         
                int wifi = wifi_cntrl(1);
                sleep(3);
                (wifi == 0) ? qDebug()<<"===>WiFi Power_On Success<===" : qDebug()<<"===>WiFi Power_On Failed<===";
         
                wifi = wifi_cntrl(0); // [B]It's stucks here, Device is getting hanged.[/B]
                (wifi == 0) ? qDebug()<<"===>WiFi Power_OFF Success<===" : qDebug()<<"===>WiFi Power_OFF Failed<===";
         
                iodev = iodev_close();
                (iodev == 0) ? qDebug()<<"===>IODEV close Success<===" : qDebug()<<"===>IODEV close Failed<===";
         
                return a.exec();
        }
    

    Non-GUI-Qt Application :

        #include <QtCore>
        #include <QDebug>
        #include<unistd.h>
        extern "C"
        {
            #include "embeddedDev.h"
        }
        int main(int argc, char *argv[])
        {
                QCoreApplication a(argc, argv);
         
                int iodev = iodev_open();
                (iodev == 0) ? qDebug()<<"===>IODEV Open Success<===" : qDebug()<<"===>IODEV Open Failed<===";
         
                int wifi = wifi_cntrl(1);
                sleep(3);
                (wifi == 0) ? qDebug()<<"===>WiFi Power_On Success<===" : qDebug()<<"===>WiFi Power_On Failed<===";
         
                wifi = wifi_cntrl(0); 
                (wifi == 0) ? qDebug()<<"===>WiFi Power_OFF Success<===" : qDebug()<<"===>WiFi Power_OFF Failed<===";
         
                iodev = iodev_close();
                (iodev == 0) ? qDebug()<<"===>IODEV close Success<===" : qDebug()<<"===>IODEV close Failed<===";
         
                return a.exec();
        }
    

    Any help will be appreciated.
    Thanks in advance,
    Rohith.G

    jsulmJ 1 Reply Last reply
    0
    • R Rohith

      Hi,

      I am using WiFi API(which is written in C) in my GUI based Qt application for my embedded device but it is getting hanged.

      When i am using same API in non-GUI based Qt Application then it is working fine.

      I am using Qt-5.5.1 version in my target embedded device.

      GUI-Qt Application Code :

          #include <QApplication>
          #include <QDebug>
          #include<unistd.h>
          extern "C"
          {
              #include "embeddedDev.h"
          }
          int main(int argc, char *argv[])
          {
                  QApplication a(argc, argv);
           
                  int iodev = iodev_open();
                  (iodev == 0) ? qDebug()<<"===>IODEV Open Success<===" : qDebug()<<"===>IODEV Open Failed<===";
           
                  int wifi = wifi_cntrl(1);
                  sleep(3);
                  (wifi == 0) ? qDebug()<<"===>WiFi Power_On Success<===" : qDebug()<<"===>WiFi Power_On Failed<===";
           
                  wifi = wifi_cntrl(0); // [B]It's stucks here, Device is getting hanged.[/B]
                  (wifi == 0) ? qDebug()<<"===>WiFi Power_OFF Success<===" : qDebug()<<"===>WiFi Power_OFF Failed<===";
           
                  iodev = iodev_close();
                  (iodev == 0) ? qDebug()<<"===>IODEV close Success<===" : qDebug()<<"===>IODEV close Failed<===";
           
                  return a.exec();
          }
      

      Non-GUI-Qt Application :

          #include <QtCore>
          #include <QDebug>
          #include<unistd.h>
          extern "C"
          {
              #include "embeddedDev.h"
          }
          int main(int argc, char *argv[])
          {
                  QCoreApplication a(argc, argv);
           
                  int iodev = iodev_open();
                  (iodev == 0) ? qDebug()<<"===>IODEV Open Success<===" : qDebug()<<"===>IODEV Open Failed<===";
           
                  int wifi = wifi_cntrl(1);
                  sleep(3);
                  (wifi == 0) ? qDebug()<<"===>WiFi Power_On Success<===" : qDebug()<<"===>WiFi Power_On Failed<===";
           
                  wifi = wifi_cntrl(0); 
                  (wifi == 0) ? qDebug()<<"===>WiFi Power_OFF Success<===" : qDebug()<<"===>WiFi Power_OFF Failed<===";
           
                  iodev = iodev_close();
                  (iodev == 0) ? qDebug()<<"===>IODEV close Success<===" : qDebug()<<"===>IODEV close Failed<===";
           
                  return a.exec();
          }
      

      Any help will be appreciated.
      Thanks in advance,
      Rohith.G

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Rohith Could you please explain better what happens? Is any of the debug messages printed? And what do you mean by "hanged"?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Rohith
        wrote on last edited by Rohith
        #3

        Hi Jsulm,

        Thanks for replying

        ===>IODEV Open Success<===
        ===>WiFi Power_On Success<===

        These two debugs are appearing on the Screen and there after we are unable to see any more debugs in the case of we use QApplication but where as in the case of QCoreApplication each and every debug we are able to see.

        Hanging in the sense, we cant to able to perform any other operation even ctrl+c will also not works.
        In order to use the device we need to restart the device and our device is having Linux OS and the Qt version we are using Qt-5.5.1 .

        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