2
我有使用QSerialPort的應用程序,我的程序執行的最後一件事就是打電話給我closePort功能,看起來像這樣:確保QSerialPort.close在程序執行完成之前完成?
//Closes the port when we're done with it
void SerialCommSession::closePort()
{
connected = false;
if(m_port.isOpen())
{
qDebug() << "closing port";
m_port.close();
}
}
的它工作正常,並且程序再次啓動時沒有了一些時間任何問題。但是可能有75%的時間,當我嘗試再次運行程序時,它無法打開端口,返回錯誤代碼2. QSerialPort.close()需要多長時間才能執行?我怎樣才能確保它完成?