1
00:00:00,660 --> 00:00:10,740
Up to now, we have been programming the 3-2 by having it constantly connected to the computer and we

2
00:00:10,740 --> 00:00:15,230
were able to click on the green button to get the program to run.

3
00:00:15,770 --> 00:00:21,570
I imagine when you have finished development and you want your hospitality to be independent of your

4
00:00:21,570 --> 00:00:28,570
computer and to be able to automatically execute a given script when power is applied.

5
00:00:29,190 --> 00:00:31,980
There's a couple of ways by which you can do that in this.

6
00:00:31,980 --> 00:00:37,470
Let's show you both of them both ways involve the supply file.

7
00:00:37,890 --> 00:00:45,480
So the bid to be fine as long as it exists, is going to be the file that the EPA authority will attempt

8
00:00:45,480 --> 00:00:48,340
to execute when it's powered up.

9
00:00:48,750 --> 00:00:54,480
You can see here that in this instance, it does have some code in it, but it's all commented out.

10
00:00:54,480 --> 00:00:58,770
And that's why when we do start the hospitality, nothing happens.

11
00:00:59,100 --> 00:01:01,910
There is code that is coming out is not going to be executed.

12
00:01:03,390 --> 00:01:05,600
You can replace this code with your own code.

13
00:01:05,610 --> 00:01:07,310
So I'm going to do this right now.

14
00:01:07,320 --> 00:01:13,590
I'm going to copy the code from previous lecture and I'm going to pasted here.

15
00:01:13,800 --> 00:01:17,010
It's going to leave the previous committed out code as it is.

16
00:01:17,460 --> 00:01:21,570
I'm going to paste it in here and then save this file.

17
00:01:22,880 --> 00:01:29,180
Now, what I'm going to do is I'm going to disconnect the computer, cable, USB, cable, and I'm going

18
00:01:29,180 --> 00:01:33,050
to replace it with a cable that I have connected to a power supply.

19
00:01:33,230 --> 00:01:41,300
This one's a battery power supply and plug it in and you can see the reality is blinking, meaning that

20
00:01:41,420 --> 00:01:44,060
my code in the P.

21
00:01:44,120 --> 00:01:46,730
Y script is being executed.

22
00:01:48,380 --> 00:01:49,600
So that's the first way.

23
00:01:50,950 --> 00:01:59,380
Could you connect my Richard back to my computer and now let's see what happens.

24
00:01:59,410 --> 00:02:06,730
Remember that pill, one that contains code and my attitude is executing it, which means that it's

25
00:02:06,730 --> 00:02:11,200
locked inside this loop, going to click on the stop restart back in button.

26
00:02:12,510 --> 00:02:13,230
And.

27
00:02:14,550 --> 00:02:20,430
I'm not getting any files in the file browser for the connected device.

28
00:02:21,610 --> 00:02:28,960
Because, again, the device is busy executing the Blink script, so I'm going to send a control scene

29
00:02:28,960 --> 00:02:36,490
to interrupt the execution so that the device is released and I can continue to interact with it via

30
00:02:36,490 --> 00:02:36,960
Sony.

31
00:02:37,540 --> 00:02:38,530
So that's something to remember.

32
00:02:38,530 --> 00:02:44,140
When you do have a script that contains infinite loops like that, you need to remember to hit control,

33
00:02:44,140 --> 00:02:47,490
see to regain control of the device.

34
00:02:48,280 --> 00:02:56,140
So the first way is to just simply copy your code inside the file and then it will execute the contained

35
00:02:56,140 --> 00:02:56,590
code.

36
00:02:57,520 --> 00:03:01,150
But a better way to go about doing this is to use input.

37
00:03:01,430 --> 00:03:07,390
And because we already have the code that we want to execute on bood in a separate file, we don't want

38
00:03:07,390 --> 00:03:09,540
really to copy across into the boot.

39
00:03:09,550 --> 00:03:16,840
So a better way to do that and reuse the work that we have already done is to use the import function

40
00:03:16,840 --> 00:03:19,990
and just simply import Elida.

41
00:03:20,020 --> 00:03:22,310
And it's called Blinkx without the extensions.

42
00:03:23,050 --> 00:03:24,190
So this.

43
00:03:25,800 --> 00:03:31,200
To save this file, so say the new version of Bitter Pill, why so what's going to happen now is when

44
00:03:31,590 --> 00:03:35,990
power is applied to the big three to it is going to look inside.

45
00:03:36,000 --> 00:03:37,990
Would it be wise for executable code?

46
00:03:38,010 --> 00:03:42,510
It's going to find a link to the ality and it's called blink.

47
00:03:42,510 --> 00:03:46,830
That file will import it and they will execute it as it comes in.

48
00:03:47,160 --> 00:03:52,780
And the effect is going to be exactly the same, except that now we can continue working on our ALYDA

49
00:03:52,980 --> 00:03:59,460
linked or Peepli File, knowing that it will be executed on boot up because of the input instruction

50
00:03:59,460 --> 00:04:02,020
in line seven of the top file.

51
00:04:03,300 --> 00:04:05,760
So I've got my input statement here.

52
00:04:05,760 --> 00:04:12,150
But just one thing that I've noticed is that the ability in cobbling to Kidwai file is not my ISP through

53
00:04:12,150 --> 00:04:17,640
the device, it's on my local file system, so I won't need to bring it across.

54
00:04:18,300 --> 00:04:22,230
I believe there is this file here, so I'm just going to upload it.

55
00:04:22,980 --> 00:04:31,100
And now that it is here, that reference will actually be correct and it will work.

56
00:04:31,110 --> 00:04:31,480
All right.

57
00:04:31,500 --> 00:04:41,360
So I'm going to unplug the data from my computer and then bring the power cable from the battery room.

58
00:04:41,910 --> 00:04:42,680
And there you go.

59
00:04:42,690 --> 00:04:43,200
It works.

60
00:04:49,460 --> 00:04:56,690
Let's connect back to Sony, and it's like power, like two computers, USB, cable.

61
00:05:01,020 --> 00:05:05,280
And the hospital, too, is now locked into the infinite loop.

62
00:05:06,320 --> 00:05:10,550
So I'm going to hit on the stop button to restart the back end.

63
00:05:12,360 --> 00:05:13,920
And then control, see?

64
00:05:16,030 --> 00:05:19,150
To stop the execution and we've got control back.

65
00:05:20,330 --> 00:05:29,330
OK, so let's sit with the two methods by which you can automatically run a program on time or power

66
00:05:29,330 --> 00:05:37,160
up on your AHP suited to the last thing that I want to show you in this section is how to do simple

67
00:05:37,160 --> 00:05:43,180
debugging of your of Python scripts using phony I.D. And we'll do that in the next lecture.
