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. Queue send frames in synchronous serial comm
Forum Update on Monday, May 27th 2025

Queue send frames in synchronous serial comm

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 489 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.
  • D Offline
    D Offline
    Damian7546
    wrote on 29 Mar 2023, 16:21 last edited by Damian7546
    #1

    Hi,

    I must queued frames to send.

    I am currently doing it as below
    QQueue<QByteArray> queueFrameToSend;

    and adding to queue like below:

    queueFrameToSend.enqueue(sendBuffer);

    It is possible adding two parameter like below:
    queueFrameToSend.enqueue(QByteArray, quint8 );

    How do this ?

    S 1 Reply Last reply 29 Mar 2023, 19:09
    0
    • D Damian7546
      1 Apr 2023, 07:20

      @jsulm In below function I would like to add two parameters to send queue, Now I have like below:

      void MyFunction::transaction(const QByteArray &data,quint8 reqType)
      {
      queueFrameToSend.enqueue(sendBuffer);
      queueType.enqueue(reqType);

      }

      J Offline
      J Offline
      JonB
      wrote on 1 Apr 2023, 08:16 last edited by JonB 4 Jan 2023, 08:18
      #6

      @Damian7546
      I too do not understand what you are still asking. If you want to put a QByteArray and a uint8 into the queue, as a single item, why don't you use the struct approach both @SGaist & @jsulm have suggested? What is the problem with that? You can create the struct in MyFunction::transaction(const QByteArray &data,quint8 reqType) if you wish to retain a function which accepts them as separate parameters.

      If, for some reason, you are asking whether you can have two different typed items in a QQueue, one a QByteArray and another a uint8, then you cannot, what type would the QQueue<...> be?

      1 Reply Last reply
      1
      • D Damian7546
        29 Mar 2023, 16:21

        Hi,

        I must queued frames to send.

        I am currently doing it as below
        QQueue<QByteArray> queueFrameToSend;

        and adding to queue like below:

        queueFrameToSend.enqueue(sendBuffer);

        It is possible adding two parameter like below:
        queueFrameToSend.enqueue(QByteArray, quint8 );

        How do this ?

        S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 29 Mar 2023, 19:09 last edited by
        #2

        Hi,

        What is that second parameter ?
        In any case, yes you can: use a struct.

        struct Frame 
        {
            QByteArray data;
            uint8 value;
        };
        
        QQueue<Frame> queueFrameToSend;
        

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

        D 1 Reply Last reply 31 Mar 2023, 11:37
        2
        • S SGaist
          29 Mar 2023, 19:09

          Hi,

          What is that second parameter ?
          In any case, yes you can: use a struct.

          struct Frame 
          {
              QByteArray data;
              uint8 value;
          };
          
          QQueue<Frame> queueFrameToSend;
          
          D Offline
          D Offline
          Damian7546
          wrote on 31 Mar 2023, 11:37 last edited by Damian7546
          #3

          @SGaist and exactly like this:

          struct Frame 
          {
              QByteArray data;
              quint8 value;
          };
          
          
          Frame myFrame;
          QQueue<myFrame> queueFrameToSend;
          

          do i need to declare my struct, right ?

          J 1 Reply Last reply 31 Mar 2023, 13:16
          0
          • D Damian7546
            31 Mar 2023, 11:37

            @SGaist and exactly like this:

            struct Frame 
            {
                QByteArray data;
                quint8 value;
            };
            
            
            Frame myFrame;
            QQueue<myFrame> queueFrameToSend;
            

            do i need to declare my struct, right ?

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 31 Mar 2023, 13:16 last edited by
            #4

            @Damian7546 said in Queue send frames in synchronous serial comm:

            QQueue<myFrame> queueFrameToSend;

            This is wrong. What @SGaist suggested is correct. I don't know what you're trying to achieve with your invalid C++ code.
            To add a frame to the queue:

            struct Frame 
            {
                QByteArray data;
                uint8 value;
            };
            
            QQueue<Frame> queueFrameToSend;
            
            Frame myFrame;
            queueFrameToSend.enqueue(myFrame);
            

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

            D 1 Reply Last reply 1 Apr 2023, 07:20
            2
            • J jsulm
              31 Mar 2023, 13:16

              @Damian7546 said in Queue send frames in synchronous serial comm:

              QQueue<myFrame> queueFrameToSend;

              This is wrong. What @SGaist suggested is correct. I don't know what you're trying to achieve with your invalid C++ code.
              To add a frame to the queue:

              struct Frame 
              {
                  QByteArray data;
                  uint8 value;
              };
              
              QQueue<Frame> queueFrameToSend;
              
              Frame myFrame;
              queueFrameToSend.enqueue(myFrame);
              
              D Offline
              D Offline
              Damian7546
              wrote on 1 Apr 2023, 07:20 last edited by
              #5

              @jsulm In below function I would like to add two parameters to send queue, Now I have like below:

              void MyFunction::transaction(const QByteArray &data,quint8 reqType)
              {
              queueFrameToSend.enqueue(sendBuffer);
              queueType.enqueue(reqType);

              }

              J 1 Reply Last reply 1 Apr 2023, 08:16
              0
              • D Damian7546
                1 Apr 2023, 07:20

                @jsulm In below function I would like to add two parameters to send queue, Now I have like below:

                void MyFunction::transaction(const QByteArray &data,quint8 reqType)
                {
                queueFrameToSend.enqueue(sendBuffer);
                queueType.enqueue(reqType);

                }

                J Offline
                J Offline
                JonB
                wrote on 1 Apr 2023, 08:16 last edited by JonB 4 Jan 2023, 08:18
                #6

                @Damian7546
                I too do not understand what you are still asking. If you want to put a QByteArray and a uint8 into the queue, as a single item, why don't you use the struct approach both @SGaist & @jsulm have suggested? What is the problem with that? You can create the struct in MyFunction::transaction(const QByteArray &data,quint8 reqType) if you wish to retain a function which accepts them as separate parameters.

                If, for some reason, you are asking whether you can have two different typed items in a QQueue, one a QByteArray and another a uint8, then you cannot, what type would the QQueue<...> be?

                1 Reply Last reply
                1
                • D Damian7546 has marked this topic as solved on 4 Apr 2023, 07:12

                1/6

                29 Mar 2023, 16:21

                • Login

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