blob: 376503e02663014ccff8d1425df7022b80dac42c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/*
* Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2022/01/20 bernard the first version
*/
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <rtthread.h>
#include <msh.h>
int em_init(void)
{
int count = 5;
char *em_cmd = "/services/em.elf &";
while (count --)
{
int fd;
fd = open("/services/em.elf", O_RDONLY);
if (fd >= 0)
{
close(fd);
msh_exec(em_cmd, rt_strlen(em_cmd) + 1);
return 0;
}
else
{
rt_thread_mdelay(500);
}
}
if (count <= 0)
{
printf("open em failed!\n");
}
return -1;
}
INIT_APP_EXPORT(em_init);
|