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 use syncronous serial port for io and op?
Forum Update on Monday, May 27th 2025

how to use syncronous serial port for io and op?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 342 Views
  • 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.
  • S Offline
    S Offline
    SherifOmran
    wrote on last edited by
    #1

    I am trying to input data from serial port and reply in 30ms only. I need to use a syncronous method to write out the data. I set up the buffer to 1 byte, is it correct?
    but when i receive the data and write it out, it seems it is not in the given time frame.

    Is there a special setting in QSerial ? i based my app on the terminal application ..

    jsulmJ aha_1980A 2 Replies Last reply
    0
    • S SherifOmran

      I am trying to input data from serial port and reply in 30ms only. I need to use a syncronous method to write out the data. I set up the buffer to 1 byte, is it correct?
      but when i receive the data and write it out, it seems it is not in the given time frame.

      Is there a special setting in QSerial ? i based my app on the terminal application ..

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @sherifomran said in how to use syncronous serial port for io and op?:

      I need to use a syncronous method to write out the data

      You don't have to. You can use a QTimer with 30ms timeout and in the slot write...

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • S Offline
        S Offline
        SherifOmran
        wrote on last edited by
        #3

        may be you misunderstood me, i am receiving a data (live) online and i must reply as fast as i receive the data. But when i write, i see it is not fast enough.

        J.HilkJ 1 Reply Last reply
        0
        • S SherifOmran

          may be you misunderstood me, i am receiving a data (live) online and i must reply as fast as i receive the data. But when i write, i see it is not fast enough.

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @sherifomran
          if you write to your serial port in the slot connected to readyRead, than that is as fast as it possibly can be.

          Can you show your read and write functions?


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          4
          • S SherifOmran

            I am trying to input data from serial port and reply in 30ms only. I need to use a syncronous method to write out the data. I set up the buffer to 1 byte, is it correct?
            but when i receive the data and write it out, it seems it is not in the given time frame.

            Is there a special setting in QSerial ? i based my app on the terminal application ..

            aha_1980A Offline
            aha_1980A Offline
            aha_1980
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @sherifomran Such hard requirements are usually hard to satisfy on a non real-time operating system.

            Even if you handle the incoming bytes as fast as possible, the operating system may still delay the write. Sometimes it helps to flush() the output buffer after write.

            And one tip: use a "real" serial port, no USB-serial converter. These usually have further delay times, as USB is polled, not interrupt driven.

            I set up the buffer to 1 byte, is it correct?

            That heavily depends on the protocol you want to transmit.

            Regards

            Qt has to stay free or it will die.

            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