1
00:00:00,910 --> 00:00:02,100
Hello, welcome back.

2
00:00:02,740 --> 00:00:09,700
And this lesson, we go in to see how to work with the gatekeeper task, I'm going to create a new project

3
00:00:09,700 --> 00:00:12,040
by making a copy of the last one over here.

4
00:00:12,400 --> 00:00:14,770
I'll copy and paste it over here.

5
00:00:15,190 --> 00:00:17,380
I'll call this gatekeeper.

6
00:00:22,710 --> 00:00:23,340
Like this.

7
00:00:23,850 --> 00:00:24,350
OK.

8
00:00:28,220 --> 00:00:29,240
So it's cop in.

9
00:00:32,710 --> 00:00:38,350
OK, so I'm going to open our gate keeper to ask.

10
00:00:40,000 --> 00:00:41,200
This is minimized.

11
00:00:43,190 --> 00:00:52,430
Here we are, gatekeeper over here, source and may not see over here, so we go in to achieve what

12
00:00:52,430 --> 00:00:54,490
we've been achieving with our semaphores.

13
00:00:54,500 --> 00:00:59,600
But this time without semaphores, we're going to use our gatekeeper and the gatekeeper is going to

14
00:00:59,600 --> 00:01:04,970
be the task which is keeping the gate for our serial port.

15
00:01:04,970 --> 00:01:08,660
Our Ewart's is going to be handled by just one task.

16
00:01:08,930 --> 00:01:16,700
So both our analog sensor task and our digital sensor task, if they have something to print, they

17
00:01:16,700 --> 00:01:21,180
have to give it to the gatekeeper task to print it for them.

18
00:01:21,830 --> 00:01:23,930
That is what we going to do over here.

19
00:01:24,140 --> 00:01:29,270
So over here, we don't require semaphores or delete our semaphore handle here and then.

20
00:01:31,070 --> 00:01:36,320
So currently, I've just deleted our SEMAFO, Honda or Semaphore crates of deleted as well.

21
00:01:36,690 --> 00:01:37,160
OK.

22
00:01:39,030 --> 00:01:46,320
So what do we have we have two tasks, we have our Botin Reid task and we have a white button, Reid

23
00:01:46,320 --> 00:01:52,320
and Senator Reid, and we know Button Reid is our digital button and then sensor is, of course, our

24
00:01:52,320 --> 00:01:52,910
ADC.

25
00:01:53,190 --> 00:01:59,880
What I'm going to do next is I'm going to clean this bit here where we were taken and given to SEMAFO.

26
00:01:59,880 --> 00:02:03,600
I'm going to clean it in both of these task functions.

27
00:02:04,110 --> 00:02:11,910
Such that's what we have left in our digital sense or task is just read the digital sense or storage

28
00:02:11,910 --> 00:02:18,600
in a variable, and then we toss one here and what we have in our analog senso with the analog sense

29
00:02:18,600 --> 00:02:19,920
or storage in a variable.

30
00:02:19,920 --> 00:02:21,980
And we have to delay one here.

31
00:02:22,530 --> 00:02:26,880
So we're going to create a third task known as the gatekeeper task.

32
00:02:27,450 --> 00:02:37,140
And this would have the same it would have the same amount of rum, the same success story as the other

33
00:02:37,140 --> 00:02:37,650
tasks.

34
00:02:38,670 --> 00:02:40,850
We're going to give this a priority of zero.

35
00:02:40,890 --> 00:02:42,590
The others have a priority of one.

36
00:02:42,600 --> 00:02:46,710
So our gatekeeper essentially has the lowest priority here.

37
00:02:47,040 --> 00:02:48,090
No problem with this.

38
00:02:48,870 --> 00:02:49,300
Right.

39
00:02:49,530 --> 00:02:55,860
So now the question is, how are we going to get information from our tasks to the gatekeeper?

40
00:02:56,460 --> 00:03:03,390
What are we going to do is employ a Q We're going to use a Q So if if a task has something to print,

41
00:03:03,600 --> 00:03:04,590
it would put it into.

