1
00:00:00,680 --> 00:00:01,780
Hello, welcome back.

2
00:00:02,450 --> 00:00:09,740
And this lesson, we going to create another variation of our last project, which is our Ewart's our

3
00:00:09,920 --> 00:00:13,450
interrupt, we saw how to receive a single byte.

4
00:00:14,090 --> 00:00:18,830
What if we want to receive a packet and the package is made up of, say, 10 bytes.

5
00:00:19,340 --> 00:00:21,440
How do we construct this?

6
00:00:22,040 --> 00:00:24,800
So let's see one way that this can be achieved.

7
00:00:25,190 --> 00:00:25,600
Right.

8
00:00:25,790 --> 00:00:29,960
So I'm going to make a copy of the last project, number twenty six over here.

9
00:00:29,960 --> 00:00:31,190
I'll copy and paste this.

10
00:00:31,580 --> 00:00:33,260
I'll call this number twenty seven.

11
00:00:35,950 --> 00:00:36,520
And then.

12
00:00:38,900 --> 00:00:42,870
I simply call you are you are Torex receiving Puckett's?

13
00:01:03,080 --> 00:01:04,400
Puckett's basically.

14
00:01:05,590 --> 00:01:06,070
OK.

15
00:01:09,270 --> 00:01:17,000
I'm going to open this number 27 call over here, and this is our main NFR.

16
00:01:17,710 --> 00:01:19,750
OK, we still going to be using our interrupts.

17
00:01:19,930 --> 00:01:21,010
We wouldn't get rid of that.

18
00:01:21,630 --> 00:01:29,810
OK, so let's say this time, rather than just receive a single byte, we want to make make sure the

19
00:01:30,160 --> 00:01:35,950
bytes count is, let's say 10 before we we send it.

20
00:01:35,950 --> 00:01:40,480
And we would we are calling it Puckett's essentially OK.

21
00:01:43,200 --> 00:01:45,900
So what we're going to do is we go into.

22
00:01:46,880 --> 00:01:48,770
Update our you at.

23
00:01:50,360 --> 00:01:56,870
IREX enwrapped function, and we would need this function, take two argument, one would be a pointer

24
00:01:56,870 --> 00:02:02,370
to the Buffa to store the content and then the other argument will be the buffer length.

25
00:02:02,960 --> 00:02:07,450
But before we do that, we're going to declare a number of global static variables here.

26
00:02:08,150 --> 00:02:14,090
We're going to have one to tell us what IREX is in progress or not, what a reception is in progress.

27
00:02:14,270 --> 00:02:20,300
Another one will be to hold the are excellent the length of the pocket or the buffer if you meet and

28
00:02:20,300 --> 00:02:23,430
then a pointer to the buffer and then an iterator.

29
00:02:23,990 --> 00:02:27,540
So we're going to have these three this new three variables here.

30
00:02:28,520 --> 00:02:30,150
This one is the are excellent.

31
00:02:30,170 --> 00:02:36,020
This will be whether we want to receive five bytes, ten bytes and then a pointer to the buffer where

32
00:02:36,020 --> 00:02:42,080
we want to store the received data and then the iterator, of course, we would need to apply a loop

33
00:02:42,080 --> 00:02:42,430
here.

34
00:02:43,730 --> 00:02:54,140
OK, once we've done the we're going to update the, like I said, the T rex in its function.

35
00:02:54,800 --> 00:02:59,720
This is going to be the new IREX in its function is going to take.

36
00:03:01,470 --> 00:03:07,470
To argument this is a pointer to that buffer where we want to store what we receive and then the buffer

37
00:03:07,470 --> 00:03:13,470
land, I'm going to copy this new function prototype and bring it to the top here, because we have

38
00:03:13,470 --> 00:03:14,340
the old one here.

39
00:03:15,800 --> 00:03:17,360
Is the old one, the old one.

40
00:03:17,630 --> 00:03:18,680
OK, we cleaned it.

41
00:03:20,250 --> 00:03:22,810
In a way, I'll put this new function prototype here.

42
00:03:23,580 --> 00:03:25,050
OK, so.

43
00:03:26,460 --> 00:03:29,910
Why do we have this, OK, because it's got this sort of border.

