<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[Solved] QSerialPort close() throws Unknown error]]></title><description><![CDATA[<p dir="auto">Hi,<br />
Im talking with my GSM-Modem with QSerialPort.<br />
At the beginning i do the following:<br />
@QSerialPort* pSerialPort = new QSerialPort(this);@</p>
<p dir="auto">I have a "start()" Funktion within i do this:</p>
<p dir="auto">@pSerialPort-&gt;setPortName(sPortName);</p>
<pre><code>if (pSerialPort-&gt;open(QIODevice::ReadWrite))
{
    if (pSerialPort-&gt;setBaudRate(QSerialPort::Baud19200)
            &amp;&amp; pSerialPort-&gt;setDataBits(QSerialPort::Data8)
            &amp;&amp; pSerialPort-&gt;setParity(QSerialPort::NoParity)
            &amp;&amp; pSerialPort-&gt;setStopBits(QSerialPort::OneStop)
            &amp;&amp; pSerialPort-&gt;setFlowControl(QSerialPort::NoFlowControl))
    {
        connect(pSerialPort, SIGNAL(error(QSerialPort::SerialPortError)), this, SLOT(serialPortError(QSerialPort::SerialPortError)));
        connect(pSerialPort, SIGNAL(readyRead()), this, SLOT(serialRead()));
        stateMaschine(START);
        emit info("GsmCommunication::start(): COM-Schnittstelle erfolgreich initialisiert", GlobalVars::SI_COM_PORT_INIT_OK);
        pSmsCheckTimer-&gt;start();

    }
    else
    {
        emit error("GsmCommunication::start(): Kann COM-Schnittstelle nicht initialisieren");
    }
}
else
{
    emit error("GsmCommunication::start(): Kann COM-Schnittstelle nicht oeffnen");
}@
</code></pre>
<p dir="auto">I have a "stop()"-function within i do this:</p>
<p dir="auto">@pSerialPort-&gt;clear();<br />
pSerialPort-&gt;close();@</p>
<p dir="auto">And i have a reInit()-function, within i do this:</p>
<p dir="auto">@stop();<br />
start();@</p>
<p dir="auto">Everything works fine, but i get "Unknown error" from QSerialPort when i call my reInit()-Function. Seems like QSerialPort.close() causes the error, why is that?</p>
]]></description><link>https://forum.qt.io/topic/35163/solved-qserialport-close-throws-unknown-error</link><generator>RSS for Node</generator><lastBuildDate>Thu, 24 Sep 2026 15:20:56 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/35163.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 06 Dec 2013 09:58:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [Solved] QSerialPort close() throws Unknown error on Tue, 10 Dec 2013 09:48:52 GMT]]></title><description><![CDATA[<p dir="auto">bq. *ERROR: 0 ErrorString: “Unknown error”</p>
<p dir="auto">This is not an error. Just ignore/skip SerialPortError::NoError error code.. :)</p>
]]></description><link>https://forum.qt.io/post/206890</link><guid isPermaLink="true">https://forum.qt.io/post/206890</guid><dc:creator><![CDATA[kuzulis]]></dc:creator><pubDate>Tue, 10 Dec 2013 09:48:52 GMT</pubDate></item><item><title><![CDATA[Reply to [Solved] QSerialPort close() throws Unknown error on Tue, 10 Dec 2013 09:25:06 GMT]]></title><description><![CDATA[<p dir="auto">I changed my Modification in the terminal example:</p>
<p dir="auto">@void MainWindow::handleError(QSerialPort::SerialPortError error)<br />
{<br />
qDebug() &lt;&lt; "ERROR: " &lt;&lt; error &lt;&lt; "ErrorString: " &lt;&lt; serial-&gt;errorString();<br />
if (error == QSerialPort::ResourceError) {<br />
QMessageBox::critical(this, tr("Critical Error"), serial-&gt;errorString());<br />
closeSerialPort();<br />
}<br />
}@<br />
Now the terminal example shows the following in debugging console:<br />
*ERROR:  0 ErrorString:  "Unknown error" *<br />
Thats exactly the same behaivior as in my Program.</p>
<p dir="auto">The USB-&gt;RS232 converter is type U232-P9 made in Taiwan (-: dont have more information.</p>
<p dir="auto">I will have to read about the Git Version and how to compile it, never heard about that so far.</p>
]]></description><link>https://forum.qt.io/post/206886</link><guid isPermaLink="true">https://forum.qt.io/post/206886</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Tue, 10 Dec 2013 09:25:06 GMT</pubDate></item><item><title><![CDATA[Reply to [Solved] QSerialPort close() throws Unknown error on Tue, 10 Dec 2013 08:46:07 GMT]]></title><description><![CDATA[<p dir="auto">bq. Since then also the terminal-example shows “ERROR: 0”</p>
<p dir="auto">It is NoError.</p>
<p dir="auto">bq. “pSerialPort-&gt;clear()” just before “open()” is called, since then i get the following Error-String</p>
<p dir="auto">It is because your port already closed, so the clear() method can't to be success.</p>
<p dir="auto">bq. USB-&gt;RS232 connector</p>
<p dir="auto">What is connector model?</p>
<p dir="auto">bq. I use the build in Version of QSerialPort in QT 5.1.1</p>
<p dir="auto">Please download and compile the Git version of QtSerialPort and try check again.</p>
<p dir="auto">Also:</p>
<ol>
<li>
<p dir="auto">Please provide a minimal compilable project that reproduce a problem (it is better - console if possible).</p>
</li>
<li>
<p dir="auto">You can try to do debugging himself to help us.</p>
</li>
</ol>
]]></description><link>https://forum.qt.io/post/206882</link><guid isPermaLink="true">https://forum.qt.io/post/206882</guid><dc:creator><![CDATA[kuzulis]]></dc:creator><pubDate>Tue, 10 Dec 2013 08:46:07 GMT</pubDate></item><item><title><![CDATA[Reply to [Solved] QSerialPort close() throws Unknown error on Tue, 10 Dec 2013 07:40:05 GMT]]></title><description><![CDATA[<p dir="auto">Ty for ur answer,<br />
I tried it with the terminal example, i added the following code to see any kind of errors:</p>
<p dir="auto">@void MainWindow::handleError(QSerialPort::SerialPortError error)<br />
{<br />
qDebug() &lt;&lt; "ERROR: " &lt;&lt; error; //I added this line<br />
if (error == QSerialPort::ResourceError) {<br />
QMessageBox::critical(this, tr("Critical Error"), serial-&gt;errorString());<br />
closeSerialPort();<br />
}<br />
}@<br />
Since then also the terminal-example shows "ERROR:  0", but not as I thought when close() is called, it appears when I click the "connect" button, also in my Program it appears in my start() function. I added "pSerialPort-&gt;clear()" just before "open()" is called, since then i get the following Error-String:<br />
"Das Handle ist ungültig." Which i would translate in english as "The Handle is not valid". Without the clear() its "Unknown Error".</p>
<p dir="auto">The OS is Microsoft Windows 7 32bit.<br />
The Device is a CT63 GSM-Modem conneted with a USB-&gt;RS232 connector.<br />
I use the build in Version of QSerialPort in QT 5.1.1<br />
(#include &lt;QtSerialPort/QSerialPort&gt;)<br />
I fixed the issue of wrong placed connect(), but that doesnt appear to make any changes.</p>
]]></description><link>https://forum.qt.io/post/206872</link><guid isPermaLink="true">https://forum.qt.io/post/206872</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Tue, 10 Dec 2013 07:40:05 GMT</pubDate></item><item><title><![CDATA[Reply to [Solved] QSerialPort close() throws Unknown error on Fri, 06 Dec 2013 10:45:25 GMT]]></title><description><![CDATA[<ol>
<li>
<p dir="auto">Can you try it with the Terminal example (from the QtSerialPort package)?<br />
I mean just do clicks to the "connect" and "disconnect" buttons.</p>
</li>
<li>
<p dir="auto">What OS is used?</p>
</li>
<li>
<p dir="auto">What model of modem is used (what is device)?</p>
</li>
<li>
<p dir="auto">What version of QSerialPort you use? From the Git?</p>
</li>
<li>
<p dir="auto">The QObject::connect should be done once after creation of the QSerialPort's object, like:</p>
</li>
</ol>
<p dir="auto">@<br />
QSerialPort* pSerialPort = new QSerialPort(this);</p>
<p dir="auto">connect(pSerialPort, SIGNAL(error(QSerialPort::SerialPortError)),<br />
this, SLOT(serialPortError(QSerialPort::SerialPortError)));</p>
<p dir="auto">connect(pSerialPort, SIGNAL(readyRead()), this, SLOT(serialRead()));<br />
@</p>
]]></description><link>https://forum.qt.io/post/206537</link><guid isPermaLink="true">https://forum.qt.io/post/206537</guid><dc:creator><![CDATA[kuzulis]]></dc:creator><pubDate>Fri, 06 Dec 2013 10:45:25 GMT</pubDate></item></channel></rss>