42
00:03:04,590 --> 00:03:06,660
Q You can think of.

43
00:03:08,020 --> 00:03:15,610
You can think of being in an office with a number of computers and having a central computer that is

44
00:03:15,610 --> 00:03:20,800
connected to the printer such that if you want something to print, you send it to the central computer

45
00:03:21,220 --> 00:03:23,380
in the central computer keywords for you.

46
00:03:24,720 --> 00:03:29,340
In the printer, and then you print one after the other based on which arrived first.

47
00:03:29,940 --> 00:03:34,730
OK, so we have three tasks.

48
00:03:34,750 --> 00:03:36,510
Yeah, our bottom reader task.

49
00:03:36,510 --> 00:03:37,560
Sensory task.

50
00:03:37,560 --> 00:03:38,790
Our gatekeeper task.

51
00:03:39,330 --> 00:03:44,220
OK, next, we going to define the handle for a Q.

52
00:03:45,110 --> 00:03:52,850
Of course, we said we're going to use a cue, so I'll come up here and have this Q&amp;A Hondo here, experiencer

53
00:03:52,850 --> 00:03:53,180
cue.

54
00:03:53,750 --> 00:03:58,610
OK, so since we have the handle for the cue, we have to create the cue, then we're going to see the

55
00:03:58,610 --> 00:03:59,150
cue.

56
00:03:59,630 --> 00:04:02,110
Should have a maximum capacity of two elements.

57
00:04:02,630 --> 00:04:07,770
So we see X execute great size of end.

58
00:04:07,790 --> 00:04:09,950
This is going to be the data type.

59
00:04:11,020 --> 00:04:17,150
And we want to study Hunda here, OK, once that is done, we said the name of our.

60
00:04:19,530 --> 00:04:25,200
Our gatekeeper task is task, we can call it a little task for now, right?

61
00:04:25,220 --> 00:04:30,570
You can call it zero printer task if you want, or LCD task.

62
00:04:30,580 --> 00:04:33,710
I'm just calling the LCD task here, OK?

63
00:04:33,870 --> 00:04:36,610
So that's the name we give the task function.

64
00:04:36,810 --> 00:04:37,880
We know this already.

65
00:04:38,220 --> 00:04:42,300
So I'm going to create an LCD task function down here.

66
00:04:42,310 --> 00:04:50,790
We have our first task function is the second one for the second task, the third one over here like

67
00:04:50,790 --> 00:04:51,150
this.

68
00:04:52,600 --> 00:04:55,100
We're going to have our infinite loop here.

69
00:04:57,900 --> 00:05:06,590
OK, so over here, in a digital sense or task, whenever it's reached the sense data we wanted to send

70
00:05:06,590 --> 00:05:12,050
DICENZO who wanted to send the button data to our queue.

71
00:05:12,870 --> 00:05:20,490
So what we want to do is see X, Q send it back because we want to add this to the Q.

72
00:05:21,880 --> 00:05:28,700
Excuse and to back and what we want to send is the button states, so what we read here, we send in

73
00:05:28,720 --> 00:05:33,040
it to the cute, OK, and we want to do the same for our.

74
00:05:34,040 --> 00:05:35,060
Analog Senseor.

75
00:05:36,310 --> 00:05:44,080
So the analog sensor volume that we store in this variable, we want to send that to the queue over

76
00:05:44,080 --> 00:05:45,670
here like this.

77
00:05:45,760 --> 00:05:50,080
OK, so then our queue has our sense of values.

78
00:05:50,860 --> 00:06:00,210
Now, what we want to do is go to our gatekeeper task over here and tell the gatekeeper task to wait.

79
00:06:01,360 --> 00:06:07,810
We're going to create a variable for the gatekeeper task to store what it received or of this variable

80
00:06:07,810 --> 00:06:10,540
into variable here called value to print.

81
00:06:11,200 --> 00:06:13,980
So the gatekeeper task is going to wait.

82
00:06:13,990 --> 00:06:17,960
We're going to see Portsmouth's delay over here.

83
00:06:17,960 --> 00:06:19,270
We're going to pass this over here.