44
00:03:31,170 --> 00:03:34,470
So when are we going to do this in this function?

45
00:03:34,470 --> 00:03:42,360
The first thing we're going to do is check if the if our buffer is valid, if the buffer is not pointing

46
00:03:42,360 --> 00:03:45,030
to another location, we've got to check if it's valid.

47
00:03:45,300 --> 00:03:48,390
And then we would initialize our global static's.

48
00:03:49,290 --> 00:03:49,590
We.

49
00:03:51,110 --> 00:03:52,010
We want to check.

50
00:03:54,320 --> 00:03:55,040
Over here.

51
00:03:56,990 --> 00:04:05,300
We want to make sure our X is not in progress, we said our X in progress because one is the flag that

52
00:04:05,300 --> 00:04:07,940
we used to indicate reception is in progress.

53
00:04:08,120 --> 00:04:09,440
So we want to see if we start.

54
00:04:11,540 --> 00:04:14,570
If our in progress is false and.

55
00:04:18,140 --> 00:04:20,960
If our progress is false and our buffa.

56
00:04:22,820 --> 00:04:24,140
We see it over here and.

57
00:04:28,230 --> 00:04:35,070
Buffer is not equal to normal, meaning the buffer is valid, if that's the case, then we want to go

58
00:04:35,070 --> 00:04:41,040
ahead and initialize our system for enwrapped.

59
00:04:42,400 --> 00:04:48,910
And then we want to return zero for success, so I say return to zero over here else.

60
00:04:50,510 --> 00:04:54,360
We could just see return one or return minus one here.

61
00:04:56,880 --> 00:05:00,440
OK, so this is.

62
00:05:05,440 --> 00:05:07,100
There's a better way of doing it.

63
00:05:07,150 --> 00:05:08,630
We come in check, OK?

64
00:05:08,830 --> 00:05:13,050
We've not started receiving yet and our buffer is not now.

65
00:05:13,300 --> 00:05:20,610
So what we want to do is set our course in progress to one and we want to set our bluebottles.

66
00:05:20,620 --> 00:05:23,610
You want to set a length that buffer and the iterator.

67
00:05:24,040 --> 00:05:28,930
So we simply set the global and this global variable here.

68
00:05:28,930 --> 00:05:33,480
We want to set it to the argument when I set the arguments past.

69
00:05:34,750 --> 00:05:40,420
So what a user passes here becomes our excellent and then the buffer points that they use apostacy,

70
00:05:40,420 --> 00:05:45,670
it becomes our IREX buffer that we define over here and the iterator is zero.

71
00:05:46,120 --> 00:05:49,210
And once we've done the OK, everything remains the same.

72
00:05:49,660 --> 00:05:55,030
We have our our enwrapped enabled, then we've given it a priority.

73
00:05:55,030 --> 00:05:56,490
And then with a neighborhood at an end.

74
00:05:56,510 --> 00:05:56,790
Vic.

75
00:05:58,490 --> 00:06:06,230
OK, so once that is done, now we go to our enwrapped service routine and see what we need to do there.

76
00:06:06,800 --> 00:06:12,590
So this is our interrupt service routine or interrupt request handler, OK.

77
00:06:15,330 --> 00:06:18,080
Over here, we don't need a queue anymore.

78
00:06:19,080 --> 00:06:27,350
What we would need, we would employ here is a SEMAFO, we need a SEMAFO that would be sent to our handler

79
00:06:27,360 --> 00:06:30,240
task to let him know that we received the entire packet.

80
00:06:31,450 --> 00:06:39,040
So our cue here, we would just remove that and we would have a SEMAFO here that would help us know

81
00:06:39,040 --> 00:06:45,760
that we've sent all the data and this will show us we've already seen how to use semaphores, which

82
00:06:45,760 --> 00:06:49,190
tasks this will show us how we can apply semaphores in interrupt.

83
00:06:49,540 --> 00:06:52,390
So we'll use the interrupt service routine.

84
00:06:53,410 --> 00:06:59,680
API for semaphores rather than our standard SEMAFO API, so to do this, I'll start off by creating

85
00:06:59,680 --> 00:07:03,120
the SEMAFO Hodler over here.

