PDA

View Full Version : setting QSerialPort port



saman_artorious
24th April 2013, 16:02
The program crashes when I try to set qserialport instance setting, such as setBaudRate. it causes segmentation fault.


#include "mainwindow.h"
#include <QApplication>

#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>

#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>

QT_USE_NAMESPACE

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();


QSerialPort serial;

QString path;

path.append("/dev/ttyS0");

serial.setBaudRate(QSerialPort::Baud9600);

serial.close();

return a.exec();
}

As my system is Linux, should I use a posix version of the function to open port!
like:

posix_openpt()

i would thank if run the code in your system n see if you get the same segmentation fault when setting port settings.

kuzulis
24th April 2013, 17:35
I did not crash. What am I doing wrong?

PS:
1. Before posting the nonsense, you'd at least have checked that you have causes crash...
2. Also you didn't read documentation and didn't look examples. Otherwise you wouldn't write this nonsense.

I won't answer any more your questions about QtSerialPort.





#include <QApplication>
#include <QMainWindow>
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);

QMainWindow w;
w.show();

QSerialPort serial;

QString path;

path.append("/dev/ttyS0");

serial.setBaudRate(QSerialPort::Baud9600);

serial.close();

return a.exec();
}

saman_artorious
27th April 2013, 06:37
I did not crash. What am I doing wrong?

PS:
1. Before posting the nonsense, you'd at least have checked that you have causes crash...
2. Also you didn't read documentation and didn't look examples. Otherwise you wouldn't write this nonsense.

first of all, this was the exact qt doc. example, I shortened. second, you never have to reply to any post, this is the second time you are replying nonsensely and aggressively to my post. please NEVER EVER REPLY TO MY POSTS.

wysota
27th April 2013, 07:36
I think what kuzulis meant was your statement about posix_openpt().

reasra
9th May 2013, 14:04
I think you have to use QSerialPort as a pointer

I don't have the documentation in front of me, but here's some pseudo code:


QSerialPort *serial;
serial->setName("MYPORT");
serial->open();
serial->setBaudRate(9600);

I distinctly remember the little terminal GUI example that comes with QSerialPort was immensely helpful.

wally123
17th May 2013, 09:45
Hello,


I distinctly remember the little terminal GUI example that comes with QSerialPort was immensely helpful.

agree :)