1
00:00:00,650 --> 00:00:01,890
Hello, welcome back.

2
00:00:01,910 --> 00:00:09,860
In this lesson, we're going to see how to use cues, cues will be used to transfer data from one task

3
00:00:10,160 --> 00:00:16,220
to another or from a task to an interrupt service routine or from the interrupt service routine to a

4
00:00:16,220 --> 00:00:16,710
task.

5
00:00:16,730 --> 00:00:23,840
Basically, you can think of cues, US message boxes that you can use to transmit a piece of information

6
00:00:23,840 --> 00:00:26,060
from a task to another task.

7
00:00:26,540 --> 00:00:31,160
OK, I'm going to make a copy of one of our simplest project, O Select.

8
00:00:32,560 --> 00:00:37,300
Maybe project number four over here, TASC Priorities, copy and paste.

9
00:00:40,060 --> 00:00:42,910
And then I call this number 14.

10
00:00:45,730 --> 00:00:46,810
Working with Kyuss.

11
00:00:53,060 --> 00:00:53,630
Nick.

12
00:00:55,870 --> 00:00:58,870
Where is it this is it, number 14, open this.

13
00:01:01,650 --> 00:01:03,730
May not see it over here.

14
00:01:04,170 --> 00:01:05,370
I'm going to.

15
00:01:08,690 --> 00:01:10,940
I'm going to clean what we have, yeah.

16
00:01:14,030 --> 00:01:16,490
I'm going to clean our task Croatian.

17
00:01:18,350 --> 00:01:22,910
So that we start from scratch, we'll be using different tasks.

18
00:01:22,940 --> 00:01:30,200
Yeah, OK, so in this experiment, we're going to have two tasks, the sender and the receiver.

19
00:01:31,040 --> 00:01:35,000
The sender is going to send something and we expect to receive it from the receiver.

20
00:01:35,900 --> 00:01:39,080
OK, one other thing we have to do is.

21
00:01:41,460 --> 00:01:46,140
We have to include cues to our project.

22
00:01:46,530 --> 00:01:47,490
Let me show you what I mean.

23
00:01:48,060 --> 00:01:50,910
Let's come to free to see over here.

24
00:01:51,390 --> 00:01:55,050
In here you see we have task that H included.

25
00:01:55,440 --> 00:02:02,460
We have to include tutorage to have access to the cube APIs to also include over here.

26
00:02:06,220 --> 00:02:14,500
And task not is included because when we created the very first project from Cuba, makes a default

27
00:02:14,500 --> 00:02:20,530
task was included to a project, that is why we have this already included for us.

28
00:02:21,070 --> 00:02:23,020
So our security over here.

29
00:02:29,570 --> 00:02:30,260
Like this.

30
00:02:30,800 --> 00:02:35,960
OK, so now I'll come over here, like I said, we're going to have two tasks.

31
00:02:36,530 --> 00:02:38,410
Oh, just put your prototypes here.

32
00:02:39,080 --> 00:02:42,070
We're going to have the task function.

33
00:02:42,080 --> 00:02:43,250
We're going to have one called.

34
00:02:44,800 --> 00:02:45,820
Send the task.

35
00:02:51,180 --> 00:02:57,330
And we know the nature of the task function, it takes one argument, which is a pointer, and we often

36
00:02:57,330 --> 00:02:59,180
call that PVG parameters.

37
00:02:59,190 --> 00:03:00,690
You can call it whatever you want.

38
00:03:02,960 --> 00:03:10,710
And then I'm going to copy this and then I'll paste this over here and then I'll call this receiver

39
00:03:10,710 --> 00:03:11,190
task.

40
00:03:14,340 --> 00:03:17,170
OK, and I'm going to create Taj condos as well.

41
00:03:18,090 --> 00:03:19,110
I'll say TASC.

42
00:03:21,450 --> 00:03:25,470
No, take over here and then.

43
00:03:27,360 --> 00:03:28,530
I say send a home to.

44
00:03:31,000 --> 00:03:33,720
Then receive a Honda

45
00:03:36,990 --> 00:03:45,300
like this, OK, once that is done, I'm going to come over here and I'm going to create a queue, I'll

46
00:03:45,300 --> 00:03:49,940
come over here and then to create a queue, we create a Honda for it.

47
00:03:51,510 --> 00:03:57,060
We going to when we create the queue, the queue is going to return a handle and is from the Honda that

48
00:03:57,060 --> 00:04:00,780
we can use to send and receive data from the queue or to access the queue.

49
00:04:01,650 --> 00:04:08,760
OK, so secu Honda just like we have type Honda type the rescue Honda type Q handwrote over here.

50
00:04:08,760 --> 00:04:10,080
We're going to call this year queue.

51
00:04:10,080 --> 00:04:11,790
Let's see this queue starts the.

52
00:04:11,790 --> 00:04:12,360
Yes.

53
00:04:17,730 --> 00:04:19,290
Are we spelling you correctly?

54
00:04:20,960 --> 00:04:22,430
Yeah, tops, correct.

55
00:04:23,040 --> 00:04:27,760
OK, so once that is done, I'm going to come in here and the first thing I'll do is create a queue,

56
00:04:28,670 --> 00:04:29,080
right?

57
00:04:29,540 --> 00:04:32,270
So to create a Q we used to Q create function.

58
00:04:32,270 --> 00:04:34,070
This function takes two arguments.

59
00:04:34,070 --> 00:04:42,440
The first argument is the length of the Q and the second argument is the is the the item size of the

60
00:04:42,440 --> 00:04:48,170
Q and the item size is basically based on the length of the Q.

61
00:04:48,800 --> 00:04:49,790
Let me show you what I mean.

62
00:04:50,510 --> 00:04:53,120
I'm going to see Q Execute, create.

63
00:04:53,120 --> 00:04:58,580
That's the name of the function, execute, create over here and I'm going to pass.

64
00:05:00,730 --> 00:05:06,970
I'm going to pass, I want five elements and what is the size of the queue?

65
00:05:07,100 --> 00:05:09,720
Well, it's going to be size of.

66
00:05:11,310 --> 00:05:16,790
The size of each item, so the second argument is the size of each item.

67
00:05:17,220 --> 00:05:21,180
Sorry, the second argument is the size of each item of the queue.

68
00:05:21,360 --> 00:05:24,510
So the items will be of size you in to.

69
00:05:25,810 --> 00:05:30,940
OK, so and this will return to Hondo, which we shall store here.

70
00:05:35,570 --> 00:05:43,430
OK, so this will we end up with, right, and then once this is done, we're going to go ahead to create

71
00:05:43,440 --> 00:05:46,880
our Task X task, create.

72
00:05:54,330 --> 00:06:02,210
And the first argument is the task function, so I'm going to start off with this is the task.

73
00:06:05,820 --> 00:06:10,530
And then the second argument is the name of the task, which is simply a string.

74
00:06:13,860 --> 00:06:21,280
Then following that, the stock going to give it a stock of one hundred and then following that.

75
00:06:25,280 --> 00:06:28,140
The the next document is the task parameter.

76
00:06:28,160 --> 00:06:36,410
We do not have a parameter and then the task handle what we want to study under the priority, first,

77
00:06:36,740 --> 00:06:38,170
I'm given that priority of one.

78
00:06:38,180 --> 00:06:42,350
And then finally, Dindo, I want to store this in the hand of variable.

79
00:06:42,350 --> 00:06:43,040
We created.

80
00:06:43,400 --> 00:06:44,780
So past the address here.

81
00:06:48,180 --> 00:06:48,810
Like this.

82
00:06:51,260 --> 00:06:54,410
OK, then I'm going to copy this.

83
00:06:57,690 --> 00:07:04,290
And paste this over here and I'll rename this to receive a task, the task function becomes receive

84
00:07:04,290 --> 00:07:11,550
a task over here and this word here becomes a receiver and then the handler here becomes receiver Hondo

85
00:07:13,170 --> 00:07:14,220
over here like this.

86
00:07:14,580 --> 00:07:17,000
OK, so we've created our tasks.

87
00:07:17,820 --> 00:07:20,490
We have to implement the task functions.

88
00:07:21,000 --> 00:07:24,120
And then before we forget, we've got to start our scheduler.

89
00:07:24,150 --> 00:07:27,540
So I'll see if the task starts.

90
00:07:27,540 --> 00:07:28,170
Scheduler.

91
00:07:33,480 --> 00:07:39,060
Like this, OK, so I'm going to implement these tasks, I'll copy them.

92
00:07:40,790 --> 00:07:49,430
Push them over here, the first one open and close, the second one open and close, because it's a

93
00:07:49,430 --> 00:07:56,480
task I'm going to give the infinite loop in here like this open and close and then here as well.

94
00:08:00,890 --> 00:08:01,770
Open and close.

95
00:08:01,860 --> 00:08:11,540
OK, that looks good, so I'm going to come over here and I'm going to, you know, Ascender, we're

96
00:08:11,540 --> 00:08:13,580
going to create a number of local variables.

97
00:08:14,210 --> 00:08:20,270
One, to hold the data we wish to to send and another one would hold the status.

98
00:08:24,170 --> 00:08:28,300
So I'll come over here and then into 30 to underscore.

99
00:08:29,600 --> 00:08:31,760
OK, you know, see value to send.

100
00:08:34,840 --> 00:08:43,600
Let's say we wish to send a year 2015 over there and then I'm going to have a base type, yeah, this

101
00:08:43,600 --> 00:08:49,570
will give us the status of the Q based type unaskable t, I'll call this huge status.

102
00:08:51,010 --> 00:08:51,520
Okay.

103
00:08:53,410 --> 00:09:02,170
So to send we have to we have to use the Q Senate function, this function takes three arguments.

104
00:09:02,650 --> 00:09:06,700
The first argument is the handle of the Q that you want to send to.

105
00:09:07,150 --> 00:09:10,240
The second argument is the value you want to send.

106
00:09:10,240 --> 00:09:13,560
And the third argument is like the timeout.

107
00:09:13,630 --> 00:09:14,830
How long do you want to wait?

108
00:09:17,220 --> 00:09:27,960
OK, so I'm going to come over here and say, excuse, send and then send here has to be capital.

109
00:09:28,170 --> 00:09:30,170
Q requires an equal right here.

110
00:09:31,050 --> 00:09:36,090
The first document, the name of our Q is the Yaku over here controversy.

111
00:09:37,740 --> 00:09:38,880
You page this over here.

112
00:09:39,900 --> 00:09:42,120
The value to send this is what we want.

113
00:09:42,120 --> 00:09:45,570
Is it going to pass this Ambersons sign here?

114
00:09:45,580 --> 00:09:47,340
Why did you send time out?

115
00:09:47,350 --> 00:09:56,040
We're going to pass you here and this will retain the status and I'm going to store it in our Q status

116
00:09:56,050 --> 00:09:58,830
variable here, OK?

117
00:10:00,680 --> 00:10:07,490
So this argument, like I said, it's the time out, so this is the maximum amount of time we want the

118
00:10:07,700 --> 00:10:09,950
the queue to wait in the blocked states.

119
00:10:10,860 --> 00:10:17,700
For data to be for space to become available in it, so should in case the cubie be full, should in

120
00:10:17,700 --> 00:10:22,560
case there is no space in the queue, we want to wait for X amount of time.

121
00:10:23,470 --> 00:10:29,980
For space to be available so that we can send this new piece of data, but when we put zero here, it's

122
00:10:29,980 --> 00:10:33,290
as if put zero here means we do not want to wait at all.

123
00:10:33,700 --> 00:10:40,020
This will return immediately as it detects that the queue is full in a similar way.

124
00:10:40,030 --> 00:10:41,790
We can put a time value here.

125
00:10:41,800 --> 00:10:49,900
We can pass wait for 50 VMS or 250 times, etc. but we pass in zero, meaning just return when it's

126
00:10:49,900 --> 00:10:50,170
full.

127
00:10:50,260 --> 00:10:51,160
You need no wait.

128
00:10:51,940 --> 00:10:53,350
OK, so that's what that means.

129
00:10:53,740 --> 00:10:57,340
And then so we've, we've sent this, we return this.

130
00:10:57,490 --> 00:10:59,720
We can use this to check whether it was successful.

131
00:11:01,630 --> 00:11:04,600
So we're going to see if it is successful or not.

132
00:11:04,600 --> 00:11:08,050
So I'm going to see if queue status.

133
00:11:10,340 --> 00:11:16,670
It's not equal to you, please pass, please pass is like true, this is defined in free ARTUS.

134
00:11:17,150 --> 00:11:19,160
So this is simply a saying.

135
00:11:19,160 --> 00:11:31,100
If it's not equal to true, then we want to make use of our printf say printf over here erro perhaps

136
00:11:31,100 --> 00:11:33,500
we can see data could not be sent.

137
00:11:39,260 --> 00:11:41,750
Then I return you line over here.

138
00:11:46,140 --> 00:11:51,900
Right, and we can put a bit of delay here or see for over here.

139
00:11:56,280 --> 00:12:08,870
And I equals zero, I is less than 100000 a plus plus European, and we close over here like this.

140
00:12:09,300 --> 00:12:14,660
OK, so this descender, how about a receiver over here in the receiver?

141
00:12:14,670 --> 00:12:16,910
We're going to have a number of local variables, too.

142
00:12:17,610 --> 00:12:22,970
I'm going to have INT 32 that escort and this is going to be value received.

143
00:12:22,980 --> 00:12:30,660
This is where we will store what we receive and then we're going to have we're going to allow the receiver

144
00:12:30,690 --> 00:12:31,310
to wait.

145
00:12:31,770 --> 00:12:37,440
So I'm going to create a hundred times over here by calling our PDM Static's.

146
00:12:37,890 --> 00:12:39,480
So I see a constant over here.

147
00:12:42,720 --> 00:12:43,350
Constance.

148
00:12:45,880 --> 00:12:49,180
To type Scottie.

149
00:12:51,330 --> 00:12:58,260
And then I say, wait time over here, which time over here, I'm going to say this because CDMs.

150
00:13:00,290 --> 00:13:01,070
To takes.

151
00:13:03,480 --> 00:13:09,620
What we want to do is say we passed 100 here, in a sense, we end up with one hundred is which time.

152
00:13:10,220 --> 00:13:15,420
So over here to receive we used a Q receive excuse function.

153
00:13:15,700 --> 00:13:22,410
The first document of this function is the Q handle the Q the handle to the Q from which we want to

154
00:13:22,410 --> 00:13:22,920
receive.

155
00:13:23,160 --> 00:13:26,120
The second argument is where to start to receive data.

156
00:13:26,430 --> 00:13:29,720
And the third argument is how long to wait the time out value.

157
00:13:30,270 --> 00:13:31,530
So I'm going to say X.

158
00:13:36,190 --> 00:13:42,130
Excuse receive over here, the first argument is the Q name.

159
00:13:42,160 --> 00:13:46,830
Q Hondo Yaku, it is called Okay.

160
00:13:46,840 --> 00:13:49,610
And the next argument is where to store it.

161
00:13:49,630 --> 00:13:52,480
We store in it and received value over here.

162
00:13:54,230 --> 00:13:54,630
Okay.

163
00:13:54,670 --> 00:13:55,120
And then.

164
00:13:57,200 --> 00:14:00,200
And then the final arguments this week's time.

165
00:14:02,180 --> 00:14:07,570
OK, and this is going to return a status which we can declare.

166
00:14:07,610 --> 00:14:10,070
I'm going to do what I did here based type.

167
00:14:10,670 --> 00:14:14,720
We're going to declare a base type here to hold this Q status here.

168
00:14:17,860 --> 00:14:19,780
And over here, we can print.

169
00:14:22,010 --> 00:14:22,940
Well, we received.

170
00:14:25,220 --> 00:14:27,050
We can see if it is.

171
00:14:28,100 --> 00:14:34,970
If it's received, we can check for base status what is true or not, and then print something or.

172
00:14:35,890 --> 00:14:41,050
If it is false, we do not print something OK, over here, I can see.

173
00:14:46,100 --> 00:14:48,650
I can see if you.

174
00:14:52,820 --> 00:14:54,800
If Cubase excuse, that is.

175
00:14:57,080 --> 00:15:03,560
Of course, pass, then we can print what we received print off.

176
00:15:11,030 --> 00:15:15,440
We said the value received is.

177
00:15:17,620 --> 00:15:19,240
Percentage of I hear.

178
00:15:20,480 --> 00:15:31,190
One, two, three, carriage return, new line, then we want to do is pass our volume here, value

179
00:15:31,190 --> 00:15:31,730
received.

180
00:15:33,180 --> 00:15:33,740
Okay.

181
00:15:34,790 --> 00:15:40,520
Then we can have an air condition here and over here, we can say printf.

182
00:15:45,470 --> 00:15:47,690
Good to see error could not receive.

183
00:15:51,490 --> 00:15:53,320
Here, Aero Club.

184
00:15:58,300 --> 00:15:59,440
Could not receive.

185
00:16:08,910 --> 00:16:09,390
OK.

186
00:16:12,000 --> 00:16:12,970
So we're looking good.

187
00:16:12,990 --> 00:16:14,280
Let's build and see what we have.

188
00:16:14,530 --> 00:16:15,630
Click over here to build.

189
00:16:16,910 --> 00:16:18,130
We have three arrests.

190
00:16:19,050 --> 00:16:19,700
OK.

191
00:16:20,960 --> 00:16:22,610
I see what does this one see?

192
00:16:23,540 --> 00:16:24,550
Percentage de.

193
00:16:25,740 --> 00:16:30,660
Aren't we using OK, let's expand here.

194
00:16:30,890 --> 00:16:32,820
Give us the specify it to use.

195
00:16:32,850 --> 00:16:34,160
So we should use Helda.

196
00:16:34,170 --> 00:16:36,560
It's trying to say this is a warning.

197
00:16:36,570 --> 00:16:38,190
So deal with the warnings.

198
00:16:38,190 --> 00:16:41,310
First percentage dhody over here.

199
00:16:45,090 --> 00:16:46,980
Red here implies error.

200
00:16:47,850 --> 00:16:49,850
OK, so it's a yes.

201
00:16:51,710 --> 00:16:52,470
That's cute.

202
00:16:52,490 --> 00:16:53,740
It's not included here.

203
00:16:59,280 --> 00:17:06,480
This makes your spelling of Honda as correct, the spelling is correct, so it's about including our

204
00:17:06,480 --> 00:17:07,230
culotte each.

205
00:17:08,850 --> 00:17:09,390
OK.

206
00:17:11,480 --> 00:17:13,850
OK, OK, so let's see what happened, right?

207
00:17:14,210 --> 00:17:18,370
Remember, we, um, we included our culotte itchin free artist Cifas.

208
00:17:18,830 --> 00:17:23,180
Well, we included it because we saw task that H included here.

209
00:17:23,780 --> 00:17:29,550
But we know what happens if you including the that file.

210
00:17:29,870 --> 00:17:31,730
It's not accessible from other files.

211
00:17:32,060 --> 00:17:37,760
So obviously by including this year, it's not accessible in our mind or Cifas.

212
00:17:38,030 --> 00:17:43,820
So we can include this in our May not H file alcott's culotte H from here, located from here.