86
00:07:03,310 --> 00:07:06,580
It's global, so it's called IREX.

87
00:07:06,850 --> 00:07:08,140
That's the name of the SEMAFO.

88
00:07:08,740 --> 00:07:13,880
So we're going to come back to our enwrapped request handler over here.

89
00:07:14,410 --> 00:07:20,100
Currently, our enwrapped request handler just receives the data, installs it in temp file.

90
00:07:20,530 --> 00:07:20,990
OK.

91
00:07:21,700 --> 00:07:28,220
And over here, this is we had our excuse sent from Isar over here and we deleted it.

92
00:07:28,810 --> 00:07:34,510
So what are we going to do is whenever we receive data, we're going to take this data and store it

93
00:07:34,510 --> 00:07:35,700
in our IREX buffer.

94
00:07:36,550 --> 00:07:46,120
OK, so the data is going to be stored in the our buffer and the index will be iterated as well so that

95
00:07:46,120 --> 00:07:48,770
we can store the next piece of data in the next location.

96
00:07:49,330 --> 00:07:54,070
So then once we store the data in the aggregate buffer and we increment the index, we have to check

97
00:07:54,070 --> 00:08:01,120
whether the index is greater than or equal to the the are excellent.

98
00:08:03,070 --> 00:08:05,500
If that's the case, then we can send our SEMAFO.

99
00:08:05,710 --> 00:08:08,770
If that's the case, we can simply see if irex.

100
00:08:09,070 --> 00:08:09,700
Yes.

101
00:08:09,700 --> 00:08:14,620
If it's greater or we can see if it's equal to it's all the same.

102
00:08:15,100 --> 00:08:24,730
So if that's the case we simply said we see, OK, irex in progress, we set it to false or zero, we

103
00:08:24,730 --> 00:08:31,210
use it, we use an integer for this variable so we set it to force O0 like this.

104
00:08:31,940 --> 00:08:38,350
OK, and then we send our SEMAFO and whenever you are sending you also you still have to indicate whether

105
00:08:38,440 --> 00:08:41,740
you want a higher priority task to be woken or not.

106
00:08:42,220 --> 00:08:49,840
So over here we see X semafo give from ESR this the SEMAFO handle, and this is where we want to wake

107
00:08:49,840 --> 00:08:51,440
up a higher priority task or not.

108
00:08:51,460 --> 00:08:53,260
We said not to focus just like we did.

109
00:08:53,500 --> 00:08:56,950
And like I said, I shouldn't have any effect yet since we have a single task.

110
00:08:58,680 --> 00:09:05,740
OK, so once that is done, we come over here and then we load the the Processo, OK?

111
00:09:05,940 --> 00:09:07,920
So check this.

112
00:09:08,520 --> 00:09:09,810
We received the data.

113
00:09:09,870 --> 00:09:11,730
We keep storing it in our buffer.

114
00:09:11,730 --> 00:09:19,170
When the buffer iterator is equal to the IREX length, which is the length that we expect, then we

115
00:09:19,170 --> 00:09:24,780
set our progress to zero and then we send a SEMAFO to indicate we have the entire Puckett's.

116
00:09:25,200 --> 00:09:31,470
So then once the SEMAFO is sent, let's go to our handler task to see how this will be dealt with.

117
00:09:33,550 --> 00:09:34,510
I'll come over here.

118
00:09:34,540 --> 00:09:42,190
This is our task in the previous project, the handler task simply received the data using the key was

119
00:09:42,190 --> 00:09:43,550
simply received in the queue.

120
00:09:44,080 --> 00:09:50,460
OK, over here, what we're going to do is we're going to expect the semaphore.

121
00:09:50,500 --> 00:09:55,480
When we received a semaphore, then we would want to do something to the data.

122
00:09:55,480 --> 00:09:59,200
We want to prints the data, processing, the data or whatever we want.

123
00:10:00,640 --> 00:10:04,490
So what we're going to do is we're going to have a buffer here.

124
00:10:05,320 --> 00:10:06,880
I'm going to have to buffer here.

125
00:10:07,420 --> 00:10:14,170
And the reason the buffer will be, too, is because we wouldn't we wouldn't be using our you what?

126
00:10:14,440 --> 00:10:17,200
I'm going to use this buffer to store the IREX code.

