C API not working with QtApplication



  • 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


  • Moderators

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



  • 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 .


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.