Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem on Raspberry PI 2B serial port /dev/ttyAMA0 write timeout
Forum Updated to NodeBB v4.3 + New Features

Problem on Raspberry PI 2B serial port /dev/ttyAMA0 write timeout

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 2.0k 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.
  • J Offline
    J Offline
    joaopagotto
    wrote on 12 Sept 2016, 11:33 last edited by
    #1

    Hello guys.

    I have a problem taking the hair.

    I do not know have gone for it, but what happens is that I made an application that works correctly in Windows , but when port this application in Qt 5.7.1 for Linux using a Raspberry PI 2B and its UART GPIO port.

    It is called /dev/ttyAMA0

    bool NetMaster485::open(const QString &port, qint32 baudRate)
    {
       serialPort.setBaudRate(baudRate);
       serialPort.setDataBits(QSerialPort::Data8);
       serialPort.setParity(QSerialPort::NoParity);
       serialPort.setStopBits(QSerialPort::OneStop);
       serialPort.setFlowControl(QSerialPort::NoFlowControl);
       serialPort.setPortName(port);
    
       return serialPort.open(QIODevice::ReadWrite);
    }
    
       QByteArray tx;
       
       ...
       
       serialPort.write(tx);
       serialPort.flush();
       if ( serialPort.waitForBytesWritten(timeoutTX) ) {
          return true;
       }
       return false; <<<
    

    This aways emit error signal QSerialPort::SerialPortError(TimeoutError)

    1 Reply Last reply
    0
    • J Offline
      J Offline
      joaopagotto
      wrote on 12 Sept 2016, 22:43 last edited by
      #2

      Solved removed flush();

      After:

       serialPort.flush();
         if ( serialPort.waitForBytesWritten(timeoutTX) ) {
      

      Before:

         if ( serialPort.waitForBytesWritten(timeoutTX) ) {
      
      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 13 Sept 2016, 20:15 last edited by
        #3

        Hi,

        Out of curiosity, why are you not using the asynchronous mechanism ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • J Offline
          J Offline
          joaopagotto
          wrote on 13 Sept 2016, 20:39 last edited by
          #4

          Hello friend , I am developing a RS485 communication protocol , and the communication would be the master layer. Ie it need to write on the bus and wait for the slave answer below , if not reply consider timeout . Ie is in a half duplex connection. This will be a free API compatible with Qt , Arduino , Microchip PIC .

          Follow the project on this link:

          https://github.com/JoaoPagotto/Net485

          1 Reply Last reply
          0

          1/4

          12 Sept 2016, 11:33

          • Login

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