Results 1 to 1 of 1

Thread: Getting problem in writing command to serial port

  1. #1
    Join Date
    Feb 2014
    Posts
    31
    Thanks
    7
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Post Getting problem in writing command to serial port

    Hello all,
    First of all sorry for my English,,,

    I am biggner in Qt, I have a need to read and write from a QT program to a serial port(fingerprint module r305). I was written code for write and read functions..
    My problem is when i write something to the serial port i need an ack signal to the serial port but nothing is happning.

    And my debug output giving error as "No such process" as shown in below.

    Here is my code...

    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. ui->setupUi(this);
    6. textEdit=ui->textEdit;
    7.  
    8. qDebug() << "Number of serial ports:" << QSerialPortInfo::availablePorts().count();
    9.  
    10. foreach(const QSerialPortInfo &info,QSerialPortInfo::availablePorts())
    11. {
    12. qDebug()<<"Name: "<<info.portName();
    13. port=new QSerialPort(info);
    14.  
    15. qDebug()<<port->open(QIODevice::ReadWrite) <<" ok";
    16. if (!port->open(QIODevice::ReadWrite)) {
    17. qDebug() << "Baud rate:" << port->baudRate();
    18. qDebug() << "Data bits:" << port->dataBits();
    19. qDebug() << "Stop bits:" << port->stopBits();
    20. qDebug() << "Parity:" << port->parity();
    21. qDebug() << "Flow control:" << port->flowControl();
    22. qDebug() << "Read buffer size:" << port->readBufferSize();
    23. } else {
    24. qDebug() << "Unable to open port, error code" << port->error();
    25. qDebug()<< port->errorString();
    26. }
    27. connect(port,SIGNAL(readyRead()),this,SLOT(readData()));
    28. }
    29. }
    30.  
    31.  
    32. void MainWindow::on_pushButton_clicked()
    33. {
    34. writeData("0xEF01FFFFFFFF010003100005");
    35. }
    36.  
    37. void MainWindow::writeData(char *msg)
    38. {
    39. port->write(msg);
    40. qDebug()<<port->errorString();
    41. qDebug() << "Error code:" << port->error();
    42. textEdit->append("writing data:");
    43. textEdit->append(msg);
    44.  
    45. QTimer *timee=new QTimer(this);
    46. timee->start(1000);
    47. port->flush();
    48. }
    49.  
    50. void MainWindow::readData()
    51. {
    52. port->flush();
    53. QString response=port->readAll();
    54. textEdit->append(response);
    55. }
    56.  
    57. void MainWindow::on_pushButton_2_clicked()
    58. {
    59. exit(0);
    60. }
    To copy to clipboard, switch view to plain text mode 

    And my debug output giving error as "No such process" as shown in below.
    Number of serial ports: 1
    Name: "ttyS0"
    true ok
    Baud rate: 9600
    Data bits: 8
    Stop bits: 1
    Parity: 0
    Flow control: 0
    Read buffer size: 0
    "No such process"
    Error code: 3
    Please help me...and thanks in advance..
    Last edited by anda_skoa; 6th March 2014 at 11:02. Reason: changed [qtclass] to [code]

Similar Threads

  1. qext-serial-port write problem.
    By rex in forum Qt Programming
    Replies: 11
    Last Post: 9th December 2013, 08:18
  2. Replies: 12
    Last Post: 19th July 2012, 22:22
  3. Reading/writing a serial port through USB
    By jvwlong in forum Newbie
    Replies: 2
    Last Post: 28th June 2012, 12:09
  4. QT to Android serial port API problem?
    By eddis in forum Newbie
    Replies: 5
    Last Post: 5th January 2012, 01:09
  5. Serial Port Reading problem
    By sfabel in forum Qt Programming
    Replies: 12
    Last Post: 18th February 2010, 15:59

Tags for this Thread

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.