127
00:10:17,560 --> 00:10:24,100
And what I mean by the IREX good is whether the data was received successfully or whether the data is

128
00:10:24,100 --> 00:10:25,840
corrupt or whatever time outlooked.

129
00:10:26,290 --> 00:10:31,870
We're going to store that information in this buffer and the actual data will be stored in our data

130
00:10:31,870 --> 00:10:36,070
here so we can come over here and.

131
00:10:37,190 --> 00:10:44,300
Let's see, for our example, we have we have this value, I'm going to define expected length over

132
00:10:44,300 --> 00:10:44,600
here.

133
00:10:47,850 --> 00:10:48,420
Let's see.

134
00:10:53,290 --> 00:10:56,680
Oh, defined as expected, expected.

135
00:11:00,340 --> 00:11:01,210
Peatland.

136
00:11:02,570 --> 00:11:05,510
So this is the expected length of the Puckett's.

137
00:11:07,300 --> 00:11:07,800
OK.

138
00:11:11,130 --> 00:11:14,490
So we've set us five, so the pocket length is five.

139
00:11:16,770 --> 00:11:18,140
I'm going to come over here.

140
00:11:21,160 --> 00:11:23,020
Where we sit, here we are.

141
00:11:24,950 --> 00:11:28,980
I come over here and initialize our code.

142
00:11:29,000 --> 00:11:38,690
I'm going to set the data, lente the IREX data, let's see our IREX data buffer has more capacity.

143
00:11:38,690 --> 00:11:41,050
It's got more space than our expected length.

144
00:11:41,210 --> 00:11:43,540
We just had expected lend to five.

145
00:11:43,550 --> 00:11:51,140
We can change that value, but our IREX data above has space for twenty 20 items.

146
00:11:51,140 --> 00:11:52,060
So we can leave this.

147
00:11:52,070 --> 00:11:53,180
It doesn't have to be the same.

148
00:11:53,600 --> 00:11:57,770
OK, so the first thing we do when we enter our.

149
00:11:59,770 --> 00:12:01,900
When we enter our Honda task.

150
00:12:03,200 --> 00:12:03,620
To.

151
00:12:05,050 --> 00:12:11,070
Just set everything here, we make sure we initialize it to zero, so I'm simply going to use a follow

152
00:12:11,110 --> 00:12:12,250
up to achieve that.

153
00:12:16,620 --> 00:12:22,830
So four inch equals zero eyes, less than the Buffa size, we simply set everything to zero.

154
00:12:23,400 --> 00:12:25,500
OK, so once that is done.

155
00:12:27,300 --> 00:12:36,090
We go into sets the time out because we want we said, OK, we expect the data, the entire pocket to

156
00:12:36,420 --> 00:12:43,860
OK within five thousand homes, which is essentially five seconds, we expect the entire Buffa to be

157
00:12:44,040 --> 00:12:47,550
the entire package to be received within this, OK?

158
00:12:47,970 --> 00:12:50,880
And this this is our oad start.

159
00:12:51,900 --> 00:12:58,920
IREX, this starts IREX enwrapped function, we don't need this, remember, we've changed our stats,

160
00:12:58,920 --> 00:13:00,270
IREX interrupts function.

161
00:13:00,270 --> 00:13:04,140
Now it's expects to document the buffer in the buffer length.

162
00:13:06,040 --> 00:13:13,210
So we're going to call our state our enwrapped function over here.

163
00:13:15,120 --> 00:13:15,990
We're going to see.

164
00:13:21,130 --> 00:13:22,300
Starts on school.

165
00:13:25,490 --> 00:13:28,350
On the school in Rob.

166
00:13:29,620 --> 00:13:31,870
And the first argument is the.

167
00:13:33,120 --> 00:13:36,780
Buffer, which we said when asteroids in our states are here.

168
00:13:38,560 --> 00:13:40,510
The second argument is the length.

169
00:13:43,470 --> 00:13:48,570
So the length of the buffer, we can pass 20 over.

170
00:13:49,560 --> 00:13:55,300
Actually, it would make more sense if we make the buffer size the same as the expected length.

171
00:13:55,320 --> 00:13:58,710
Now, simplify things, we would need to write less conditions.

