PDA

View Full Version : QExtSerialport reads junk char's through UART first time after booting PC



Askar
3rd November 2012, 06:12
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.


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);

if(Pc_ACR_Commn.open(QIODevice::ReadWrite))
{
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.

kuzulis
3rd November 2012, 13:32
Try QtSerialPort (http://qt-project.org/wiki/QtSerialPort)

Askar
5th November 2012, 05:20
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.

Lesiok
5th November 2012, 07:08
Most likely some control signals (CTS,RTS,DTR,DSR) have incorrect state.

Askar
5th November 2012, 14:38
yes .. checked that ... i have disabled both DTR & RTS

Still same problem..

Lesiok
5th November 2012, 15:34
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.

kuzulis
5th November 2012, 16:07
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.

yusufkhan2301
11th November 2014, 09:40
Thanks Very Much
I was configuring it first then opening it.
But it was Vice Verca.