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

Queue send frames in synchronous serial comm

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 584 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.
  • D Offline
    D Offline
    Damian7546
    wrote on 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 ?

    SGaistS 1 Reply Last reply
    0
    • D Damian7546

      @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);

      }

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #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

        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 ?

        SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on 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
        2
        • SGaistS SGaist

          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 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 ?

          jsulmJ 1 Reply Last reply
          0
          • D Damian7546

            @SGaist and exactly like this:

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

            do i need to declare my struct, right ?

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on 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
            2
            • jsulmJ jsulm

              @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 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);

              }

              JonBJ 1 Reply Last reply
              0
              • D Damian7546

                @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);

                }

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #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

                • Login

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