Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Qextserialport crashes
Qt 6.11 is out! See what's new in the release blog

Qextserialport crashes

Scheduled Pinned Locked Moved 3rd Party Software
4 Posts 3 Posters 2.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    martinpetkovic
    wrote on last edited by
    #1

    Hello to everyone

    I made a simple code for communication with a lpc2138 board through com port but my code chrashes after about 10 seconds, I made my code in lpc to send data all the time.
    Here are the source files:

    untitled.pro
    @QT += core gui

    TARGET = untitled
    TEMPLATE = app

    SOURCES += main.cpp
    untitledmainwindow.cpp

    HEADERS += untitledmainwindow.h

    FORMS += untitledmainwindow.ui

    include(C:/Users/Martin/Desktop/qextserialpor/src/qextserialport.pri)@

    main.cpp
    @#include <QtGui/QApplication>
    #include "untitledmainwindow.h"

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

    return a.exec&#40;&#41;;
    

    }
    @

    untitledmainwindow.h
    @#ifndef UNTITLEDMAINWINDOW_H
    #define UNTITLEDMAINWINDOW_H

    #include <QMainWindow>
    #include "qextserialport.h"

    namespace Ui {
    class untitledMainWindow;
    }

    class untitledMainWindow : public QMainWindow
    {
    Q_OBJECT

    public:
    explicit untitledMainWindow(QWidget *parent = 0);
    ~untitledMainWindow();

    private slots:
    void onDataAvailable();

    private:
    Ui::untitledMainWindow *ui;
    QextSerialPort *port;
    };

    #endif // UNTITLEDMAINWINDOW_H@

    untitledmainwindow.cpp
    @#include "untitledmainwindow.h"
    #include "ui_untitledmainwindow.h"

    untitledMainWindow::untitledMainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::untitledMainWindow)
    {
    ui->setupUi(this);

    port = new QextSerialPort("COM9");
    port->setBaudRate(BAUD9600);
    port->setDataBits(DATA_8);
    port->setParity(PAR_NONE);
    port->setFlowControl(FLOW_OFF);
    port->setStopBits(STOP_1);
    port->open(QIODevice::ReadOnly);
    
    connect(port, SIGNAL(readyRead()), this, SLOT(onDataAvailable()));
    

    }

    void untitledMainWindow::onDataAvailable()
    {
    QByteArray data;
    data.resize(1);

    port->read(data.data(), data.size());
    
    ui->lineEdit->setText(data.data());
    

    }

    untitledMainWindow::~untitledMainWindow()
    {
    delete ui;
    }@

    Please help!!

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kuzulis
      Qt Champions 2020
      wrote on last edited by
      #2

      Instead of QextSerialPort try use "QtSerialPort":http://qt-project.org/wiki/QtSerialPort.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        cincirin
        wrote on last edited by
        #3

        I try to adapted your code on my serial port reader. I have no crash, I'm using qextserialport 1.2. In what line stops(crash) your application ?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          martinpetkovic
          wrote on last edited by
          #4

          I made a delay in the lpc code, I send 10 bytes in second, and now its ok.
          Anyway thank you kuzulis and cincirin

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved