1
00:00:00,630 --> 00:00:01,680
Hello, welcome back.

2
00:00:02,010 --> 00:00:07,500
In this lesson, we going to see how to send more complex data using our cues.

3
00:00:07,770 --> 00:00:10,470
I'm going to make a copy of the last project.

4
00:00:10,500 --> 00:00:15,990
I'll copy this and I'll paste over here and I'll rename this to number 16.

5
00:00:18,320 --> 00:00:20,930
Send in complex data with Qs.

6
00:00:27,830 --> 00:00:31,730
Later, with cues like this.

7
00:00:35,080 --> 00:00:41,830
It's done, karpin, I'm going to expand to number 16 over here and I'm going to open my window to see.

8
00:00:43,710 --> 00:00:44,730
OK, so.

9
00:00:45,770 --> 00:00:52,610
In order to make this easily understandable, I'm going to delete all of our tasks so that we start

10
00:00:52,610 --> 00:00:53,230
from scratch.

11
00:00:55,330 --> 00:01:01,720
So this is the receiver task in this last project, I'm going to delete it, I'm going to delete our

12
00:01:01,720 --> 00:01:03,810
send a task one and two as well.

13
00:01:08,690 --> 00:01:09,250
OK.

14
00:01:11,020 --> 00:01:16,060
And in here, our main function, I'm going to delete everything in it.

15
00:01:23,310 --> 00:01:23,930
OK.

16
00:01:29,940 --> 00:01:31,290
So what we have.

17
00:01:32,810 --> 00:01:40,580
We have just our project with you at this hour, you are to function the targets in for printf and these

18
00:01:40,580 --> 00:01:46,180
are our standard system Klok, the one that we started with when we created a project which Cuba makes

19
00:01:46,370 --> 00:01:47,400
this our main function.

20
00:01:47,780 --> 00:01:50,470
Currently, there is no ARTUS running.

21
00:01:51,020 --> 00:01:54,030
We've just included our Simms's always thought each file here.

22
00:01:54,440 --> 00:01:57,770
OK, so we're going to start off by creating a structure.

23
00:01:57,780 --> 00:01:59,830
Our data is going to be held in this structure.

24
00:02:00,260 --> 00:02:08,240
I'm going to create unenumerated type and then from that accretes structure, I'll start off by creating

25
00:02:08,450 --> 00:02:09,650
an enumerator type.

26
00:02:09,830 --> 00:02:13,550
Let's say our system has humidity sensor and a pressure saying so.

27
00:02:13,940 --> 00:02:16,160
So we're going to have this enumerator taip.

28
00:02:17,760 --> 00:02:22,380
Humidity, Senso is the first element, pressure sensor is the second element, and we call in this

29
00:02:22,380 --> 00:02:23,100
data source.

30
00:02:23,770 --> 00:02:25,200
OK, so now.

31
00:02:26,420 --> 00:02:29,930
We going to create a structure or structure, it's going to have two members.

32
00:02:31,410 --> 00:02:38,460
The first member is going to be the value of the senso so value and then the second member is of type

33
00:02:38,460 --> 00:02:39,210
datasource.

34
00:02:41,200 --> 00:02:48,250
So we have this structure, we first created an enumerator type humidity saying so in Pregerson so as

35
00:02:48,250 --> 00:02:52,990
its members, and then we have this structure with two members and this structure here, which represents

36
00:02:52,990 --> 00:03:01,150
our data and the data item here has a value and the source of the data.

37
00:03:02,050 --> 00:03:03,820
OK, so far, so good.

38
00:03:04,390 --> 00:03:09,790
Next, we're going to declare two data variables that will be passed to our cue because we want to see

39
00:03:09,790 --> 00:03:12,520
how to parse these complex data types to our cue.

40
00:03:12,920 --> 00:03:16,130
So we're going to declare two variables.

41
00:03:16,360 --> 00:03:18,610
So I'm going to come over here.

42
00:03:20,150 --> 00:03:20,870
Sorry about that.

43
00:03:23,150 --> 00:03:30,500
We have this array here called struct instructed to send and the array has a size of two.

44
00:03:31,520 --> 00:03:32,930
The first I remember.

45
00:03:34,310 --> 00:03:43,010
Is this one here, remember, the array type is of data type of data over here, so if it's of data,

46
00:03:43,010 --> 00:03:47,240
then each each element in the array has to members.

47
00:03:49,110 --> 00:03:51,750
Because this year has two members, so.

48
00:03:52,760 --> 00:03:55,190
We've we've created an array of data.

49
00:03:56,140 --> 00:04:03,100
And then the first data is this one here, which has seventy seven and then humidity, SENSO And the

50
00:04:03,100 --> 00:04:05,470
second data is this one here, OK?

51
00:04:05,560 --> 00:04:06,760
And I hope you understand this.

52
00:04:06,760 --> 00:04:14,530
The reason we have this and this is in our data structure, the first element is that you each value.

53
00:04:14,530 --> 00:04:21,150
The second element is of type data source, which can be humidity sensor or pressure.

54
00:04:21,250 --> 00:04:26,680
And so that is why we have this, because our structure is of type data.

55
00:04:27,530 --> 00:04:28,060
OK.

56
00:04:29,850 --> 00:04:36,750
So we've created our data that our Q is going to send, OK, so we're going to have.

57
00:04:38,290 --> 00:04:44,740
We're going to have three tasks, we're going to have the humidity task, the pressure task, and they

58
00:04:44,740 --> 00:04:50,050
receive a task to do this, we first declared task on those.

59
00:04:51,920 --> 00:04:54,180
So we have three task condos here.

60
00:04:54,680 --> 00:05:00,170
We have this one for humidity, tasc, this one for pressure task and this one for the receiver task.

61
00:05:00,990 --> 00:05:02,840
Also, we're going to declare a Q.

62
00:05:04,260 --> 00:05:10,260
We declare AQ here, we call in this Q excuse the standard name we use for our Qs.

63
00:05:12,900 --> 00:05:13,410
OK.

64
00:05:15,830 --> 00:05:22,760
So once this is done, we're going to go to our main function and create a queue, so we're going to

65
00:05:22,760 --> 00:05:24,470
create a queue to hold.

66
00:05:26,050 --> 00:05:31,900
Data, remember, we've created our own variable, our own data type known as data, so our cue is going

67
00:05:31,900 --> 00:05:32,860
to hold this type.

68
00:05:33,380 --> 00:05:37,900
Our previous Qs have held you into 32 and other data types.

69
00:05:38,140 --> 00:05:42,100
This time we've defined our own data type that AQ is going to hold.

70
00:05:42,500 --> 00:05:44,590
So come down here and create.

71
00:05:44,590 --> 00:05:45,900
Q I'll see Lidsky.

72
00:05:45,900 --> 00:05:52,660
You have a maximum of three structures, so the size is of safe size data over here, a maximum of three.

73
00:05:53,500 --> 00:05:55,690
Once that is done, we're going to create.

74
00:05:57,140 --> 00:05:59,120
Our receiver, TASC.

75
00:06:00,870 --> 00:06:03,450
With a priority of one.

76
00:06:05,610 --> 00:06:11,700
We have this receiver task, then we're going to create our center task.

77
00:06:12,840 --> 00:06:20,850
We're going to create two center tasks, one is going to be for our humidity task and then the other

78
00:06:20,850 --> 00:06:24,150
one is going to be for our pressure task.

79
00:06:24,960 --> 00:06:32,380
So we create this center task with priority of two higher than the priority of the receiver task.

80
00:06:32,970 --> 00:06:40,410
And over here, we're going to have the same task function called center task for both tasks such that

81
00:06:40,410 --> 00:06:43,890
we pass what is sent as task argument.

82
00:06:44,040 --> 00:06:46,770
That is why over here we see the center task.

83
00:06:47,010 --> 00:06:49,770
The name of this task is humidity center task.

84
00:06:50,190 --> 00:06:51,750
And we pass another argument.

85
00:06:51,750 --> 00:06:53,940
Our structure, our array.

86
00:06:53,940 --> 00:07:00,450
Here we see the first element in the array should be parsed as argument to this task as we have structures

87
00:07:00,450 --> 00:07:04,170
to send index zero for this first element.

88
00:07:06,830 --> 00:07:12,680
Once that is done, we going to create the task for the precious angel.

89
00:07:14,990 --> 00:07:17,030
And we have our essential task here.

90
00:07:17,950 --> 00:07:20,530
OK, so we have three tasks.

91
00:07:22,120 --> 00:07:30,310
We have the receiver task humidities and our task pressure center task, however, our humidity center

92
00:07:30,310 --> 00:07:37,810
task and pressure sensor pressure center task would share the same task function and we'll be passing

93
00:07:38,140 --> 00:07:42,460
what is to be sent a document to the task function.

94
00:07:42,640 --> 00:07:48,730
As we've indicated over here, over here, we are sending the content of our struct to send our index

95
00:07:48,730 --> 00:07:54,580
one because we know index one here corresponds to the pressure information, pressure, sensor information.

96
00:07:55,120 --> 00:08:02,170
And then in the humidity sensor, we send in struct to send index zero because we know index zero corresponds

97
00:08:02,170 --> 00:08:04,660
with the humidity sensor information.

98
00:08:05,260 --> 00:08:07,450
OK, so once that is done.

99
00:08:08,820 --> 00:08:11,370
We going to create our center task.

100
00:08:13,020 --> 00:08:16,170
So come down here, the task function for us in the task.

101
00:08:19,120 --> 00:08:26,740
We can use this to hold a status of any action we take, such as when we want to receive data such as

102
00:08:26,740 --> 00:08:33,460
one such as when we want to send data across course the a task and also we're going to define it.

103
00:08:33,460 --> 00:08:34,180
Blocked states.

104
00:08:36,040 --> 00:08:41,590
So over here, we are going to see into the block two states for two hundred milliseconds if the queue

105
00:08:41,590 --> 00:08:43,600
is full, because this center task.

106
00:08:44,940 --> 00:08:50,550
They are to send the tasks that will be sent into the same queue, so enter the blocked state for two

107
00:08:50,550 --> 00:08:56,140
hundred four for space to become available in the queue each time the queue is full.

108
00:08:56,250 --> 00:08:58,620
So we've just defined this week's time here.

109
00:08:58,740 --> 00:09:04,170
And we're going to take this wait time and parse out the third argument in our excuse and function.

110
00:09:07,730 --> 00:09:08,960
So we can see.

111
00:09:10,380 --> 00:09:12,330
We can open our one loop here.

112
00:09:14,190 --> 00:09:15,300
You see, while.

113
00:09:17,400 --> 00:09:23,130
One over here, and then we start off by sending.

114
00:09:24,470 --> 00:09:25,550
What are we going to send?

115
00:09:26,210 --> 00:09:35,750
We're going to send the parents remember, we passing parameters to these to the send a task and the

116
00:09:35,750 --> 00:09:37,700
parameter here is what we want to send.

117
00:09:37,720 --> 00:09:44,900
So we just said we send in this to our HQ and we want to wait for this amount of time and then we save

118
00:09:44,900 --> 00:09:45,770
the status here.

119
00:09:47,660 --> 00:09:53,330
And if status is not equal to pass, we want to we could print something.

120
00:09:54,790 --> 00:10:01,090
Or we could give an indication to show that AQ is full so we can make use of our status here, but now

121
00:10:01,090 --> 00:10:04,690
I wouldn't print anything or just leave it empty or do something here.

122
00:10:05,930 --> 00:10:12,170
And then we can put a bit of delay, a bit of a delay here by just putting a loop.

123
00:10:13,780 --> 00:10:18,280
Right, so this loop is just like delay without putting the task in a blocked state.

124
00:10:18,840 --> 00:10:19,380
OK.

125
00:10:20,310 --> 00:10:24,810
So this whole center task, this single center task is going to service.

126
00:10:25,770 --> 00:10:32,100
The two center tasks that we've created and we are using task parameters here.

127
00:10:33,120 --> 00:10:35,970
To send their respective data.

128
00:10:36,900 --> 00:10:43,110
OK, so once that is done, we're going to deal with the humidity task over here, we said a humidity

129
00:10:43,110 --> 00:10:43,630
task.

130
00:10:43,710 --> 00:10:46,350
Oh, sorry, we're going to deal with a receiver task.

131
00:10:47,010 --> 00:10:48,610
Let's call it receiver task.

132
00:10:48,720 --> 00:10:50,160
The name is written us.

133
00:10:52,120 --> 00:10:54,620
Task one over here, so receive a task.

134
00:10:54,640 --> 00:11:01,120
We're going to create the task function for the receiver task force, avoid receive receiver task and

135
00:11:01,120 --> 00:11:06,520
this takes just like all tasks, PvP firearms or Peevey parameters.

136
00:11:09,030 --> 00:11:11,110
So argument and then open, close.

137
00:11:11,820 --> 00:11:17,670
So we're going to receive data, the data we're going to receive is going to be of type data because

138
00:11:17,670 --> 00:11:19,880
that is what we are sending is going to be of this type.

139
00:11:20,190 --> 00:11:23,910
So we have to create a variable of this type to hold the data we receive.

140
00:11:25,080 --> 00:11:29,700
So I'll create that variable, I'll call it received structure.

141
00:11:32,710 --> 00:11:36,670
Here we are, and then we created a variable to hold a status.

142
00:11:37,600 --> 00:11:41,980
OK, so once that is done, we're going to open our infinite loop.

143
00:11:49,200 --> 00:11:51,960
And we're going to we're going to receive.

144
00:11:53,620 --> 00:12:01,330
So to receive, we call our security function and when we receive Wistar, it's in our variable that

145
00:12:01,330 --> 00:12:02,470
we've created over here.

146
00:12:03,110 --> 00:12:03,580
OK.

147
00:12:04,570 --> 00:12:08,290
And then once that is done, we're going to check the status.

148
00:12:09,530 --> 00:12:14,990
If the status is passed, then we're going to inspect the data to know where it came from so that we

149
00:12:14,990 --> 00:12:20,240
can identify whether it's humidity data or it's pressure data.

150
00:12:22,560 --> 00:12:28,140
So over here, Q Status equals speed pass, meaning we've received.

151
00:12:29,320 --> 00:12:36,850
So if we've received then then we can check the structure contents, because we know in our data, in

152
00:12:36,850 --> 00:12:37,660
our data.

153
00:12:38,570 --> 00:12:46,790
Elements here, if we can find this member, the second member of the data, we can know whether it's

154
00:12:46,940 --> 00:12:49,850
from humidity sense or from pressure saying so.

155
00:12:50,090 --> 00:12:55,820
So we're going to access the data and then access the second member to find where it is from.

156
00:12:56,450 --> 00:13:02,480
OK, so to do that, we simply use on this condition to check.

157
00:13:02,700 --> 00:13:04,510
So I'll come in here and I'll see.

158
00:13:05,430 --> 00:13:06,630
This is the received data.

159
00:13:06,650 --> 00:13:08,810
This is where we start to receive data.

160
00:13:08,840 --> 00:13:13,480
So receive data dots as datasource, remember, receive data.

161
00:13:13,730 --> 00:13:14,720
It's a structure.

162
00:13:17,290 --> 00:13:24,760
Is of this type, and this type has a member states Assoc., and this is DataSource is off type Annu,

163
00:13:25,300 --> 00:13:28,090
the values can be humidity or pressure preciousness.

164
00:13:28,100 --> 00:13:30,550
So, OK, so we check that.

165
00:13:31,930 --> 00:13:33,070
So we see.

166
00:13:34,970 --> 00:13:35,600
Where are we?

167
00:13:36,670 --> 00:13:43,150
If DataSource is humidity sensible, then we want to preserve humidity, sense of value percentage,

168
00:13:44,280 --> 00:13:50,860
and then we can print the value with the actual value by accessing the value member of the structure.

169
00:13:53,210 --> 00:13:55,490
OK, so since we have this.

170
00:13:56,410 --> 00:14:01,690
Two data sources we can use on Ellis condition to see, OK, if it's not humidity or.

171
00:14:02,660 --> 00:14:04,850
Then it has to be our precious and so.

172
00:14:06,960 --> 00:14:15,440
So in that case, we print the value the same way, but we use the word precious and so here, OK,

173
00:14:15,660 --> 00:14:20,490
so this is if we receive the data, if Kyuss, that is equal speed pass.

174
00:14:20,880 --> 00:14:22,290
What if it's not PDE pass?

175
00:14:22,560 --> 00:14:29,670
Perhaps we want to do something, print something or do something over here or simply say do something.

176
00:14:29,670 --> 00:14:36,570
You can add your own code here if you want some particular action or a particular flag.

177
00:14:37,460 --> 00:14:45,290
To be set when Q status is not true or is not passed, you can put that information here.

178
00:14:45,890 --> 00:14:50,870
OK, so once we've done this, we are ready to test out our project.

179
00:14:51,500 --> 00:14:57,920
What are we going to do is put the prototypes of our to ask and receive a task at the top of the file,

180
00:14:58,160 --> 00:14:59,750
a copy of this controversy.

181
00:15:02,060 --> 00:15:02,660
And then.

182
00:15:03,880 --> 00:15:10,330
I'll come over here, send a task, and then come down here to grab our receiver task.

183
00:15:11,690 --> 00:15:13,730
Is the receiver task controversy.

184
00:15:14,750 --> 00:15:16,660
And then I'll paste this over here.

185
00:15:18,930 --> 00:15:21,630
OK, now we're looking good.

186
00:15:23,160 --> 00:15:24,630
So I'm going to build.

