bla2447 / qextserialport

Automatically exported from code.google.com/p/qextserialport
Other
0 stars 0 forks source link

Library dont open a port that hasn't been opened first by another program. #122

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
1. Build examples with QT Creator 2.4.1, QT 4.8.0 and mingw.
2. Run any of the examples provided with qextserialport-1.2beta1
3. Try to open COMx, in which a Texas Instruments CC1111 is connected.

The serial port will not open until another program such as putty or 
hyperterminal open it and close first.

But the serialPort->open(QIODevice::ReadWrite) return true.

I'm using Win 7 x64.

Original issue reported on code.google.com by brunoea...@gmail.com on 21 Mar 2012 at 3:50

GoogleCodeExporter commented 8 years ago
Hi brunoeagle,

Related source code located in qextserialport_win.cpp

 http://code.google.com/p/qextserialport/source/browse/src/qextserialport_win.cpp

Open operation can be found in 
{{{
QextSerialPortPrivate::open_sys()
}}}

First, we call the system api CreateFileW() to open the serialport. If the 
handle it returned is not INVALID_HANDLE_VALUE. The port is considered opend, 
and we will return a "true" value.

After the port is opened. we call the system api GetCommState() to get current 
DCB contents, and then do some settings for the DCB struct.

Finally, we use system api SetCommConfig(), push the DCB to system again.(code 
can be found in QextSerialPortPrivate::updatePortSettings() )

From your description, I think that, the default DCB values that we get using 
GetCommState() maybe has something wrong.

Perhaps, your can try to watch the DCB struct in the open_sys() function under 
debug mode.

If you can find the reason, we can fix it soon. :-)

Debao.

Original comment by dbzhang...@gmail.com on 21 Mar 2012 at 8:44

GoogleCodeExporter commented 8 years ago
I had exactly the same issue today.
I got it workin on Win XP SP3 32-bit by adding
Win_CommConfig.dcb.fDtrControl=1; after /*set up parameters*/ in open_sys().

Original comment by jarm...@gmail.com on 22 Mar 2012 at 12:25

GoogleCodeExporter commented 8 years ago
Hi jarmovh,

Thanks for your information. I wonder calling following memeber

    void setDtr(bool set=true);

after we opened the port will work or not, can you try it too?

Regards,

Debao

Original comment by dbzhang...@gmail.com on 22 Mar 2012 at 5:57

GoogleCodeExporter commented 8 years ago
I had the same problem with a version that I download from somewhere that I 
don't remember now: qextserialport-1.2win-alpha... but I don't experiment this 
issue after compile the qextserialport-1.2beta1.tar.gz following the step "How 
to use(3)".

Original comment by fpbo...@gmail.com on 27 Mar 2012 at 11:40

GoogleCodeExporter commented 8 years ago
Callin the setDtr(true) after opening the port seems to work too.

I was originally using qextserialport-1.2win-alpha and had no problems in my 
development environment, but when the software that uses it was deployed to 
another machine the problem occured. After switching to latest release the 
problem occured in my development environment too.

Original comment by jarm...@gmail.com on 2 Apr 2012 at 8:44

GoogleCodeExporter commented 8 years ago

Original comment by dbzhang...@gmail.com on 10 Apr 2012 at 8:27