PDA

View Full Version : QextSerialPort - Segmentation Fault



b1
26th November 2006, 03:00
G'Day,

I have simple program to write to and read from a serial port. The port is opened as "serialPort->open( QIODevice::ReadWrite);" and I am able to send data. (viewed on another PC and serial breakout box).

My problem is trying to read the serial port for any data that comes in. I am using a timer to regularly check the port but the I get a seg fault when checking the "bytesAvailable" (see code). As soon as the code hits that line it seg faults.

Any thoughts would be greatly appreciated.



void Mainscreen::checkPort()
{
qWarning( "checking port..." );
if (serialPort->bytesAvailable() > 0 );
{
qWarning( "emitting signal..." );
emit( dataready() );
}
qWarning( "checked port..." );
}


Thanks, B1.


Edit:
I ran it through Vlagrind and I get an "Use of uninitialised value of size 4" at the same line.

b1
26th November 2006, 06:58
Problem Solved!

I had "QextSerialPort *serialPort;" in the header file and then "QextSerialPort *serialPort = new QextSerialPort( portname1 );" in the source file.

I changed the latter to "serialPort = new QextSerialPort( portname1 );" and it now no longer seg faults.

Now to fix the rest of the code...

B1.