Queue send frames in synchronous serial comm
-
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 ?
-
@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,
What is that second parameter ?
In any case, yes you can: use a struct.struct Frame { QByteArray data; uint8 value; }; QQueue<Frame> queueFrameToSend;
-
@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);
-
@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);}
-
@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? -