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 - receives data only, after port was first opened in other terminal-like application
QtWS25 Last Chance

QExtSerialPort - receives data only, after port was first opened in other terminal-like application

Scheduled Pinned Locked Moved 3rd Party Software
4 Posts 2 Posters 4.1k Views
  • 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
    mih90
    wrote on 19 Jan 2012, 12:48 last edited by
    #1

    Hi, i'm rather new to Qt, and started a project which require a serial port connection, so I downloaded the qextserialport library, and compiled It into the project. It properly connects with the device, but there is a problem when It comes to data receiving. When I start the compiled application, and send data from the device It receives only 1 byte which is 7F in hex (device send string: "KeyA pressed").
    The problem disappears when I start other app for serial port communication, open port on which the device is connected in that app and close It.
    Any ideas what is going on ?
    here is my code for opening serial port :
    @
    serialPort = new QextSerialPort("COM3");
    serialPort->setBaudRate(BAUD115200);
    serialPort->setDataBits(DATA_8);
    serialPort->setParity(PAR_NONE);
    serialPort->setFlowControl(FLOW_OFF);
    serialPort->setStopBits(STOP_1);
    serialPort->setTimeout(500);
    serialPort->setQueryMode(QextSerialPort::EventDriven);
    serialPort->open(QIODevice::ReadWrite | QIODevice::Unbuffered);

    if(serialPort->isOpen())
    {
    ui.statusbar->showMessage("succesfull connected with device..");
    connect(serialPort,SIGNAL(readyRead()),this,SLOT(slot_receive()));
    }
    else ui.statusbar->showMessage("unable to connect with device..");
    @

    and here is slot_receive() function:

    @
    void USARTtest::slot_receive()
    {
    char data[1024];
    int numBytes = serialPort->bytesAvailable();
    int readed = serialPort->read(data,1024);
    data[readed] = '\0';
    ui.textEdit->insertPlainText(QString::number(readed)+"\n");
    //ui.textEdit->insertPlainText(QString(data));
    }
    @

    I'm using the 4.7.0 version of Qt, and QT-eclipse integration.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kuzulis
      Qt Champions 2020
      wrote on 19 Jan 2012, 13:23 last edited by
      #2

      Read "this":http://developer.qt.nokia.com/forums/viewreply/67246/
      Perhaps you change your mind and take another library.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mih90
        wrote on 19 Jan 2012, 13:56 last edited by
        #3

        I didn't hear about that library earlier, I will give it a try :)
        As I see you are one of the developers of that library, so I have a question - does it support the readyRead() signal ? or do I have to manually handle the way I check if there is any incoming data ?

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kuzulis
          Qt Champions 2020
          wrote on 19 Jan 2012, 15:15 last edited by
          #4

          Supported.

          Behavior is "almost completely" copies QAbstractSocket, with all methods, etc.
          All I/O is also buffered and non-blocking.
          See examples in /tests directory.
          In the general, try.

          1 Reply Last reply
          0

          4/4

          19 Jan 2012, 15:15

          • Login

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