PDA

View Full Version : QextSerialPort - very strange problem with runtime



code_err
7th February 2012, 22:27
I've used this library before and didn't have such a problem. I did the same things as always.
After adding line which opens COM port: port->open(QIODevice::ReadWrite)
my program can be compiled but i get this message

7372

I use dynamic linking, i.e.

in my pro file have this:
LIBS += -lqextserialport1
in my sources include header file from library and in build directory have .dll.

Spend over 5h and can't understand why it happens. When i wrote simple, testing app everything works. Maybe there is a conflict because of using dynamic linked Qwt and QExt?

My compilator is MinGw-gcc4.4.0, Qt4.8 on Windows 7

I can add that i use version 1.2 of QextSerialPort, creating QextSerialPort object on heap doesn't make any runtime problem, just opening is not working. All libraries was compiled in MinGw in Qt4.8

ChrisW67
8th February 2012, 02:33
My money is on a null or invalid pointer.

code_err
8th February 2012, 11:24
It would be very very nice but it seems not to be so simple:

entire function


QStringList myWindow::findPorts()
{
QStringList list;

QextSerialPort *myPort = new QextSerialPort("COM1");

for(int i = 1; i <= 256; ++i)
{
if(i < 9)
{
myPort->setPortName(QString("COM%1").arg(QString::number(i)));
}
else
{
myPort->setPortName(QString("\\\\.\\COM%1").arg(QString::number(i)));
}
if(myPort->open(QIODevice::ReadWrite))
{
myPort->close();
list << QString("Port: COM%1").arg(QString::number(i));
}
}
delete myPort;

return list;
}

myPort pointer isn't empty as you see. The same code works in a simple, testing app.

findPorts() is invoked by another function in constructor of myWindow

Lesiok
8th February 2012, 14:02
Why You don't use QextSerialEnumerator ?

laszlo.gosztola
8th February 2012, 14:05
Does it happen in debug and release mode also?
Shouldn't You link in debug mode qextserialportd1?

By the way, I haven't used qextserialport in windows7 environment, just in XP

code_err
8th February 2012, 14:29
Why You don't use QextSerialEnumerator ?
Because i used to do it that way and it should work anyway (and works fine in other programs)


Does it happen in debug and release mode also?
Shouldn't You link in debug mode qextserialportd1?
I was writing about release mode but in debug mode there is the same error.


By the way, I haven't used qextserialport in windows7 environment, just in XPIt works good, usually.

I've changed qextSerialPort library on version 1.2 alpha and now i have other error message:
When I try to run it, I get "The application failed to initialize properly (0xc0000005)".

I tried to apply this hint but it doesn't help much.
http://www.qtcentre.org/threads/11327-app-fails-to-start-with-QWT-involved

so i've come back to previous version of QextSerialPort which seems to have some problem with QWT i guess.

I can add that there is a warning that i have while compiling related to QWT library:

qwt_interva.h:270: warning: 'bool QwtInterval::isValid() const' redeclared without dllimport after being referenced with dll linkage
In file included from ....
from ....
from ....
from ....

code_err
8th February 2012, 23:17
Maybe i could use QProcess(es) as a form of workaround and there put everything related to QextSerialPort functionality?
What do you think? But still the normal way of using this library would be much more appreciated

The problem occurs exactly when i try to open existing port, if port doesn't exist there is no problem, but when existing (close or open) port is opening i see above dialog with error.

I can also see in external serial port monitor tool that my app in fact opens port and then it crashes.

laszlo.gosztola
9th February 2012, 07:11
Did You build the qextserial from source?
Did You download it from sourceforge - it has been moved from there to googlecode and as far as I remeber there is a newer version than 1.2.alpha. (Maybe just the alpha tag was removed)

If You have the source code, maybe should try to debug the port open function step-by-step, to find out why and where it crashes.

Lesiok
9th February 2012, 08:25
Because i used to do it that way and it should work anyway (and works fine in other programs)

1. This solution works only in Windows. In Linux serial ports names are different.
2. In this way You produce a list of ports that you can open, not a list of existing ports on your computer.

code_err
9th February 2012, 10:29
Did You build the qextserial from source? Yes, i did.

Did You download it from sourceforge - it has been moved from there to googlecode and as far as I remeber there is a newer version than 1.2.alpha. (Maybe just the alpha tag was removed)Have two versions, the old one from sourgeforge and newer from googlecode, first (that i use in my other apps) shows this error message, the second shows 0x0000005 error, it occurs with conjunction with QWT i suppose.

If You have the source code, maybe should try to debug the port open function step-by-step, to find out why and where it crashes.Probably i will have to.

1. This solution works only in Windows. In Linux serial ports names are different.
Maybe will try QextSerialEnumerator

2. In this way You produce a list of ports that you can open, not a list of existing ports on your computer.
Yes, but on this list i have also all physical/virtual ports from my pc.
Thanks for ideas.

kuzulis
9th February 2012, 13:23
2 code_err,

try use another library QSerialDevice 2.0 (http://gitorious.org/qserialdevice/qserialdevice/trees/2.0)

The reason for this see here (http://developer.qt.nokia.com/forums/viewreply/67246/).

code_err
10th February 2012, 11:45
This changes everything, thanks.

code_err
10th February 2012, 20:07
I changed my mind. As for now i see that class SerialPortInfo from library QSerialDevice do not see:

on my Laptop with Win7:
- any virtual COM port made by several different tools
- USB to COM - Prolific HUB

on PC with Win XP
- can't see virtual ports

but
- see physical COM port
- USB to COM - Prolific HUB

Unfortunately i need HUB USB->COM so i probably come back to QExtSerialPort

ChrisW67
11th February 2012, 06:07
I've changed qextSerialPort library on version 1.2 alpha and now i have other error message:
When I try to run it, I get "The application failed to initialize properly (0xc0000005)".

0xC0000005
STATUS_ACCESS_VIOLATION
The instruction at 0x%08lx referenced memory at 0x%08lx. The memory could not be %s.

That is, most likely, your program attempted to dereference a null or invalid pointer.

kuzulis
11th February 2012, 14:27
- any virtual COM port made by several different tools
You Lie! At the very least displayed virtual ports from Eltima Software, Com0Com, etc,
on XP, Win7

Library recognizes only those devices that also recognizes the OS,
ie only those devices that are displayed in the DeviceManager (by Setup API).

That is, utilities that create virtual ports must be adhere to standards of Windows. For all other virtual ports are created by "curves" utilities - it is the problem of "Curves" tools.


USB to COM - Prolific HUB
What Class GUID have this device? What type of device (chip)? Which driver is installed? Displayed whether this device in DeviceManager?

code_err
12th February 2012, 00:54
You Lie!Easy, don't be so angry, i tried three software tools: Eterlogic VSPEmulator, HHD Free Virtual Serial Port and Eltima Virtual Serial port and they didn't work for me on my notebook but... i realized that it do works when i execute program with admin rights. Anyone know what to do to my app could see ports as normal user? With QExtSerialPort i can see it without any problems.


That is, utilities that create virtual ports must be adhere to standards of Windows. For all other virtual ports are created by "curves" utilities - it is the problem of "Curves" tools.Soft was ok.
What Class GUID have this device? What type of device (chip)? Which driver is installed? Displayed whether this device in DeviceManager?
It's working now.

kuzulis
12th February 2012, 09:19
Try add GUID {86E0D1E0-8089-11D0-9CE4-08003E301F73} to serialportinfo_win.cpp in

static const GUID guidArray[] =
line 20

or add GUID your "USB to COM - Prolific HUB" device.