QExtSerialport reads junk char's through UART first time after booting PC
Hi all,
I'm having trouble in reading data through serialport using QExtSerialPort. Now i'm working for microcontroller - PC communication through serial port.
The case is, if i booted my PC (WinXp) when i tried to read data through serial port using QExtSerialPort it reads junk char's repeatedly, but if i tried to read the same in Hyperterminal (or) SIOW software it reads properly.
After using Hyperterminal or SIOW to read data one time, my program (using same QExtSerialPort code)also reads the data properly (same program).
settings are all same on both ends.
Code:
bool ACR_UARTCOMM
::serialPortInit(QString portname
) {
if(Pc_ACR_Commn.isOpen())
{
return true;
}
else
{
Pc_ACR_Commn.setPortName(portname);
Pc_ACR_Commn.setBaudRate(BAUD9600);
Pc_ACR_Commn.setDataBits(DATA_8);
Pc_ACR_Commn.setParity(PAR_NONE);
Pc_ACR_Commn.setStopBits(STOP_1);
Pc_ACR_Commn.setFlowControl(FLOW_OFF);
{
return true;
}
else
{
QMessageBox::critical(0,
"Error",
"Error while opening port " + portname
);
return false;
}
}
}
Friends help me sort out this problem where im doing wrong.
Re: QExtSerialport reads junk char's through UART first time after booting PC
Re: QExtSerialport reads junk char's through UART first time after booting PC
Sorry i forgot to mention.. I have tried QSerialPort (QSerialDevice) also... result is same...
Also i tried to debug the data transaction between both ends using serialport monitor software, that software also reads same junk char's if i tried to transmit or receive data through Qt.
but the same software reads correct data if i tried to send/receive data through hyperterminal/SIOW software.
Re: QExtSerialport reads junk char's through UART first time after booting PC
Most likely some control signals (CTS,RTS,DTR,DSR) have incorrect state.
Re: QExtSerialport reads junk char's through UART first time after booting PC
yes .. checked that ... i have disabled both DTR & RTS
Still same problem..
Re: QExtSerialport reads junk char's through UART first time after booting PC
After opening the port (line 18) read potential garbage. You do not know what are the parameters of the port (speed, parity etc.) before programming. If the second side send something on your side will be garbage. The port is still active and supported by the operating system and driver.
I think that Hyperterminal do this for You. This is normal.
Re: QExtSerialport reads junk char's through UART first time after booting PC
Quote:
Sorry i forgot to mention.. I have tried QSerialPort (QSerialDevice) also... result is same...
You are wrong using QtSerialPort! First, need open device, and second - configure it!
Please read documentation.
Re: QExtSerialport reads junk char's through UART first time after booting PC
Thanks Very Much
I was configuring it first then opening it.
But it was Vice Verca.