Hello, welcome back.
In this lesson, we're going to see how to use cues, cues will be used to transfer data from one task
to another or from a task to an interrupt service routine or from the interrupt service routine to a
task.
Basically, you can think of cues, US message boxes that you can use to transmit a piece of information
from a task to another task.
OK, I'm going to make a copy of one of our simplest project, O Select.
Maybe project number four over here, TASC Priorities, copy and paste.
And then I call this number 14.
Working with Kyuss.
Nick.
Where is it this is it, number 14, open this.
May not see it over here.
I'm going to.
I'm going to clean what we have, yeah.
I'm going to clean our task Croatian.
So that we start from scratch, we'll be using different tasks.
Yeah, OK, so in this experiment, we're going to have two tasks, the sender and the receiver.
The sender is going to send something and we expect to receive it from the receiver.
OK, one other thing we have to do is.
We have to include cues to our project.
Let me show you what I mean.
Let's come to free to see over here.
In here you see we have task that H included.
We have to include tutorage to have access to the cube APIs to also include over here.
And task not is included because when we created the very first project from Cuba, makes a default
task was included to a project, that is why we have this already included for us.
So our security over here.
Like this.
OK, so now I'll come over here, like I said, we're going to have two tasks.
Oh, just put your prototypes here.
We're going to have the task function.
We're going to have one called.
Send the task.
And we know the nature of the task function, it takes one argument, which is a pointer, and we often
call that PVG parameters.
You can call it whatever you want.
And then I'm going to copy this and then I'll paste this over here and then I'll call this receiver
task.
OK, and I'm going to create Taj condos as well.
I'll say TASC.
No, take over here and then.
I say send a home to.
Then receive a Honda
like this, OK, once that is done, I'm going to come over here and I'm going to create a queue, I'll
come over here and then to create a queue, we create a Honda for it.
We going to when we create the queue, the queue is going to return a handle and is from the Honda that
we can use to send and receive data from the queue or to access the queue.
OK, so secu Honda just like we have type Honda type the rescue Honda type Q handwrote over here.
We're going to call this year queue.
Let's see this queue starts the.
Yes.
Are we spelling you correctly?
Yeah, tops, correct.
OK, so once that is done, I'm going to come in here and the first thing I'll do is create a queue,
right?
So to create a Q we used to Q create function.
This function takes two arguments.
The first argument is the length of the Q and the second argument is the is the the item size of the
Q and the item size is basically based on the length of the Q.
Let me show you what I mean.
I'm going to see Q Execute, create.
That's the name of the function, execute, create over here and I'm going to pass.
I'm going to pass, I want five elements and what is the size of the queue?
Well, it's going to be size of.
The size of each item, so the second argument is the size of each item.
Sorry, the second argument is the size of each item of the queue.
So the items will be of size you in to.
OK, so and this will return to Hondo, which we shall store here.
OK, so this will we end up with, right, and then once this is done, we're going to go ahead to create
our Task X task, create.
And the first argument is the task function, so I'm going to start off with this is the task.
And then the second argument is the name of the task, which is simply a string.
Then following that, the stock going to give it a stock of one hundred and then following that.
The the next document is the task parameter.
We do not have a parameter and then the task handle what we want to study under the priority, first,
I'm given that priority of one.
And then finally, Dindo, I want to store this in the hand of variable.
We created.
So past the address here.
Like this.
OK, then I'm going to copy this.
And paste this over here and I'll rename this to receive a task, the task function becomes receive
a task over here and this word here becomes a receiver and then the handler here becomes receiver Hondo
over here like this.
OK, so we've created our tasks.
We have to implement the task functions.
And then before we forget, we've got to start our scheduler.
So I'll see if the task starts.
Scheduler.
Like this, OK, so I'm going to implement these tasks, I'll copy them.
Push them over here, the first one open and close, the second one open and close, because it's a
task I'm going to give the infinite loop in here like this open and close and then here as well.
Open and close.
OK, that looks good, so I'm going to come over here and I'm going to, you know, Ascender, we're
going to create a number of local variables.
One, to hold the data we wish to to send and another one would hold the status.
So I'll come over here and then into 30 to underscore.
OK, you know, see value to send.
Let's say we wish to send a year 2015 over there and then I'm going to have a base type, yeah, this
will give us the status of the Q based type unaskable t, I'll call this huge status.
Okay.
So to send we have to we have to use the Q Senate function, this function takes three arguments.
The first argument is the handle of the Q that you want to send to.
The second argument is the value you want to send.
And the third argument is like the timeout.
How long do you want to wait?
OK, so I'm going to come over here and say, excuse, send and then send here has to be capital.
Q requires an equal right here.
The first document, the name of our Q is the Yaku over here controversy.
You page this over here.
The value to send this is what we want.
Is it going to pass this Ambersons sign here?
Why did you send time out?
We're going to pass you here and this will retain the status and I'm going to store it in our Q status
variable here, OK?
So this argument, like I said, it's the time out, so this is the maximum amount of time we want the
the queue to wait in the blocked states.
For data to be for space to become available in it, so should in case the cubie be full, should in
case there is no space in the queue, we want to wait for X amount of time.
For space to be available so that we can send this new piece of data, but when we put zero here, it's
as if put zero here means we do not want to wait at all.
This will return immediately as it detects that the queue is full in a similar way.
We can put a time value here.
We can pass wait for 50 VMS or 250 times, etc. but we pass in zero, meaning just return when it's
full.
You need no wait.
OK, so that's what that means.
And then so we've, we've sent this, we return this.
We can use this to check whether it was successful.
So we're going to see if it is successful or not.
So I'm going to see if queue status.
It's not equal to you, please pass, please pass is like true, this is defined in free ARTUS.
So this is simply a saying.
If it's not equal to true, then we want to make use of our printf say printf over here erro perhaps
we can see data could not be sent.
Then I return you line over here.
Right, and we can put a bit of delay here or see for over here.
And I equals zero, I is less than 100000 a plus plus European, and we close over here like this.
OK, so this descender, how about a receiver over here in the receiver?
We're going to have a number of local variables, too.
I'm going to have INT 32 that escort and this is going to be value received.
This is where we will store what we receive and then we're going to have we're going to allow the receiver
to wait.
So I'm going to create a hundred times over here by calling our PDM Static's.
So I see a constant over here.
Constance.
To type Scottie.
And then I say, wait time over here, which time over here, I'm going to say this because CDMs.
To takes.
What we want to do is say we passed 100 here, in a sense, we end up with one hundred is which time.
So over here to receive we used a Q receive excuse function.
The first document of this function is the Q handle the Q the handle to the Q from which we want to
receive.
The second argument is where to start to receive data.
And the third argument is how long to wait the time out value.
So I'm going to say X.
Excuse receive over here, the first argument is the Q name.
Q Hondo Yaku, it is called Okay.
And the next argument is where to store it.
We store in it and received value over here.
Okay.
And then.
And then the final arguments this week's time.
OK, and this is going to return a status which we can declare.
I'm going to do what I did here based type.
We're going to declare a base type here to hold this Q status here.
And over here, we can print.
Well, we received.
We can see if it is.
If it's received, we can check for base status what is true or not, and then print something or.
If it is false, we do not print something OK, over here, I can see.
I can see if you.
If Cubase excuse, that is.
Of course, pass, then we can print what we received print off.
We said the value received is.
Percentage of I hear.
One, two, three, carriage return, new line, then we want to do is pass our volume here, value
received.
Okay.
Then we can have an air condition here and over here, we can say printf.
Good to see error could not receive.
Here, Aero Club.
Could not receive.
OK.
So we're looking good.
Let's build and see what we have.
Click over here to build.
We have three arrests.
OK.
I see what does this one see?
Percentage de.
Aren't we using OK, let's expand here.
Give us the specify it to use.
So we should use Helda.
It's trying to say this is a warning.
So deal with the warnings.
First percentage dhody over here.
Red here implies error.
OK, so it's a yes.
That's cute.
It's not included here.
This makes your spelling of Honda as correct, the spelling is correct, so it's about including our
culotte each.
OK.
OK, OK, so let's see what happened, right?
Remember, we, um, we included our culotte itchin free artist Cifas.
Well, we included it because we saw task that H included here.
But we know what happens if you including the that file.
It's not accessible from other files.
So obviously by including this year, it's not accessible in our mind or Cifas.
So we can include this in our May not H file alcott's culotte H from here, located from here.
And then I would open the not H open declaration and then in here I would include Kittridge.
But I wanted to I want to find out where Task H is included.
Let's see if we are to reach what is in the.
Free artist of the house config Dorridge Portable that each.
OK, OK, let's go back to Main and let's open CMC Storage, we can solve this problem, but I just
want to put it where Task H is rather than playsets.
Anyway, this is CMC Storage.
So Task not exist, CMC Storage.
That is why we have access to the task functions you may not see.
So then we're going to include Kudo over here as well.
No, let's wait and see what we left with.
OK, no error, no warning, we're looking good.
OK.
Right, let's download it onto a board or click over here working with number 14 here.
I say, OK.
And then I'll quick to switch.
I'm going to open Realto, so I select my port, my border region and my ports, I'm going to click
to open it and then I'm going to drop this here a bit.
They're not quick to run.
OK, but as I see, the value received is to 50, so we receive in it.
OK.
Writes.
So those successful.
We're going to stop.
I'm going to play this again and see when I stop this, so we would have to do actually although we
received it, we had a hard fought.
And the reason the reason our Ewart's is not cooperating with us is because of the way it is implemented
here.
There is a huge time out value in this.
You ought to transmit function.
So what are we going to do?
Is we going to we're going to write our own implementation of you are to transmit a simplified version
of you are to transmit where we're going to transmit to use in the data register itself.
And perhaps that would allow the US to function quicker than it is functioning currently.
And we may also want to increase some of its configuration parameters.
Let's see what the board rate is quite high, but we can go higher if we want.
And then the speed.
Yeah, so anyway, we would start off with a Ewart's, we would we would implement a new you are to
function so that where we retargeted to print, if we don't use how you are to transmit, we would use
a simple function that, you know, reads the data register of the other peripheral directly.
OK, so we'll do that in the next lesson.