Hello, welcome back.
And this lesson, we see how to work with message cues, so we simply make a copy of the last project.
I copy this and I'll paste this over here.
And I call this message Kyuss.
Then we explain this and then we open this.
Made a seat over here.
OK, so like we always do.
Let's go to the documentation and find out what we need to do to create a new message.
Q I'm going to go to our documentation over here.
So we have to go to the queue management section.
Let's see, there is a message queue over here.
So there is a message you create.
Let's click on this and the message to you also has a structure, it takes attributes like we saw for
semaphores, the SEMAFO mutex in the tasks so we can you know, we have to define a structure for us.
Well, let's click on voice message.
You knew the first argument is the message counts.
And then the second argument is the size, the message size, maximum message size invites, it says
over here.
And the third argument is the attributes, whether we are using attributes or not, we can personally,
if we want or we can assign it, we can use one of the message cue attributes members such as a sign
to cue a name.
OK.
So just to be consistent, we're going to define we're going to define an attribute structure for the
message cue to start off.
I'm going to define I'm going to create a variable to hold the message ID, because when we create the
cue is going to return the ID.
We want to store it somewhere so that we can access it.
So I'll create always message cue ID type.
I'll call this MSG covid like this.
OK, once that is done I'm going to create the voice message, cue attribute type and I'm going to call
this MSG cue attributes like this.
And over here we're using just one member in the attribute structure we just given.
It's a name we're using just the name Amber.
OK, so once that is done, we can create the cue by calling our message cue new function and then it's
going to.
It's going to return the idea of the created message, so I'm going to come down here and create a message
for you and the idea is going to be retained and stored here.
This is going to hold five elements.
This the size screen to hold elements of type you in 16.
And this is the attribute we defined up here.
OK, so once that is done, what are we going to do in this experiment is to, um, let's say use the
red.
LCD controller has to send something to the queue and receive it from the blue task.
OK, so.
I'm going to take out our mutex experiment code, this one here.
I'm going to remove it.
And this one here.
OK, so what we're going to do is we agreed to.
Create a variable over here.
Let's see, we said our Q is going to hold you in 16 type, so I'm going to see you in 16.
And then we're going to call this value to send we want to send the year 2050 to the queue.
OK, so then to send we use the always message queue put function to do this.
So I'm simply going to send this by voice message queue put.
This is the one to send to this queue.
So we pass on the idea of the queue here.
Message queue ID.
This is what we want to send.
Over here and then the priority of the message, it's allows us to set priorities and then time out.
OK, let's go to the documentation and find out what we mean by this priority of the message.
Let's see, where are we?
I'm going to click back here so that we can have all the functions.
That's a message you put.
OK, first argument is the message ID.
Pointer to the buffer that contains the data you want to send in a priority and then time out over here,
it says message priority so we can assign priority to the message and then the timeout.
Tynemouth Value O0 in case of Norteños, so we pass in zero for no time.
That's what we have over here.
OK.
So once we've sent this, then we expect to receive this somewhere, we going to use the blue led task
to receive this.
So we're going to declare.
We going to declare two variables here in the blue LCD task.
I'm going to have received message and I'm going to update.
OK, so what I'm going to do is use the OS who has a message to get function to get the message from
the Q The first document is the Q idea of the Q you want to get from the second document over here is
the is the way where you want to store it.
The third argument is the priority and then the last document is the time out.
Over here we say wait forever and once we receive this, it's going to be stored here.
We're going to read it and storage in our data variable and we can print this to our serial port.
I'm making it global, just in case you want to view this and the live expressions, but we can make
this local.
OK, so we still have this because we made a copy of our time, a project.
This can be removed, but I don't want to mess it up, so I'll leave it.
So once we have this, we can print.
We can see the message received is this, and I'll just typecast this to an end to avoid warnings,
so we're simply using message puts and the message you get a squeakier to build.
It's Beurden.
We have one warning.
I see where that is.
Oh, so because we're not using this, OK, so the plan was to view the date or one of the variables
in a watch window.
Since the data is redundant, we can remove the data variable.
OK?
Right.
Let's do it and see a click over here to view it.
To build successfully.
All right, click over here.
I'll see.
Keep us ASTM 30 to.
Double click forty four over here.
And then I'll say, OK, over here.
It's open in.
Click to switch.
Then I'll give space.
And I'll clear what we have over here, open this report, then click to run.
OK, so the message you received is getting this number here, OK, so that is why I think I had the
dates for before because I had tested this.
OK, so to receive it, once we receive from the Buffa, we're going to store it in our variable outdates
variable before we print.
OK.
So over here, I'll simply have a date over here.
And I'll come over here and see when we receive the data storage in the buffer dates because received
message indexer.
Indexer over here.
And this time.
We're going to print dates, this word should be dates, not data.
So.
We print the deeds variable here.
OK, let's see.
Click over here to build.
It's built in to build successfully, and then I'll click to go to the burger.
To in.
Click to switch.
And I'll make way.
Eau Claire, this.
And then a click to run.
That's right, a strange.
OK, let's try to find out where the issue is.
See?
OK.
So we're going to exit this.
Let's see.
Whether we are sending and receiving the right information.
Value to send over here, we send in this.
And then.
A message.
During this year.
And dates and then Prince dates.
To solve this, we can simply make our buffer here global.
I'm going to cut this.
I received a.
And then make Globo over here, we don't need we don't need data anymore, we simply going to print
the contents directly.
Right.
So I'll see print receive.
Message index zero.
I'll type cause this to end, it's already on edge, isn't it?
It's into too.
So we don't need this.
We don't need this.
OK, now let's run and see.
OK, click over here to build.
It's Putin.
It's built successfully and click here to run.
Und.
Let's wait for it.
OK, I'm going to open my cereal port.
And I can see receiving a message receives 20, 50, OK, so this is it, this is how to use message
cues with our Simms's ourselves apps.
So that's all there is.
I'll see you later.
Have a nice day.