213
00:17:43,820 --> 00:17:52,250
And then I would open the not H open declaration and then in here I would include Kittridge.

214
00:17:53,330 --> 00:17:59,620
But I wanted to I want to find out where Task H is included.

215
00:17:59,630 --> 00:18:02,270
Let's see if we are to reach what is in the.

216
00:18:06,570 --> 00:18:10,170
Free artist of the house config Dorridge Portable that each.

217
00:18:12,990 --> 00:18:20,940
OK, OK, let's go back to Main and let's open CMC Storage, we can solve this problem, but I just

218
00:18:20,940 --> 00:18:25,650
want to put it where Task H is rather than playsets.

219
00:18:25,650 --> 00:18:27,660
Anyway, this is CMC Storage.

220
00:18:27,660 --> 00:18:30,450
So Task not exist, CMC Storage.

221
00:18:30,720 --> 00:18:33,930
That is why we have access to the task functions you may not see.

222
00:18:34,200 --> 00:18:38,580
So then we're going to include Kudo over here as well.

223
00:18:39,240 --> 00:18:41,640
No, let's wait and see what we left with.

224
00:18:43,670 --> 00:18:46,340
OK, no error, no warning, we're looking good.

225
00:18:50,320 --> 00:18:50,800
OK.

226
00:18:51,930 --> 00:18:58,320
Right, let's download it onto a board or click over here working with number 14 here.

227
00:18:59,910 --> 00:19:00,840
I say, OK.

228
00:19:06,660 --> 00:19:07,860
And then I'll quick to switch.

229
00:19:09,860 --> 00:19:17,180
I'm going to open Realto, so I select my port, my border region and my ports, I'm going to click

230
00:19:17,180 --> 00:19:22,460
to open it and then I'm going to drop this here a bit.

231
00:19:25,220 --> 00:19:26,660
They're not quick to run.

232
00:19:29,930 --> 00:19:35,120
OK, but as I see, the value received is to 50, so we receive in it.

233
00:19:36,370 --> 00:19:36,880
OK.

234
00:19:39,330 --> 00:19:39,750
Writes.

235
00:19:42,030 --> 00:19:43,140
So those successful.

236
00:19:49,910 --> 00:19:50,580
We're going to stop.

237
00:19:50,600 --> 00:19:57,020
I'm going to play this again and see when I stop this, so we would have to do actually although we

238
00:19:57,020 --> 00:19:59,000
received it, we had a hard fought.

239
00:19:59,570 --> 00:20:08,240
And the reason the reason our Ewart's is not cooperating with us is because of the way it is implemented

240
00:20:08,240 --> 00:20:08,500
here.

241
00:20:08,510 --> 00:20:11,270
There is a huge time out value in this.

242
00:20:11,510 --> 00:20:13,320
You ought to transmit function.

243
00:20:13,640 --> 00:20:14,510
So what are we going to do?

244
00:20:14,510 --> 00:20:22,010
Is we going to we're going to write our own implementation of you are to transmit a simplified version

245
00:20:22,010 --> 00:20:27,010
of you are to transmit where we're going to transmit to use in the data register itself.

246
00:20:27,410 --> 00:20:33,440
And perhaps that would allow the US to function quicker than it is functioning currently.

247
00:20:33,710 --> 00:20:38,180
And we may also want to increase some of its configuration parameters.

248
00:20:38,810 --> 00:20:43,940
Let's see what the board rate is quite high, but we can go higher if we want.

249
00:20:44,750 --> 00:20:46,340
And then the speed.

250
00:20:47,500 --> 00:20:53,110
Yeah, so anyway, we would start off with a Ewart's, we would we would implement a new you are to

251
00:20:53,110 --> 00:21:00,340
function so that where we retargeted to print, if we don't use how you are to transmit, we would use

252
00:21:00,340 --> 00:21:06,310
a simple function that, you know, reads the data register of the other peripheral directly.

253
00:21:07,300 --> 00:21:10,840
OK, so we'll do that in the next lesson.
