خرید بک لینک

Vote count: 0

I am developing an application which reads data from the device (Microcontroller) coected on SerialPort of Windows 7 and display all read data into the Qt based UI application.

Environment: Qt: Qt 5.6.0 OS: Windows 7

Before implementing the continious reading from the Windows Serial port. I implemented a test application to read data from Serial port on button press (Some button in Qt GUI) using QSerialPort Class and it worked properly.

So I started implementing the continious reading from the device coected at serial port example: 1. Coect PushButton Press. Coect to the Device. 2. Start Push Button Press. Start Reading. 3. Stop Push Button Press. Stop Reading.

Here my code is same as like my test application but for continious reading. I implemented the QSocketNotifier functionality when I coect to the Device (Coect Push Button press). Below is the code for the same:

bool Test::openPort()
{
    bool result = false;

    //SerialPortManager: Class to Open, Read, Write to the device coected at Serial Port
    if(serialPortManager != NULL) 
    {
        result = serialPortManager->open(); // Returns TRUE

        if(operationSuccessful)
        {
            //socketNotifier  pointer defined in TestClass.h file
        socketNotifier = new QSocketNotifier(serialPortManager->getSerialPortFileDescriptor(), QSocketNotifier::Read);
            coect(socketNotifier , SIGNAL(activated(int)), this, SLOT(onReadData()));

        socketNotifier ->setEnabled(true);
        }
    }

    return result ;
}

// Get File Descriptor
qint32 SerialPortManager::getSerialPortFileDescriptor()
{
    int readFileDescriptor = _open_osfhandle((qintptr), _O_RDONLY | _O_WRONLY);

    return readFileDescriptor;
    //return (qintptr)serialPort.handle();
}

Here Problem is SLOT onReadData() which is coected to the SocketNotifier is never get called. It looks like to me that the activated(int) signal is never emitted.

I did some google and on one link I found that QSocketNotifier does not work for SerialPort reading on Windows. Since the link is very old So wanted to confirm. http://www.archivum.info/[email protected]/2008-03/00128/Re-QSocketNotifier.html

Please advise what I am doing wrong?

Thanks,

asked 36 secs ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 15 شهريور 1395 ساعت: 12:12

صفحه بندی