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. How to send data in QserialPort thread
Forum Updated to NodeBB v4.3 + New Features

How to send data in QserialPort thread

Scheduled Pinned Locked Moved Unsolved General and Desktop
21 Posts 5 Posters 8.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 SGaist

    Then move the complete serial port handling to that thread and communicate information back to the main thread when appropriate but there shouldn't be any need to sleeping or blocking.

    G Offline
    G Offline
    Gokhan
    wrote on last edited by
    #12

    @SGaist Well, how should I communicate with the serial port thread? Signals/Slots or Concurrency? Which better? You say to shouldn't block, but while writing the send buffer, have to wait in order to be writtenBytes. Then how can I check whether it was written a byte?

    G 1 Reply Last reply
    0
    • G Gokhan

      @SGaist Well, how should I communicate with the serial port thread? Signals/Slots or Concurrency? Which better? You say to shouldn't block, but while writing the send buffer, have to wait in order to be writtenBytes. Then how can I check whether it was written a byte?

      G Offline
      G Offline
      Gokhan
      wrote on last edited by
      #13
      This post is deleted!
      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #14

        Please be a bit more patient before bumping your own thread. This is a community forum and people answering here may not live in the same timezone as you.

        Signals/Slots, concurrency has nothing to do with inter thread communication.

        Why do you have to wait when writing to your serial port ?

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

        G 1 Reply Last reply
        1
        • SGaistS SGaist

          Please be a bit more patient before bumping your own thread. This is a community forum and people answering here may not live in the same timezone as you.

          Signals/Slots, concurrency has nothing to do with inter thread communication.

          Why do you have to wait when writing to your serial port ?

          G Offline
          G Offline
          Gokhan
          wrote on last edited by
          #15

          @SGaist Sorry for impatient, I am struggling with this problem for a week.
          To make sure whether really it's written because the receiver has limited receive buffer, also these data will be parsed after that it will send through can bus.

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

            Are you mixing RS232 and CAN ?

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

            G 1 Reply Last reply
            0
            • SGaistS SGaist

              Are you mixing RS232 and CAN ?

              G Offline
              G Offline
              Gokhan
              wrote on last edited by Gokhan
              #17

              @SGaist It's USB-CAN module, so it converts the received data from USB to send can bus. At the same time, it might be data in can bus line and it has to read. It should never miss data even if the line is full(%100) while reading/writing.

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

                These are two different buffers so you should get data even if you are writing something to it.

                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
                1
                • G Offline
                  G Offline
                  Gokhan
                  wrote on last edited by Gokhan
                  #19

                  However, while it's writing, should read the buffer otherwise the line will be bus off and get an error. Unfortunately, because both are in the same thread and shouldn't wait to transfer the data.

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    Gokhan
                    wrote on last edited by
                    #20

                    Well, how can I write data to the serial port when it's in another thread. Is it right method to access directly the writing register? Or Should I use signals/slots?

                    serilPort *serial= new serialPort();
                    
                    serial->write(//data); it's right?
                    
                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #21

                      You can send that using signals and slots or QMetaObject::invokeMethod.

                      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
                      3

                      • Login

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