You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Tuesday, April 3rd 2012, 9:40am

readAll() function of qextserialport caused segmentation fault

Hi,

I need some help.
I am using qexserialport. I got Segmentation fault when I received data. Why?
The segmentation fault is caused by readAll() function.

I used these
settings:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
QextSerialPort*
port = new QextSerialPort("/dev/ttySAC0");

port->flush();port->setBaudRate(BAUD19200);

port->setFlowControl(FLOW_OFF);

port->setParity(PAR_NONE);

port->setStopBits(STOP_1);

port->setDataBits(DATA_8);

port->setTimeout(1000);

if (port->open(QIODevice::ReadWrite) ==
true){} else 
{ }
connect(port, SIGNAL(readyRead()), this,
SLOT(onDataAvailable()));

My function that handles signal is the next:

Source code

1
2
3
4
5
6
7
8
void myclasss:: onDataAvailable(){

QByteArray bytes=port->readAll(); //THIS CAUSES SEGMENTATION FAULT!!!!!!!!!%!!
char *data2 = bytes.data();
QString *var = new QString( data);
ui->lineEdit_2->setText(*var);

}


Thank you.
David

2

Tuesday, April 3rd 2012, 11:10am

I used
QextSerialPort 1.2beta1 from this site
http://code.google.com/p/qextserialport/

There is a small example on their site, but the read function also causes segmentation fault.

So both of read and write cause segmentation fault. But the openning works fine.

What can be wrong? Any kind of idea would be great. :-)

3

Tuesday, April 3rd 2012, 11:23am

I have solved the problem.

4

Thursday, July 12th 2012, 6:37am

Will you share you you get your solution.