187
00:15:26,240 --> 00:15:30,350
Going to right click and then would project over here.

188
00:15:33,140 --> 00:15:35,000
We have a number of errors, see?

189
00:15:36,620 --> 00:15:37,280
It says.

190
00:15:38,280 --> 00:15:39,480
Receiver TASC.

191
00:15:40,790 --> 00:15:42,230
But as I say, let's see.

192
00:15:43,180 --> 00:15:47,720
Expect a declaration specify before start talking.

193
00:15:47,800 --> 00:15:52,780
OK, I forgot to put the word void here in the receiver task.

194
00:15:54,800 --> 00:15:55,350
OK.

195
00:15:56,500 --> 00:15:57,250
Click to build.

196
00:16:02,860 --> 00:16:06,370
OK, we have no error now I'm going to right click.

197
00:16:07,220 --> 00:16:10,340
And I'm going to say run us SDM 30 to.

198
00:16:12,250 --> 00:16:14,350
A select number 16 over here.

199
00:16:14,860 --> 00:16:15,480
OK.

200
00:16:17,430 --> 00:16:19,110
And then OK, over here.

201
00:16:24,680 --> 00:16:26,780
OK, it's flushing onto the board.

202
00:16:28,670 --> 00:16:31,910
It's done, I'm going to open our realtor.

203
00:16:34,700 --> 00:16:40,430
I'll clean the previous experiment and I'm going to click to open the port.

204
00:16:42,260 --> 00:16:45,010
I'm going to reset the board by pressing the MCU.

205
00:16:48,750 --> 00:16:51,180
Let's see real time, it's not responded.

206
00:16:53,650 --> 00:16:55,900
I'm going to restart real time to see.

207
00:16:57,930 --> 00:17:06,260
OK, here it is, I'm going to select New Line Mode Port over here, it's the same.

208
00:17:06,900 --> 00:17:07,560
And then.

209
00:17:08,780 --> 00:17:10,760
Moderate's is the same policies, 16.

210
00:17:12,280 --> 00:17:18,170
OK, so this has to be from our quote, let's see what the issue could be up.

211
00:17:18,550 --> 00:17:21,560
Let's make sure we initialised our you out.

212
00:17:21,620 --> 00:17:22,300
All right.

213
00:17:23,090 --> 00:17:24,970
Oh, goodness, forgive me.

214
00:17:25,330 --> 00:17:27,250
I forgot to start the scheduler.

215
00:17:28,350 --> 00:17:30,330
We created the tasks.

216
00:17:31,240 --> 00:17:34,140
And over here is our main function there.

217
00:17:34,210 --> 00:17:36,490
Snow starts churchly here, of course.

218
00:17:37,970 --> 00:17:41,760
That is not supposed to work, so we have to start our scheduler.

219
00:17:42,840 --> 00:17:44,000
Click here to build again.

220
00:17:46,730 --> 00:17:52,760
It's built successfully, we're right, click over here, run us SDM 30 to.

221
00:17:54,390 --> 00:17:59,400
Click on number 16 over here for the current project, and it's flashing onto the board.

222
00:18:02,140 --> 00:18:02,950
And to see.

223
00:18:05,950 --> 00:18:07,090
Download successful.

224
00:18:07,210 --> 00:18:08,830
OK, now we can see our data.

225
00:18:09,780 --> 00:18:17,760
And indeed, we can see it come one after the other and of of close the ports, if you see indeed our

226
00:18:17,760 --> 00:18:18,900
precious sense of value.

227
00:18:20,240 --> 00:18:26,870
Precious sense of value is 63 and our humidity sense of value is seventy seven, and that's what we're

228
00:18:26,870 --> 00:18:34,280
seeing and we can replace these static values with value being recorded from a pressure sensor installed

229
00:18:34,280 --> 00:18:34,960
in the structure.

230
00:18:34,970 --> 00:18:42,230
We can easily do that by initializing our ADC and then just collecting the sensor data and placing it

231
00:18:42,710 --> 00:18:44,300
at this particular location.

232
00:18:44,990 --> 00:18:45,500
OK.

233
00:18:46,560 --> 00:18:53,160
So in a way, this is how to send more complex data using our cues and to be able to identify the data

234
00:18:53,190 --> 00:18:53,700
as well.

235
00:18:54,090 --> 00:18:55,130
So that's all there is.

236
00:18:55,170 --> 00:18:56,450
I'll see you in the next lesson.

237
00:18:56,460 --> 00:18:57,320
Have a nice day.