172
00:13:59,280 --> 00:14:02,880
So I'll copy our expected picket line here.

173
00:14:02,880 --> 00:14:05,690
And that's going to be the size of our IREX data.

174
00:14:06,300 --> 00:14:07,740
So I'll push this year.

175
00:14:09,550 --> 00:14:13,880
And then our Étretat over here.

176
00:14:13,900 --> 00:14:20,750
So if you close your eyes less than expected puppetland and then over here when we come starts IREX

177
00:14:20,770 --> 00:14:22,640
interrupt, this is our IREX data.

178
00:14:22,900 --> 00:14:26,440
This is the land expected pocket size, OK.

179
00:14:28,250 --> 00:14:32,840
So this one will do, but we need to call this we need to call this repeatedly.

180
00:14:34,880 --> 00:14:44,270
You know, while one loop, so this over here, I'll cut it and put it over here right this bit, we

181
00:14:44,270 --> 00:14:45,370
do not need it anymore.

182
00:14:45,890 --> 00:14:48,740
So we said this is just the initialization.

183
00:14:48,980 --> 00:14:58,850
Then go over it in our IREX handler, we initialize our you AT4 are in it and then we initialize the

184
00:14:58,850 --> 00:15:02,240
buffer to store the received, uh, data.

185
00:15:02,450 --> 00:15:08,210
We call in this IREX data, we set everything to zero and then we defined a time out value that we want

186
00:15:08,210 --> 00:15:09,380
to give.

187
00:15:09,720 --> 00:15:17,000
OK, and then when we came over here in our one loop we see stats Ulriksen robt, we passed our buffer

188
00:15:17,000 --> 00:15:18,130
and then the length.

189
00:15:19,040 --> 00:15:28,010
Now we're going to take the SEMAFO that was sent or the SEMAFO that will be set will be sent from the

190
00:15:28,010 --> 00:15:29,450
interrupt request handler.

191
00:15:29,750 --> 00:15:32,800
We're going to check if the SEMAFO can be taken.

192
00:15:33,410 --> 00:15:39,950
So we see ximo photic are done the name of the SEMAFO and then the timeout which is this time of value.

193
00:15:40,190 --> 00:15:45,530
We say if this is pass, meaning if we are able to take it then.

194
00:15:47,430 --> 00:15:50,450
We can print received or something.

195
00:15:52,350 --> 00:15:57,040
We can if this is passed, then we can print a particular code.

196
00:15:57,120 --> 00:16:01,730
OK, so over here we can check what other data lenders are expected.

197
00:16:02,070 --> 00:16:03,150
So we'll see if.

198
00:16:04,460 --> 00:16:06,260
Expected PKC lenth.

199
00:16:10,660 --> 00:16:18,700
Is equal to our IREX index, remember, we have this other global variable called index, the Iterator,

200
00:16:18,700 --> 00:16:27,220
which moves through the Buffa indices, OK, it's expected LENTE is equal to the current are iterator.

201
00:16:27,550 --> 00:16:29,500
Then we know we've received all the data.

202
00:16:31,430 --> 00:16:39,710
We can see Sprint and Sprint here, this used to take a string and place it in a buffer for us.

203
00:16:42,060 --> 00:16:49,720
So go clean, see sprint over here and what we want to do is this is our buffer.

204
00:16:51,720 --> 00:16:58,500
The reason I'm using sprint efforts, we're going to be using our Ewart's in IREX mode, so we cannot

205
00:16:58,500 --> 00:16:59,310
print that.

206
00:17:00,000 --> 00:17:05,760
So we're going to take our code, the code here, because it could be a word as simple as received.

207
00:17:12,310 --> 00:17:14,830
OK, so we're going to take this story to you.

208
00:17:14,860 --> 00:17:16,900
That's what this means, Sprint F means.

209
00:17:18,580 --> 00:17:20,510
Take this and put it in this buffer.

210
00:17:21,030 --> 00:17:29,350
Okay, so if the expected length is equal to the other idea we want to store this year when a prince

211
00:17:29,350 --> 00:17:29,890
received.

212
00:17:32,210 --> 00:17:34,220
What if it's not El's?

213
00:17:45,060 --> 00:17:50,610
We want to print let's data so we can see.

214
00:17:55,360 --> 00:17:57,040
As princess over here.

215
00:17:58,530 --> 00:18:00,890
And then we still want to store here.

216
00:18:02,070 --> 00:18:05,310
You know, our xcode by far and over here we can see.

217
00:18:08,670 --> 00:18:14,280
Data are for error and we could see.

218
00:18:15,850 --> 00:18:17,170
Maybe we expected.

219
00:18:19,440 --> 00:18:24,300
A particular number, and then we've got a particular number we can see expected.

220
00:18:28,540 --> 00:18:30,460
The percentage I bite's.

221
00:18:41,350 --> 00:18:41,980
Actually.

222
00:18:45,440 --> 00:18:52,640
I simply say lenth miss much, let's not complicate complicated things decided on the right phrase to

223
00:18:52,640 --> 00:18:53,230
type here.

224
00:18:53,480 --> 00:18:56,640
OK, length mismatch.

225
00:18:56,690 --> 00:18:57,080
OK.

226
00:18:59,420 --> 00:19:00,240
And over here.

227
00:19:00,290 --> 00:19:01,620
So this is what happens.

228
00:19:01,910 --> 00:19:08,000
So meaning if we are able to receive the data within this time out, we check whether the length is

229
00:19:08,000 --> 00:19:16,070
the same, because the IREX iterator would be the number of the last data item we check.

230
00:19:16,070 --> 00:19:18,790
If that's it, we say, OK, our xcode received.

231
00:19:19,130 --> 00:19:21,170
If it's not the same, we see a length mismatch.

232
00:19:21,710 --> 00:19:24,230
What if we are not able to received within?

233
00:19:24,470 --> 00:19:29,210
We're not able to receive within the the declared time out value.

234
00:19:29,690 --> 00:19:35,470
OK, so we're going to write on this condition here to deal with a C else.

235
00:19:36,320 --> 00:19:42,700
We want to see Asprin F and over here we can see printed time out.

236
00:19:43,190 --> 00:19:45,410
You can see our xcode.

237
00:19:48,210 --> 00:19:50,190
Time out over here like this.

238
00:19:51,930 --> 00:19:53,610
OK, so we're looking good.

239
00:19:53,720 --> 00:19:55,860
Looks long, but we're looking good.

240
00:19:58,310 --> 00:19:58,730
OK.

241
00:20:00,320 --> 00:20:05,750
OK, so let's build and see what we have a click here to build.

242
00:20:07,220 --> 00:20:08,810
We have to anomaly's.

243
00:20:10,060 --> 00:20:18,670
OK, we've now included semaphores in this project, so we would come over here to our systems as well

244
00:20:18,670 --> 00:20:19,990
as the fall right.

245
00:20:19,990 --> 00:20:30,910
Click open declaration and scroll down here and I'm going to include some of the rage we spelled s m,

246
00:20:30,910 --> 00:20:35,380
p, h, r and R, OK, s.

247
00:20:37,140 --> 00:20:38,010
The schoolbook.

248
00:20:39,040 --> 00:20:41,160
Quick to run, quick to build first.

249
00:20:42,040 --> 00:20:43,490
It's built successfully.

250
00:20:45,310 --> 00:20:47,290
I'm going to right click this.

251
00:20:49,180 --> 00:20:55,150
Debuggers estimated to double click this to happen, I say, OK.

252
00:21:00,200 --> 00:21:00,960
Click the switch.

253
00:21:02,390 --> 00:21:10,340
OK, so I'm going to remove this, receive Buffa, remove all and what I'm going to do is.

254
00:21:12,130 --> 00:21:17,500
I'm going to add our data and our expert exposure, since we know we are starting to receive data in

255
00:21:17,500 --> 00:21:20,000
our school, our our data and our exposure.

256
00:21:20,020 --> 00:21:22,490
That is where they received stuff will be kept.

257
00:21:22,990 --> 00:21:24,040
So I copied this.

258
00:21:25,300 --> 00:21:26,230
Our xcode.

259
00:21:29,590 --> 00:21:33,170
And then IREX data, if we want to check the data itself.

260
00:21:34,640 --> 00:21:40,920
OK, and I'm going to open real time, real time is already here.

261
00:21:41,890 --> 00:21:43,700
I'm going to expand our Xcode.

262
00:21:43,750 --> 00:21:45,370
We gave it a length of 50.

263
00:21:46,150 --> 00:21:48,340
OK, we may need to shorten this.

264
00:21:48,670 --> 00:21:56,320
So I click play here and then I'm going to press a number of letters on my keyboard.

265
00:21:56,830 --> 00:22:00,270
I've selected this type in area of real time.

266
00:22:00,280 --> 00:22:04,990
The reason we don't see what we write is because we've no, we're not echoing what we typing.

267
00:22:05,240 --> 00:22:07,870
OK, so I'll press a number of keys.

268
00:22:10,280 --> 00:22:13,370
Let me see what I need to first open the port.

269
00:22:17,570 --> 00:22:20,120
OK, nothing is happening, I've pressed.

270
00:22:22,380 --> 00:22:29,340
You see, when I press a key, we see here, you see you see the lights here showing that I'm trying

271
00:22:29,340 --> 00:22:33,690
to transmit from here, OK, but there is nothing in our IREX.

272
00:22:35,640 --> 00:22:37,620
Could the ACARS data?

273
00:22:38,960 --> 00:22:43,220
Our data has nothing as well, so I'm going to press you stop here.

274
00:22:43,240 --> 00:22:46,030
Let's see where that's our program and.

275
00:22:47,770 --> 00:22:56,320
Config assets, PKU, hahaha, I've seen this error before, it could be that we didn't create we have

276
00:22:56,320 --> 00:22:59,330
a queue somewhere or we have a SEMAFO that we didn't create.

277
00:22:59,950 --> 00:23:06,230
Yes, whenever you don't create a feature and you try to use it, you end up at a part of the code.

278
00:23:06,880 --> 00:23:10,480
Indeed the SEMAFO wasn't created and just bear with me.

279
00:23:10,750 --> 00:23:12,550
I've made this error before.

280
00:23:13,180 --> 00:23:16,900
We just, we just declare the handle of the semaphore without creating it.

281
00:23:18,230 --> 00:23:19,750
So let's create the SEMAFO.

282
00:23:21,010 --> 00:23:28,690
So when we come over here, we create the SEMAFO by saying XML for creates binary and we store the handle

283
00:23:28,690 --> 00:23:29,330
in the handle.

284
00:23:29,380 --> 00:23:30,520
We declared over here.

285
00:23:31,210 --> 00:23:32,800
OK, let's stop this.

286
00:23:34,640 --> 00:23:38,200
OK, so click over here to build again.

287
00:23:44,100 --> 00:23:45,330
It's built successfully.

288
00:23:45,930 --> 00:23:47,460
Click here to go to Debugger.

289
00:23:53,040 --> 00:23:54,030
Click here to switch.

290
00:23:58,330 --> 00:24:01,510
OK, here we go, I'm going to expand this hour Xcode.

291
00:24:03,320 --> 00:24:05,420
And I'm going to open this.

292
00:24:05,720 --> 00:24:12,260
This is real time is still the going to click to run and then I'm going to press a number of keys on

293
00:24:12,260 --> 00:24:12,890
the keyboard.

294
00:24:14,690 --> 00:24:16,640
OK, we're still transmitting yet.

295
00:24:16,640 --> 00:24:17,450
Nothing to see.

296
00:24:18,260 --> 00:24:23,850
OK, we're going to come over here, but they're going to come over here.

297
00:24:24,830 --> 00:24:27,530
Oh, here is a it took a while timeout.

298
00:24:27,680 --> 00:24:31,210
OK, so at least something is working.

299
00:24:31,400 --> 00:24:33,860
We didn't receive the data, but we did receive a timeout.

300
00:24:34,970 --> 00:24:40,340
This is timeout t i m e o u t o uti.

301
00:24:40,340 --> 00:24:41,240
OK, timeout.

302
00:24:41,780 --> 00:24:43,780
Let's see our data buffer.

303
00:24:45,290 --> 00:24:45,740
OK.

304
00:24:46,750 --> 00:24:47,980
We received the data.

305
00:24:49,320 --> 00:24:50,700
We did receive the data.

