1
00:00:00,600 --> 00:00:01,690
Hello, welcome back.

2
00:00:01,710 --> 00:00:08,310
In this lesson, we're going to see how to interact with our drivers further, we going to see how to

3
00:00:08,310 --> 00:00:14,550
receive data from the Ewart's and then started data in a queue and then use it for whatever we want

4
00:00:14,550 --> 00:00:15,540
to use it for.

5
00:00:16,110 --> 00:00:22,020
The reason we want to see this is because we want to compare two methods of achieving this.

6
00:00:22,500 --> 00:00:28,080
In this first lesson, we're going to pull the US mean and we're going to check whether there's new

7
00:00:28,080 --> 00:00:29,070
data to collect.

8
00:00:29,670 --> 00:00:36,930
And this would save us the lesson that would give us a bit of understanding before we go and implement

9
00:00:36,930 --> 00:00:38,490
uninterrupted version of this.

10
00:00:38,910 --> 00:00:45,930
And by implementing the interruptive version, we'll see how to properly interact with Incorrupt.

11
00:00:47,190 --> 00:00:53,390
Interactivity interrupts That's quite somewhat OK, we'll see how to properly interact with interrupt

12
00:00:53,400 --> 00:00:55,580
without disturbing our Toscano.

13
00:00:56,280 --> 00:00:59,430
So I'm going to make a copy of how some drivers.

14
00:01:00,800 --> 00:01:08,690
Uh, project over here, a copy this and then I'll paste this over here and I'll call this.

15
00:01:11,460 --> 00:01:12,870
Interacting with drivers.

16
00:01:18,130 --> 00:01:21,490
And then this is you are Torex, we said we're going to make.

17
00:01:23,480 --> 00:01:24,020
OK.

18
00:01:29,450 --> 00:01:34,610
We're going to explain this and then get out, may not see foul play here.

19
00:01:36,790 --> 00:01:40,060
OK, what we have here, we simply have our driver snow tax.

20
00:01:40,730 --> 00:01:43,810
OK, so we going to create a number of.

21
00:01:45,350 --> 00:01:54,650
Tasks will create one task to pull the ads for new data and then another task to handle the data.

22
00:01:55,220 --> 00:01:55,730
OK.

23
00:01:59,920 --> 00:02:08,230
OK, so we're going to start off by defining our stock size, going to define a stock of five one two

24
00:02:08,230 --> 00:02:14,290
bytes rather than put a stock size in the function we can just represent with a symbolic name here.

25
00:02:14,320 --> 00:02:20,320
I'm just trying to show you a more readable way of writing what we've been writing off and we've been

26
00:02:20,320 --> 00:02:24,910
putting these stock sized value directly in the Eckstut task rate function.

27
00:02:25,120 --> 00:02:28,130
But we can define it over here so that we can represent it with this value.

28
00:02:28,750 --> 00:02:32,270
OK, once that is done, I'm going to create a queue.

29
00:02:32,530 --> 00:02:35,890
This queue will be used to hold the data received by the others.

30
00:02:36,370 --> 00:02:42,040
And what I mean by creating a queue is actually declared a queue hondo because we have to explicitly

31
00:02:42,040 --> 00:02:42,970
create the queue.

32
00:02:43,540 --> 00:02:44,830
So we have this queue Hondo.

33
00:02:45,700 --> 00:02:46,150
Right.

34
00:02:46,450 --> 00:02:52,000
And we going to create our UAT to ask this.

35
00:02:52,000 --> 00:02:55,870
We are familiar with X task create.

36
00:02:56,230 --> 00:02:58,540
This is going to be the name of the task function.

37
00:02:58,540 --> 00:03:03,010
POJ you are to receive is the name of the what is the name of the task.

38
00:03:03,160 --> 00:03:05,430
And a stack size is what we define over here.

39
00:03:05,890 --> 00:03:12,180
We don't have any arguments and we're not using task on those over here and this one too.

40
00:03:12,190 --> 00:03:18,580
This is an interesting way of writing a task priority rather than putting an absolute value here.

41
00:03:19,090 --> 00:03:28,990
We can simply see let this task have a priority of let's this task priority be to above the lowest priority.

42
00:03:29,590 --> 00:03:34,120
The lowest priority in our ARTUS is the ideal task which we shall visit.

43
00:03:34,600 --> 00:03:38,410
We shall experiment with the ideal task later that.

44
00:03:39,420 --> 00:03:45,090
If we've not already we have, based on where I'm going to position the lesson in the course, if you've

45
00:03:45,090 --> 00:03:48,660
not dealt with the ideal task already, there is a lesson for it.

46
00:03:48,660 --> 00:03:51,120
But if you have already, then you know what I'm talking about.

