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