Results 1 to 4 of 4

Thread: Not reading data from hardware device using qextserialport in Mac OS

  1. #1
    Join Date
    Jul 2012
    Location
    India
    Posts
    33
    Thanks
    10
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Unhappy Not reading data from hardware device using qextserialport in Mac OS

    I included include(src/qextserialport.pri) in my pro file and added src directry to my project

    I created one Dialog(Member to main class) to configure serial port and I popup from main Window an I used the following code in OK button

    Qt Code:
    1. void SerianConnectionDialog::on_btnOK_clicked()
    2. {
    3. if (!port->isOpen()) {
    4. port->setPortName(ui->portBox_2->currentText());
    5. port->open(QIODevice::ReadWrite);
    6. }
    7.  
    8. //If using polling mode, we need a QTimer
    9. if (port->isOpen() && port->queryMode() == QextSerialPort::Polling)
    10. timer->start();
    11. this->accept();
    12. }
    To copy to clipboard, switch view to plain text mode 


    In My main class I concted the ready read of function


    Qt Code:
    1. void MainWindow::connectSerialPort()
    2. {
    3.  
    4. if(QDialog::Accepted== dlg.exec())
    5. {
    6.  
    7.  
    8. this->port= dlg.port;
    9. ui->led->turnOn(port->isOpen());
    10.  
    11. timer->setInterval(40);
    12.  
    13. connect(timer, SIGNAL(timeout()), SLOT(onReadyRead()));
    14. connect(port, SIGNAL(readyRead()), SLOT(onReadyRead()));
    15. }
    16. }
    To copy to clipboard, switch view to plain text mode 

    And I coded to display data in a texedit

    Qt Code:
    1. void MainWindow::onReadyRead()
    2. {
    3. if (port->bytesAvailable()) {
    4. ui->textEdit->moveCursor(QTextCursor::End);
    5. ui->textEdit->insertPlainText(QString::fromLatin1(port->readAll()));
    6. ui->textEdit->insertPlainText(QString::fromLatin1("\n"));
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 


    But not showing any data from device. Any error in my code ?

    The port showing open in Main class but not getting data to textbox
    when I run CoolTerm application it showing the data correctly

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Not reading data from hardware device using qextserialport in Mac OS

    Where do you set the port parameters ?

  3. #3
    Join Date
    Jul 2012
    Location
    India
    Posts
    33
    Thanks
    10
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Not reading data from hardware device using qextserialport in Mac OS

    In a Serial port setting dialog an when the user click on OK button it assign to parent class member

    if(QDialog::Accepted== dlg.exec())
    {


    this->port= dlg.port;
    ui->led->turnOn(port->isOpen());

    timer->setInterval(40);

    connect(timer, SIGNAL(timeout()), SLOT(onReadyRead()));
    connect(port, SIGNAL(readyRead()), SLOT(onReadyRead()));
    }

  4. #4
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Not reading data from hardware device using qextserialport in Mac OS

    I'm asking about : speed, word length, parity.

Similar Threads

  1. Replies: 3
    Last Post: 27th April 2011, 09:27
  2. Problem in reading port using QextSerialPort
    By cutie.monkey in forum Qt Programming
    Replies: 6
    Last Post: 2nd July 2009, 02:07
  3. QextSerialPort with QTimer approch for reading
    By PaceyIV in forum Qt Programming
    Replies: 1
    Last Post: 18th May 2009, 14:33
  4. Replies: 7
    Last Post: 29th August 2008, 10:24
  5. Reading/Writing data from/to usb device
    By yellowmat in forum Newbie
    Replies: 2
    Last Post: 6th March 2006, 13:08

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.