84
00:06:19,300 --> 00:06:20,740
So we're going to wait.

85
00:06:22,270 --> 00:06:27,700
For data to become available, maximum delay, OK, so when the data is received from this key is going

86
00:06:27,700 --> 00:06:33,780
to be stored in this variable here and we can print the content of this variable without of.

87
00:06:34,660 --> 00:06:42,930
So you simply say printf here, and if we want to make it more complex, of course we can identify whether

88
00:06:42,940 --> 00:06:52,630
this is coming from the from the digital sense or the analog sense or using the the one of our Q examples

89
00:06:52,630 --> 00:06:57,580
where we had a structure, we would send in a structure to the Q and one of the structure members told

90
00:06:57,580 --> 00:07:04,540
us the the identification of the data, whether it was humidity data or pressure sense or data, we

91
00:07:04,540 --> 00:07:08,140
can use that method here to identify what arrives here.

92
00:07:08,290 --> 00:07:09,340
But this is simplified.

93
00:07:09,340 --> 00:07:11,070
We simply say new value.

94
00:07:11,800 --> 00:07:14,520
OK, let's build it and see what we've got.

95
00:07:14,620 --> 00:07:15,970
Now click over here to build.

96
00:07:18,260 --> 00:07:21,770
OK, we've not placed the prototype of this.

97
00:07:22,940 --> 00:07:26,500
Tosk function at a topia, so I'll place that over here.

98
00:07:27,870 --> 00:07:28,810
We're looking good.

99
00:07:28,830 --> 00:07:30,030
Click over here to build.

100
00:07:32,660 --> 00:07:33,860
It's built successfully.

101
00:07:34,820 --> 00:07:43,070
OK, I'm going to right click over here and also run us a STEM 32 double click on Gatekeeper.

102
00:07:44,400 --> 00:07:46,530
And I'll say, OK, over here.

103
00:07:55,290 --> 00:07:55,950
OK.

104
00:07:57,370 --> 00:07:58,090
Says.

105
00:07:58,980 --> 00:08:00,840
Download verified successfully.

106
00:08:01,820 --> 00:08:05,780
So I'm going to open this and I can see we have new value.

107
00:08:06,820 --> 00:08:09,260
OK, but that is rather strange.

108
00:08:09,790 --> 00:08:11,530
We simply have in our.

109
00:08:12,460 --> 00:08:18,550
Sense of value only, we're not receiving anything we have in just our digital sense of value.

110
00:08:18,580 --> 00:08:19,450
I'm pressing the button.

111
00:08:19,460 --> 00:08:20,470
That is why he's changing.

112
00:08:20,970 --> 00:08:24,280
We're not receiving the atkeson.

113
00:08:24,280 --> 00:08:27,400
So let's see where we could have gone wrong.

114
00:08:28,180 --> 00:08:29,320
We have this here.

115
00:08:32,290 --> 00:08:33,130
This is it's.

116
00:08:35,250 --> 00:08:36,510
We are in this.

117
00:08:37,610 --> 00:08:39,290
And it looks so to cue.

118
00:08:42,990 --> 00:08:43,650
AK.

119
00:08:47,410 --> 00:08:53,290
OK, we could solve this by making it more stable, we can just increase v task delay here from one

120
00:08:53,290 --> 00:08:56,620
to ten and then ten, OK?

121
00:08:57,730 --> 00:08:59,290
So click over here to build.

122
00:09:01,770 --> 00:09:04,720
It's built successfully, I'll click here to run.

123
00:09:16,630 --> 00:09:22,090
It's running, says the sea, as you can see now, we have our unlock value.

124
00:09:23,460 --> 00:09:27,090
And then or pushbutton, when I push, you can see it's change.

125
00:09:27,470 --> 00:09:33,690
OK, so this all the wrist, this all the wrist with regards to the gatekeeper to ask any questions,

126
00:09:33,690 --> 00:09:37,240
leave them in the questions and answers area and I'll see you later.

127
00:09:37,260 --> 00:09:38,150
Have a nice day.