47
00:03:51,120 --> 00:03:53,290
The ideal task has the lowest priority.

48
00:03:53,520 --> 00:03:59,550
So we're saying give this priority, this task a priority to above the ideal task and this a more readable

49
00:03:59,550 --> 00:04:02,010
way of writing task priorities.

50
00:04:02,490 --> 00:04:08,060
OK, so once that is done, we're going to create a task to handle the Ewart's data.

51
00:04:08,280 --> 00:04:10,920
So we're going to simply call this the handler task.

52
00:04:11,310 --> 00:04:13,290
That's going to be the name of the task function.

53
00:04:13,290 --> 00:04:17,340
And we'd given it its name, its task name as you are to bring to task.

54
00:04:17,640 --> 00:04:20,370
And we've given this a priority above the pool.

55
00:04:20,490 --> 00:04:22,110
You ought to ask.

56
00:04:22,720 --> 00:04:25,320
OK, once that is done, we're going to create our Q.

57
00:04:26,300 --> 00:04:32,000
Remember, our Q Hundun is called this, you are two by two received, we're going to see the Q should

58
00:04:32,000 --> 00:04:37,100
hold a maximum of ten items, OK, we create a Q A simple as this.

59
00:04:37,730 --> 00:04:43,340
And once we've created a Q, we're going to start our scheduler, OK, like this.

60
00:04:44,660 --> 00:04:51,800
Now what we have to do is write the task functions of our of our tasks.

61
00:04:52,100 --> 00:04:53,150
We have to task.

62
00:04:53,150 --> 00:04:56,270
The first one is called the Post you add.

63
00:04:59,270 --> 00:05:02,510
Over here, we simply come down and create a task function.

64
00:05:06,610 --> 00:05:08,500
And here we have an infinite loop.

65
00:05:12,040 --> 00:05:21,010
OK, so remember, this is how some drivers project where we initialize our CPU and then our ADC here,

66
00:05:21,220 --> 00:05:22,000
we don't need this.

67
00:05:22,810 --> 00:05:25,360
We don't need ADC for this experiment.

68
00:05:25,930 --> 00:05:27,250
We don't need our GPU as well.

69
00:05:27,250 --> 00:05:29,840
What we need is our Ewart's, but in our mode.

70
00:05:29,860 --> 00:05:31,000
So I'm going to cut to this.

71
00:05:31,000 --> 00:05:38,050
You add in it and bring it to our you are to receive and when this task execute is going to initialize

72
00:05:38,150 --> 00:05:39,020
you at once.

73
00:05:39,160 --> 00:05:42,100
That is why this is outside of the one loop.

74
00:05:42,460 --> 00:05:46,150
We're going to do one initialization of the out like this.

75
00:05:46,210 --> 00:05:48,280
OK, you are Torex.

76
00:05:48,790 --> 00:05:51,840
And one thing, let's go to our you see fault.

77
00:05:53,470 --> 00:05:54,980
This is our you other sifa.

78
00:05:55,000 --> 00:05:56,170
We have two functions.

79
00:05:56,650 --> 00:05:59,740
We we have two initialization functions.

80
00:06:01,090 --> 00:06:07,870
IREX, we have Ewart's right over here but we don't have you are to receive so we have to implement

81
00:06:07,870 --> 00:06:13,060
a you are to receive function they receive is the same as right over here.

82
00:06:13,090 --> 00:06:14,860
You Ewart's right.

83
00:06:14,890 --> 00:06:20,860
We write into the data register so receive means just return the content of the data register like we

84
00:06:20,860 --> 00:06:29,280
did in the, like we did with regards to the ADC where we simply return the content of the data register.

85
00:06:29,890 --> 00:06:32,170
So the function is quite straightforward.

86
00:06:33,070 --> 00:06:34,650
This is how the function would appear.

87
00:06:35,800 --> 00:06:40,060
So we first pull, we wait until the character arrives just in the ADC.

88
00:06:40,060 --> 00:06:44,230
Listen, we waited for the conversion to be ready and we run.

89
00:06:44,230 --> 00:06:51,880
We wait by running an end operation with a particular bit in the you ought to start this register and

90
00:06:51,880 --> 00:06:59,380
once the character arrives, we simply return the content of the user to data register and this is our

91
00:06:59,380 --> 00:07:00,700
user to read function.

92
00:07:01,040 --> 00:07:07,150
OK, so I'm going to copy this function prototype and I'll put it in the 80s four.

93
00:07:08,770 --> 00:07:15,430
I'll open it that H over here from our includes foda base this over here.

94
00:07:17,080 --> 00:07:17,710
Like this.

95
00:07:17,770 --> 00:07:27,940
OK, so then we can go back to not see far, no, we said who pull you at received task is thought of

