Results 1 to 12 of 12

Thread: Qextserial on debian linux and readyRead slot

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2013
    Posts
    7
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Qextserial on debian linux and readyRead slot

    Some advance:

    Is it true I need to use connect before I open the port? In terminal example does this.
    I tried to this, and in open I get an error: "No such file or direcory". I tried /dev/ttyUSB0 and ttyUSB0 too.

    Qt Code:
    1. PacketDriver::PacketDriver(const QString& cfgPrefix)
    2. : mFifo(cfgPrefix)
    3. {
    4. mSerialPort = new QSerialPort(this);
    5.  
    6. connect(mSerialPort, SIGNAL(error(QSerialPort::SerialPortError)), this, SLOT(error()));
    7. connect(mSerialPort, SIGNAL(readyRead()), this, SLOT(onReadyRead()));
    8.  
    9. mSerialPort->setPortName("/dev/ttyUSB0");
    10.  
    11. if (!mSerialPort->open(QIODevice::ReadWrite))
    12. log_exception(PacketDriverException, "cannot open /dev/ttyUSB0");
    13.  
    14. if (!mSerialPort->setBaudRate(921600))
    15. log_exception(PacketDriverException, "cannot set baud 921600");
    16.  
    17. if (!mSerialPort->setDataBits(QSerialPort::Data8))
    18. log_exception(PacketDriverException, "cannot set databits 8");
    19.  
    20. if (!mSerialPort->setParity(QSerialPort::NoParity))
    21. log_exception(PacketDriverException, "cannot set noparity");
    22.  
    23. if (!mSerialPort->setStopBits(QSerialPort::OneStop))
    24. log_exception(PacketDriverException, "cannot set one stopbits");
    25.  
    26. if (!mSerialPort->setFlowControl(QSerialPort::NoFlowControl))
    27. log_exception(PacketDriverException, "cannot set noflow");
    28. }
    29.  
    30. void PacketDriver::error()
    31. {
    32. QString err=mSerialPort->errorString();
    33. std::cout<<"Error:"<<err.toStdString()<<std::endl;
    34. }
    35.  
    36. void PacketDriver::onReadyRead()
    37. {
    38. std::cout<<"dataAvailable";
    39. if (mSerialPort->bytesAvailable()) {
    40. QByteArray bytes = mSerialPort->readAll();
    41. std::cout<<", bytes:"<<bytes.length()<<std::endl;
    42. readChar(bytes);
    43. }
    44. }
    To copy to clipboard, switch view to plain text mode 

    Could I debug into QtSerial?

    thx
    Zamek

  2. The following user says thank you to zamek42 for this useful post:


Similar Threads

  1. Replies: 0
    Last Post: 1st August 2011, 13:06
  2. QtIOCompressor fix for Mac (Debian Linux?)
    By qdm in forum Qt Programming
    Replies: 0
    Last Post: 23rd June 2010, 02:17
  3. Replies: 1
    Last Post: 1st November 2007, 14:09
  4. Look and Feel on Debian Linux
    By Krish_ng in forum Qt Programming
    Replies: 1
    Last Post: 24th July 2007, 09:11
  5. QT4 minimum requirements Debian GNU/Linux Sarge
    By Everall in forum Installation and Deployment
    Replies: 10
    Last Post: 21st February 2006, 12:21

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
  •  
Qt is a trademark of The Qt Company.