306
00:24:51,540 --> 00:24:54,780
OK, I know what is happening here.

307
00:24:55,200 --> 00:24:55,800
Let's.

308
00:24:59,340 --> 00:25:08,600
Less comment out our spring time out, so we said if we don't receive within the timeout print, time

309
00:25:08,610 --> 00:25:08,870
out.

310
00:25:09,330 --> 00:25:11,190
I'm going to comment this out first.

311
00:25:13,870 --> 00:25:14,740
It could be that.

312
00:25:16,270 --> 00:25:23,590
We received the data and the integrity is good, but it's just a bit late, so we don't get to see,

313
00:25:24,400 --> 00:25:29,380
you know, we don't we end up seeing time out as the code in a way.

314
00:25:29,410 --> 00:25:36,610
Let's comment this out and see if we can receive the data with this call received or lenth mismatch

315
00:25:36,880 --> 00:25:40,270
before we come in and able this a click here to view it.

316
00:25:44,040 --> 00:25:46,770
It's viewed successfully or click here to go to the debugger.

317
00:25:57,780 --> 00:25:58,290
OK.

318
00:26:08,220 --> 00:26:14,640
So I'm going to click to run and then I'm going to type number of keys, OK, received.

319
00:26:16,300 --> 00:26:16,750
Right.

320
00:26:16,870 --> 00:26:22,720
So we've been able to receive I just typed what you would call gibberish, so let's see that.

321
00:26:23,350 --> 00:26:27,070
Yes, you can see USFS, OK?

322
00:26:29,410 --> 00:26:33,730
So the idea is I have to type fast enough, otherwise there'll be a time out.

323
00:26:36,140 --> 00:26:36,590
OK.

324
00:26:39,360 --> 00:26:45,630
So now let's go back, let's increase the timeout amount.

325
00:26:45,660 --> 00:26:47,430
I'm going to increase the timeout from.

326
00:26:48,920 --> 00:26:50,450
Let's say five seconds.

327
00:26:52,680 --> 00:26:55,290
To eight seconds, OK?

328
00:26:55,560 --> 00:26:56,490
Quick Hits Bude.

329
00:27:09,340 --> 00:27:11,590
And then we get to go to the debugger.

330
00:27:23,830 --> 00:27:28,510
And I'm going to type one, two, three, four, five, just so you know.

331
00:27:30,430 --> 00:27:33,400
I'm going to come over here, expand the code.

332
00:27:36,350 --> 00:27:43,080
Well, let's see, we did in a neighborhood, a time out asprin, if sorry, but let's go back and enable

333
00:27:43,440 --> 00:27:46,500
the experience of full time art is still committed.

334
00:27:46,530 --> 00:27:50,190
Art s click here to build.

335
00:27:54,320 --> 00:27:56,870
Let's build successfully go to debugger.

336
00:28:03,250 --> 00:28:03,850
Switch.

337
00:28:11,010 --> 00:28:12,420
OK, explain this.

338
00:28:15,100 --> 00:28:20,980
And we can increase the buffer here, since the code doesn't require 50 bytes so we can increase the

339
00:28:22,210 --> 00:28:22,710
OK.

340
00:28:26,010 --> 00:28:29,580
And I'm going to come over here, press this and then quickly.

341
00:28:32,710 --> 00:28:33,700
OK, received.

342
00:28:34,840 --> 00:28:36,730
So I was able to type fast enough.

343
00:28:38,800 --> 00:28:40,720
And you can see one, two, three, four, five.

344
00:28:40,930 --> 00:28:43,410
OK, so this is it over here.

345
00:28:43,630 --> 00:28:49,270
The the lesson or the take away here is we use in the semaphores to do this for us.

346
00:28:49,780 --> 00:28:54,160
The SEMAFO we are using has to be give from ESR.

347
00:28:54,610 --> 00:28:56,590
It's not just our standard SEMAFO gif.

348
00:28:56,950 --> 00:29:01,450
So we've seen how to use Qs in uninterest service routine, how to use semaphores.

349
00:29:01,660 --> 00:29:04,240
That's all there is for this lesson and I'll see you in the next lesson.

350
00:29:04,480 --> 00:29:05,260
Have a nice day.
