Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Open same QSerialPort twice
Forum Updated to NodeBB v4.3 + New Features

Open same QSerialPort twice

Scheduled Pinned Locked Moved Solved Mobile and Embedded
11 Posts 3 Posters 1.2k 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.
  • H Offline
    H Offline
    huseyinkozan
    wrote on last edited by
    #1

    Hi,

    How can I open same serial port twice ? One for read, one for write ?

    When I tried, got Permission error while locking the device error which is defined here.

    J.HilkJ 1 Reply Last reply
    0
    • H huseyinkozan

      Hi,

      How can I open same serial port twice ? One for read, one for write ?

      When I tried, got Permission error while locking the device error which is defined here.

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

      @huseyinkozan
      you can't thats a limitation from the operation system


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

        Thanks for the reply.

        My target OS is embedded Linux, maybe we should move the topic to embedded.

        The problem is, my writing thread is a real-time and should not stopped background read operations. Should I try low level serial ?

        J.HilkJ 1 Reply Last reply
        0
        • H huseyinkozan

          Thanks for the reply.

          My target OS is embedded Linux, maybe we should move the topic to embedded.

          The problem is, my writing thread is a real-time and should not stopped background read operations. Should I try low level serial ?

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

          @huseyinkozan what kind of embedded linux are we talking here? RTLinux?

          Because when your Linux is not realtime, your writing thread will not be realtime either!


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

            @J-Hilk Yep, using custom RT patched image at Toradex Colibri imx6. Its real time and write thread works for a long time.

            J.HilkJ 1 Reply Last reply
            0
            • H huseyinkozan

              @J-Hilk Yep, using custom RT patched image at Toradex Colibri imx6. Its real time and write thread works for a long time.

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

              @huseyinkozan Ok, I'm most certainly out of my depths here than :D

              Maybe the OS offer some low level serial port access that would allow parallel access to it. But I don't know where to look 😬


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

                Found this, and mentions about two different threads can use it.

                It seems I cannot go further with QSerialPort, bacause it have a lock file implementation.

                Thanks anyway

                KroMignonK 1 Reply Last reply
                2
                • H huseyinkozan

                  Found this, and mentions about two different threads can use it.

                  It seems I cannot go further with QSerialPort, bacause it have a lock file implementation.

                  Thanks anyway

                  KroMignonK Offline
                  KroMignonK Offline
                  KroMignon
                  wrote on last edited by
                  #8

                  @huseyinkozan said in Open same QSerialPort twice:

                  It seems I cannot go further with QSerialPort, bacause it have a lock file implementation.

                  I've done many embedded software development (with or without realtime OS), I my eyes sharing a serial port between several threads is not a good idea.
                  There should only be one thread which handle the serial port and this thread could then implement sharing of this resources.
                  This is, according to my experience, the best way to share a serial port.

                  My 2 cts.

                  It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                  H 1 Reply Last reply
                  5
                  • KroMignonK KroMignon

                    @huseyinkozan said in Open same QSerialPort twice:

                    It seems I cannot go further with QSerialPort, bacause it have a lock file implementation.

                    I've done many embedded software development (with or without realtime OS), I my eyes sharing a serial port between several threads is not a good idea.
                    There should only be one thread which handle the serial port and this thread could then implement sharing of this resources.
                    This is, according to my experience, the best way to share a serial port.

                    My 2 cts.

                    H Offline
                    H Offline
                    huseyinkozan
                    wrote on last edited by
                    #9

                    @KroMignon Thanks for the advice.

                    I know there is some hardware limitations about UART configuration, and I am considering that.

                    My target device requires 2msec aligned data, thus I am using a derived SerialPort class with customized writeData().

                    On the receiving side, I have another device which is transmitting data with same communication options.

                    The data incoming and outgoing is unrelated to each other.

                    I do not see any drawbacks. Do you have any suggestions with these conditions ?

                    KroMignonK 1 Reply Last reply
                    0
                    • H huseyinkozan

                      @KroMignon Thanks for the advice.

                      I know there is some hardware limitations about UART configuration, and I am considering that.

                      My target device requires 2msec aligned data, thus I am using a derived SerialPort class with customized writeData().

                      On the receiving side, I have another device which is transmitting data with same communication options.

                      The data incoming and outgoing is unrelated to each other.

                      I do not see any drawbacks. Do you have any suggestions with these conditions ?

                      KroMignonK Offline
                      KroMignonK Offline
                      KroMignon
                      wrote on last edited by KroMignon
                      #10

                      @huseyinkozan said in Open same QSerialPort twice:

                      I do not see any drawbacks. Do you have any suggestions with these conditions ?

                      IMHO Qt is not designed for realtime applications. According to your previous posts, you are using a custom Linux kernel with RT patches on an i.MX6 CPU.
                      My way to do this would be to customize the UART driver to handle there the 2ms "window". On driver side, with RT patch, this should be much easier to do, compared to userland level.
                      And made the UART/driver buffers (transmission and reception) available via /proc/ virtual file system, so you could handle transmission/reception via shell commands to test.

                      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                      H 1 Reply Last reply
                      4
                      • KroMignonK KroMignon

                        @huseyinkozan said in Open same QSerialPort twice:

                        I do not see any drawbacks. Do you have any suggestions with these conditions ?

                        IMHO Qt is not designed for realtime applications. According to your previous posts, you are using a custom Linux kernel with RT patches on an i.MX6 CPU.
                        My way to do this would be to customize the UART driver to handle there the 2ms "window". On driver side, with RT patch, this should be much easier to do, compared to userland level.
                        And made the UART/driver buffers (transmission and reception) available via /proc/ virtual file system, so you could handle transmission/reception via shell commands to test.

                        H Offline
                        H Offline
                        huseyinkozan
                        wrote on last edited by
                        #11

                        @KroMignon Thank you very much.

                        1 Reply Last reply
                        0

                        • Login

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