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 ?
-
@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 aQByteArrayand auint8into the queue, as a single item, why don't you use thestructapproach both @SGaist & @jsulm have suggested? What is the problem with that? You can create thestructinMyFunction::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 aQByteArrayand 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;@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);@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);}
@Damian7546
I too do not understand what you are still asking. If you want to put aQByteArrayand auint8into the queue, as a single item, why don't you use thestructapproach both @SGaist & @jsulm have suggested? What is the problem with that? You can create thestructinMyFunction::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 aQByteArrayand another auint8, then you cannot, what type would theQQueue<...>be? -
D Damian7546 has marked this topic as solved on