Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. RS485 Half Duplex Communication
Forum Updated to NodeBB v4.3 + New Features

RS485 Half Duplex Communication

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
17 Posts 5 Posters 2.1k Views 2 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #4

    Which exact version are you using ?
    You did not answer my question about mixing ioctl and QSerialPort.

    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
    • H Offline
      H Offline
      HSKW
      wrote on last edited by
      #5

      Qt version used is 5.9.4
      I didn't get what problem we can get by mixing ioctl and QSerialPort? And how we would be able to make same configuration as done using ioctl with QSerialPort.

      SGaistS 1 Reply Last reply
      0
      • mrdebugM Offline
        mrdebugM Offline
        mrdebug
        wrote on last edited by
        #6

        In my honest opinion this is not a problem related to QSerialPort. The 485 bus uses the enable (sometimes called direction) signal to write or read from bus.
        When that signal is not managed directly by the 485 transiver we normally write a kernel driver so, after that, everithing has to work perfecly.
        I suggest you to check who and how is managing the enable signal.
        After that some devices make an echo in the bus to manage the anticollision feature.
        If you send something and after that you receive back the same row of bytes that means that none has disturbed the comminication. If you receive a byte row different from that you have trasmit, that meas that someone in the bus has disturb the communication so you have to resend.

        Need programmers to hire?
        www.labcsp.com
        www.denisgottardello.it
        GMT+1
        Skype: mrdebug

        H 1 Reply Last reply
        1
        • H HSKW

          Qt version used is 5.9.4
          I didn't get what problem we can get by mixing ioctl and QSerialPort? And how we would be able to make same configuration as done using ioctl with QSerialPort.

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #7

          @HSKW said in RS485 Half Duplex Communication:

          Qt version used is 5.9.4
          I didn't get what problem we can get by mixing ioctl and QSerialPort? And how we would be able to make same configuration as done using ioctl with QSerialPort.

          The problem is not the mixing but how your are doing it. You're opening the same file twice so there might things that might get lost in between. You should open it with QSerialPort and then use the handle that it provides to call your ioctl.

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

          H 1 Reply Last reply
          1
          • mrdebugM mrdebug

            In my honest opinion this is not a problem related to QSerialPort. The 485 bus uses the enable (sometimes called direction) signal to write or read from bus.
            When that signal is not managed directly by the 485 transiver we normally write a kernel driver so, after that, everithing has to work perfecly.
            I suggest you to check who and how is managing the enable signal.
            After that some devices make an echo in the bus to manage the anticollision feature.
            If you send something and after that you receive back the same row of bytes that means that none has disturbed the comminication. If you receive a byte row different from that you have trasmit, that meas that someone in the bus has disturb the communication so you have to resend.

            H Offline
            H Offline
            HSKW
            wrote on last edited by
            #8

            @mrdebug
            Can you please explain how we can configure RS485 half duplex using QSerialPort? We searched through Qt documentation, but couldn't find anything.

            Thanks.

            1 Reply Last reply
            0
            • mrdebugM Offline
              mrdebugM Offline
              mrdebug
              wrote on last edited by
              #9

              Hi, QSerialPort manages the rs485 interfaces as a normal full duplex interface. The enable (direction) signal must be manged by the transceiver or by a specific kernel driver.

              Need programmers to hire?
              www.labcsp.com
              www.denisgottardello.it
              GMT+1
              Skype: mrdebug

              1 Reply Last reply
              1
              • SGaistS SGaist

                @HSKW said in RS485 Half Duplex Communication:

                Qt version used is 5.9.4
                I didn't get what problem we can get by mixing ioctl and QSerialPort? And how we would be able to make same configuration as done using ioctl with QSerialPort.

                The problem is not the mixing but how your are doing it. You're opening the same file twice so there might things that might get lost in between. You should open it with QSerialPort and then use the handle that it provides to call your ioctl.

                H Offline
                H Offline
                HSKW
                wrote on last edited by HSKW
                #10

                @SGaist
                Can you please let me know how to set RS485 mode with half duplex by opening with QserialPort and then using the handle for ioctl?

                Also, just an update on the issue:

                1. Yocto BSP with Kernel version 4.1.15, Qt version is 5.9.4
                2. It is observed that after exchanging some packets over RS485, even though Qt application is not sending or receiving anything, still on Docklight(connected to monitor serial communication) 4096 bytes of data (current byte sent - 4096) are seen.
                3. Looking at the signal over logic analyzer, we found that TX_ENABLE line remains high in such a case till these old 4096 bytes are dumped.
                4. We think that somehow kernel driver's TX buffer is getting corrupted and that is getting dumped, causing TX_ENABLE line to remain high.

                Do we know if this as an known issue? Or is our application causing the TX buffer corruption - which we don't think, as we are clearing the buffer before sending data over SErialPort using clear() call and also calling flush() after sending data. Moreover, we always get bytesWritten signal indicating complete bytes written before we send next request.

                any help is highly appreciated.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #11

                  Use the handle returned by QSerialPort::handle to call your ioctls on.

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

                  H 2 Replies Last reply
                  2
                  • SGaistS SGaist

                    Use the handle returned by QSerialPort::handle to call your ioctls on.

                    H Offline
                    H Offline
                    HSKW
                    wrote on last edited by
                    #12

                    @SGaist Thanks we will try this.

                    1 Reply Last reply
                    0
                    • SGaistS SGaist

                      Use the handle returned by QSerialPort::handle to call your ioctls on.

                      H Offline
                      H Offline
                      HSKW
                      wrote on last edited by
                      #13

                      @SGaist Thanks. We tried this approach, but we are still seeing old data getting pushed to serial port and application doesn't get any indication/event for data getting written.

                      1 Reply Last reply
                      0
                      • mrdebugM Offline
                        mrdebugM Offline
                        mrdebug
                        wrote on last edited by mrdebug
                        #14

                        I don't know which is your problem but I assure QSerialPort works perfectly, since 5.9 release up to now because I use it in a lot of projects, with half (485) and full duplex interfaces, in Linux, Windows, Mac and imx devices.
                        You should search the problem somewehere.
                        If the behaviour happens only with QSerialPort still the problem is somewhere.
                        If you want to make a test using something else than Qt you could find interesting this:
                        https://github.com/denisgottardello/ComPortServer
                        A console based application to test the serial interface and to convert it in a tcp socket, based on fpc. You shouldn't have problem to use it in you device.

                        Need programmers to hire?
                        www.labcsp.com
                        www.denisgottardello.it
                        GMT+1
                        Skype: mrdebug

                        1 Reply Last reply
                        1
                        • B Offline
                          B Offline
                          Beppe
                          wrote on last edited by
                          #15

                          HI

                          We too have the same problem

                          We use QT 5.7 and instead of using QSerialPort we use open() write() and read()

                          Usually the communication is correct, then suddenly part of the packet is resent or even the same packet many times, in short I have to send nine bytes and instead up to eighty bytes come out.

                          Did you have a solution for this problem?

                          Ciao, Beppe

                          1 Reply Last reply
                          0
                          • hskoglundH Offline
                            hskoglundH Offline
                            hskoglund
                            wrote on last edited by
                            #16

                            Hi, perhaps you could work around the bug by stuffing the data inside packets with a sequence number? So when the same data is randomly retransmitted the receiver can safely discard it because it already has that packet.

                            mrdebugM 1 Reply Last reply
                            0
                            • hskoglundH hskoglund

                              Hi, perhaps you could work around the bug by stuffing the data inside packets with a sequence number? So when the same data is randomly retransmitted the receiver can safely discard it because it already has that packet.

                              mrdebugM Offline
                              mrdebugM Offline
                              mrdebug
                              wrote on last edited by
                              #17

                              QtSerialPort can't resend the same packet automatically. Have the device or the 485 converter support anti collision? This problem sounds like an 485 anti collision behaviour.

                              Need programmers to hire?
                              www.labcsp.com
                              www.denisgottardello.it
                              GMT+1
                              Skype: mrdebug

                              1 Reply Last reply
                              1

                              • Login

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