96
00:07:28,720 --> 00:07:32,990
by initialise in the U.S. for our X for reception.

97
00:07:33,520 --> 00:07:41,170
I'm going to create a variable here, a local variable here to store the bite's received.

98
00:07:41,410 --> 00:07:44,410
So I'll see you in eight and a squatty.

99
00:07:44,470 --> 00:07:45,700
Call this next byte.

100
00:07:49,430 --> 00:07:56,480
And then what we want to do is we want to call our receive function or you are to read function that

101
00:07:56,490 --> 00:07:57,590
we've just written.

102
00:08:00,200 --> 00:08:04,320
So you start to read, use that to underscore, read.

103
00:08:04,340 --> 00:08:05,520
That's the name of the function.

104
00:08:06,350 --> 00:08:11,540
OK, so we said this will return the character, which is a bright story here.

105
00:08:11,900 --> 00:08:18,320
And once we've received this, what we want to do is send this to our queue so we use our excuse and

106
00:08:18,530 --> 00:08:19,160
function.

107
00:08:21,920 --> 00:08:29,010
You simply saying this, and we given a block time of zero, OK, so this will send it once it's sent.

108
00:08:29,060 --> 00:08:32,530
Remember, this task simply receives and sends its checks.

109
00:08:32,840 --> 00:08:38,630
We know it's poulain because we know our users to read is basically waiting for the character.

110
00:08:38,900 --> 00:08:41,630
It gets stuck waiting for the character to become available.

111
00:08:42,020 --> 00:08:51,950
OK, so then we would go ahead and implement our other task, the task over here, which will handle

112
00:08:51,950 --> 00:08:52,820
what is received.

113
00:08:53,340 --> 00:08:57,200
OK, so this is the handler task.

114
00:08:57,830 --> 00:08:59,750
We have our infinite loop in here.

115
00:09:02,690 --> 00:09:05,780
And what we want to do is wait for.

116
00:09:06,680 --> 00:09:13,130
New data to become available in the queue and what also we want to do is declare a global variable here,

117
00:09:13,130 --> 00:09:15,700
which we can observe in the live expressions window.

118
00:09:15,890 --> 00:09:19,820
Since we're going to be using our you for our X, would you be able to see what we receive?

119
00:09:20,420 --> 00:09:22,820
So I'll see character over here.

120
00:09:22,850 --> 00:09:26,240
I receive byte to indicate the bytes that we received.

121
00:09:27,110 --> 00:09:33,740
OK, so then we going to come over here and see execute, receive.

122
00:09:34,820 --> 00:09:42,980
We want to receive, we pass our you out to buy to received which is the handle of the of the queue

123
00:09:42,980 --> 00:09:44,120
that we want to receive from.

124
00:09:44,120 --> 00:09:48,950
And this way we want to store the received data and we want to delay Portsmouth's delay.

125
00:09:49,220 --> 00:09:52,070
So meaning we delay until we receive the data.

126
00:09:52,550 --> 00:09:53,090
OK.

127
00:09:53,980 --> 00:09:58,660
So we're looking good now, let's see what we get with this.

128
00:10:00,310 --> 00:10:01,570
I'm going to click here to build.

129
00:10:03,630 --> 00:10:05,430
OK, we have a number of.

130
00:10:08,060 --> 00:10:09,500
A number of anomaly's.

131
00:10:10,820 --> 00:10:17,540
OK, so we've got you, um, we've got you enable you to go to enable.

132
00:10:18,320 --> 00:10:18,890
Let's see.

133
00:10:22,510 --> 00:10:24,010
We've got to enable Kyuss.

134
00:10:27,010 --> 00:10:32,660
What I mean by that is include the cues that each fall remember this project or the project?

135
00:10:32,680 --> 00:10:38,740
We made a copy of some driver's that's the name of the project that was just experimenting with some

136
00:10:38,740 --> 00:10:39,250
drivers.

137
00:10:39,520 --> 00:10:42,540
So we've now got some of our ARTUS components.

138
00:10:42,760 --> 00:10:47,350
So I'm going to double click on all the emphasis placed on each file open over here.

139
00:10:47,530 --> 00:10:49,150
And I'll scroll down here.

140
00:10:49,630 --> 00:10:52,010
We have this task be each, you see.

141
00:10:52,120 --> 00:10:53,920
So I'm going to include tutorage.

142
00:10:54,610 --> 00:10:59,050
OK, let's go back and let's build this and see what we've got.

143
00:10:59,830 --> 00:11:02,060
OK, we've got other anomalies.

144
00:11:02,290 --> 00:11:05,510
This has got some other reason.

145
00:11:05,560 --> 00:11:06,130
Let's see.

146
00:11:07,680 --> 00:11:08,640
Pull you out.

