PDA

View Full Version : Qt and COM port access



bnilsson
7th June 2009, 00:29
I am trying to access the Windows COM ports in a QtGui application.
It works if "console" is enabled, but I do not want to have the black window visible along with my QtGui application.
If I disable "console" the serial port communication does not work, I suspect all "stdio" is intercepted by some stub module.

I am using regular Windows programming in my serial com module, and not QIODevice.
I have tried the QExtSerialport class, but it is not working for me, so I have to stick to the platform specific code.

Is there any way to have access to serial ports without "console"?

BN

wysota
7th June 2009, 09:09
Is this really a Qt-related question?

bnilsson
7th June 2009, 10:23
Yes, in my opinion it is, since the result depends on the Qt project settings.
Not using "console" in CONFIG blocks access to the COM port.
(If I could get the QExtSerialport to work, I would not need this)

wysota
7th June 2009, 10:34
But "console" only switches the console subsystem in the compiler. Try disabling the console from Visual Studio settings (if you use VS) and see if the problem persists.

QExtSerialPort uses native serial communication as well so I'm not sure if using QExtSerialPort would change anything. IMO the problem is elsewhere.

bnilsson
7th June 2009, 10:52
Any hint on how to disable console in Visual Studio?
"Help" gives nothing.

bnilsson
7th June 2009, 11:32
I got the QExtSerialport example QESPTA built with VS and it is working with HyperTerminal.
I will try again with this and abandon my own COM port methods for the moment. My problems must be in my usage of the class.
Unfortunately, QESPTA is event driven and this is not supported in the POSIX implementatioin of QExtSerialport, so in my (working) POSIX code I am just using a timer to read and write to/from the port.
Annoying that this implementation works fine in POSIX but not in WIN32, for some reason.
I will have to use completely different code for WIN32 vs. POSIX, so it seems cross platform programming has its limitations.
Thanks for your patience.

wysota
7th June 2009, 12:47
Any hint on how to disable console in Visual Studio?
"Help" gives nothing.

It's somewhere in the compilation options. It's called "console subsystem".

bnilsson
7th June 2009, 14:27
Found it , thanks. It was in Linker/System settings.
Toggling /SUBSYSTEM:CONSOLE and /SUBSYSTEM:WINDOWS also toggles COMport working/not working.
I have no idea wether this is specific to Qt or not.

BN

wysota
7th June 2009, 15:58
It's not specific to Qt. QExtSerialPort works fine without the console subsystem. It has to be something in your code.