QSerialPort open error code 10
-
@Christian-Ehrlicher said in QSerialPort open error code 10:
Do you have maybe another USB-serial converter for testing?
No, is not a USB serial converter but is a USB connected directly on the device/board.
I can ask my customer to give me back the fisrt board (the one that I starting to work with).
It could be the board or firmware yes.... but why with Hercules I can communicate without problems ?? -
@addebito said in QSerialPort open error code 10:
reinterpret_cast<const wchar_t *>("COM5")
And this is wrong. Either use the solution from @kuzulis or pass a proper utf-16 encoded string: L"COM5"
-
@Christian-Ehrlicher you are right but there isn't a call ".utf16()" in QByteArray class so I've replaced with a mistake.
Now the CreateFile with L"COM5" works. I don't get any error.
-
@addebito said in QSerialPort open error code 10:
QByteArray
Because it should be QString :)
Ok, then you have to debug by yourself, don't see what should go wrong within QSerialPort code nor can I test it locally.
-
@Christian-Ehrlicher said in QSerialPort open error code 10:
Ok, then you have to debug by yourself, don't see what should go wrong within QSerialPort code nor can I test it locally.
Yes but is not as easy as I thought.
I've run the maintenance QT software and I've check if the source was installed.I've created a simple demo project and added this lines inside the .pro
include(C:/Qt/5.14.2/Src/qtserialport/src/serialport/serialport-lib.pri)
I have to add also these lines to resolve some issues
INCLUDEPATH += "C:/Qt/5.14.2/Src/qtbase/include/QtCore/5.14.2/QtCore" INCLUDEPATH += "C:/Qt/5.14.2/Src/qtbase/include/QtCore/5.14.2" INCLUDEPATH += "C:/Qt/5.14.2/msvc2017_64/include/QtCore/5.14.2"
But now, when I compile I get this error:
definition of dllimport static data member not allowed
I think there is something wrong in my approach...
How should i do to debug QSerialPort class?
thank you for your time and your patience. -
I don't understand why you try to compile QSerialPort by yourself. Install the debug symbols and sources, compile your app with debug informations, add a breakpoint on QSP::open() call and step into the call.
-
@Christian-Ehrlicher what you means with "Install the debug symbols and sources"?
I'm in debug with a breakpoint but if try to step into by F11...
-
@addebito said in QSerialPort open error code 10:
what you means with "Install the debug symbols and sources"?
With Maintenance Tool, select "Sources" and "Qt Debug Information Files" for the select Qt Version:
Then build your project in "Debug" and start debugging.
-
@addebito said in QSerialPort open error code 10:
I see only the debugger on line 118 (qflags.h) and after F11 again the debugger return on my mainwindow.cpp.
That's correct since first the flags ctor is called, then hit F11 again to step into the function call.
-
Well, if I'm not mistaken, then thats the error code for an invalid parameter 🤷♂️
What Windows version do you use ? Is it up to date ? The windows Api changes regularly
-
https://docs.microsoft.com/it-it/windows/win32/debug/system-error-codes--0-499-?redirectedfrom=MSDN
Yes, from msdn
87 The parameter is incorrect.What kind of parameters ??
Ohh Windows...
I'm definitely being roasted.Windows 10 home
Auto update activated
QT 5.14.2Any other suggestions?
-
@addebito said in QSerialPort open error code 10:
Any other suggestions?
Build qtserialport from sources (just download the sources, open in QtCreator and re-build all targets, include examples). And then from the QtCreator run the
terminal-example
under the debugger, open your serial port and try to debug as usual.. Then, try to comments-out step-by-step the functions likeqt_set_{common|baudrate...}
, and then re-build qtserialport and try again.. And then you can look wich function brokes the work.For this, you can temporary rename the qtserialportd.dll in your installed Qt path.. In this case will be used another dll compiled in qtserialport build directory (make sure that this directory is in `run environment' PATH of your project settings in QtCreator).
-
Since you can already call CreateFile() simply go further and call GetCommState/SetCommState and set the parameters one by one according to what Qt does and see which one fails. Maybe first try to call SetCommState without modifying the DCB structure at all.
-
@kuzulis I've try to recompile step by step and try with the qt_set_{...} commented-out but... nope I've commented all the 5 lines without good result.
BUT ....unbelievable...
I've try more than one time.
If I run the terminal example under Linux, everything works fine, after that if I restart the computer without power off the board and run Windows instead Linux.... The terminal example works !!!
If I switch OFF and after, switch ON again the board the terminal example under Windows going back to fail !!So, follow step by step my tests
- run my lapton on Linux partition and run the Terminal Example
- Restart the computer, run the Windows partition and run the Terminal Example
- Switch off/on the board, the Terminal example doesn't work.
- If I run Hercules... it's still working
-
@ollarch thank you for your suggestion but doesn't work
Same error:
"Can't open COM5, error code 10" "Parametro non corretto."- I've unistall the COM driver in Windows device manager.
- Unplug the COM in the same USB.
- Windows reinstall the drivers.
- Run my application but doesn't works.
I've tried the same procedure with another USB port.
Now I'm trying the last @Christian-Ehrlicher suggestion.