Queue send frames in synchronous serial comm
-
wrote on 29 Mar 2023, 16:21 last edited by 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 ?
-
@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);}
wrote on 1 Apr 2023, 08:16 last edited by JonB 4 Jan 2023, 08:18@Damian7546
I too do not understand what you are still asking. If you want to put aQByteArray
and auint8
into the queue, as a single item, why don't you use thestruct
approach both @SGaist & @jsulm have suggested? What is the problem with that? You can create thestruct
inMyFunction::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 aQByteArray
and another auint8
, then you cannot, what type would theQQueue<...>
be? -
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 ?
Hi,
What is that second parameter ?
In any case, yes you can: use a struct.struct Frame { QByteArray data; uint8 value; }; QQueue<Frame> queueFrameToSend;
-
Hi,
What is that second parameter ?
In any case, yes you can: use a struct.struct Frame { QByteArray data; uint8 value; }; QQueue<Frame> queueFrameToSend;
wrote on 31 Mar 2023, 11:37 last edited by 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 ?
-
@SGaist and exactly like this:
struct Frame { QByteArray data; quint8 value; }; Frame myFrame; QQueue<myFrame> queueFrameToSend;
do i need to declare my struct, right ?
@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);
-
@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);
wrote on 1 Apr 2023, 07:20 last edited by@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);}
-
@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);}
wrote on 1 Apr 2023, 08:16 last edited by JonB 4 Jan 2023, 08:18@Damian7546
I too do not understand what you are still asking. If you want to put aQByteArray
and auint8
into the queue, as a single item, why don't you use thestruct
approach both @SGaist & @jsulm have suggested? What is the problem with that? You can create thestruct
inMyFunction::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 aQByteArray
and another auint8
, then you cannot, what type would theQQueue<...>
be? -
1/6