147
00:11:08,680 --> 00:11:13,920
OK, so we've not put the function prototypes at the top of the of the file.

148
00:11:14,620 --> 00:11:15,900
The function is unreachable.

149
00:11:16,440 --> 00:11:17,190
I'll copy this.

150
00:11:19,120 --> 00:11:25,900
Put this over here and then I'll come down here, controversy to copy.

151
00:11:27,220 --> 00:11:31,240
Put this over here, let's build take over here to build.

152
00:11:32,810 --> 00:11:34,340
OK, it's successful.

153
00:11:35,480 --> 00:11:44,670
And we're going to right click over here and see Debuggers Ystem 32, double click over here and then.

154
00:11:44,690 --> 00:11:45,230
OK.

155
00:11:50,240 --> 00:11:51,200
And then switch.

156
00:11:53,400 --> 00:11:55,410
OK, so I'm going to.

157
00:11:57,140 --> 00:11:59,960
OK, we have real time here from our previous project.

158
00:11:59,990 --> 00:12:05,060
I'm going to clear this, and what I'm going to do is I'm going to go to our.

159
00:12:06,460 --> 00:12:10,270
A website received global variable here I received.

160
00:12:10,720 --> 00:12:15,790
So when the queue receives, the data is going to store it in our website, so I'm going to.

161
00:12:17,530 --> 00:12:25,890
Going to view our debate in our live expression's window, so a copy RACV right over here, controversy

162
00:12:25,890 --> 00:12:28,860
to copy and I'll drop it over here and then hit enter.

163
00:12:29,250 --> 00:12:33,300
OK, so what I'm going to do is over here.

164
00:12:33,480 --> 00:12:40,320
All we simply need to do is come over here, click in here this side where we have the arrow blinking.

165
00:12:40,320 --> 00:12:45,960
We click in here and then we press you on our keyboard and we expect to see that received and displayed

166
00:12:45,960 --> 00:12:46,260
here.

167
00:12:47,700 --> 00:12:49,100
I'm going to click to run over here.

168
00:12:50,170 --> 00:12:58,660
And I'm going to reset the port by clicking open and then it's enter again, and then I just pressed

169
00:12:58,660 --> 00:12:59,650
one on my keyboard.

170
00:12:59,660 --> 00:13:02,220
You see, this is one this it's ASCII value.

171
00:13:02,500 --> 00:13:07,480
I'm going to press E, this is E, I'm going to press B, I'm going to press M.

172
00:13:08,590 --> 00:13:09,690
I'm going to press C.

173
00:13:10,270 --> 00:13:14,350
As you can see, I'm going to press F, make sure you click in here.

174
00:13:14,350 --> 00:13:17,470
You have to click in this dark area to to press.

175
00:13:17,830 --> 00:13:21,510
So I press G OK, so we're receiving the data.

176
00:13:21,970 --> 00:13:24,820
So this is very simple, very straightforward.

177
00:13:25,210 --> 00:13:32,380
We wanted to design a system that can receive data from the Ewart's and then another one, the system

178
00:13:32,380 --> 00:13:33,940
that receives data from the US.

179
00:13:34,330 --> 00:13:41,380
And we designed a project in a way that we have the task that deals with receiving the data itself.

180
00:13:41,380 --> 00:13:47,620
And another task, the handles the data such as printing or disk will be.

181
00:13:49,120 --> 00:13:54,400
In a more complex system, this could be a task receiving the data in another task, processing the

182
00:13:54,400 --> 00:13:56,710
data and display and displaying it.

183
00:13:57,010 --> 00:14:01,030
So this one here, our handler, is the one that processes the data.

184
00:14:01,300 --> 00:14:01,690
Right.

185
00:14:02,200 --> 00:14:04,450
So this is very simple, very straightforward.

186
00:14:05,410 --> 00:14:08,160
However, this implementation is not quite efficient.

187
00:14:08,590 --> 00:14:13,570
There are there is a lot of process or time wasted here because we are Poulan.

188
00:14:13,570 --> 00:14:16,180
We are waiting for the character to become available.

189
00:14:16,330 --> 00:14:23,860
A better implementation of this will be to use and interrupt such that we don't wait for the new bytes

190
00:14:23,860 --> 00:14:24,810
to become available.

191
00:14:25,090 --> 00:14:27,880
We just the process or just goes on to do its thing.

192
00:14:28,120 --> 00:14:34,900
And when the new byte is available, then we are told that the new bytes is available and we take it

193
00:14:34,900 --> 00:14:37,180
and handle it as we want.

194
00:14:39,250 --> 00:14:45,940
OK, so in the next lesson, we shall see how to write an interrupted version of this project.

195
00:14:46,510 --> 00:14:49,030
OK, so this all the see in the next lesson.
