-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinux_serial_program.c
More file actions
67 lines (56 loc) · 1.29 KB
/
linux_serial_program.c
File metadata and controls
67 lines (56 loc) · 1.29 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "serial_api.h"
#define TEST_AT "ATI51\r\n"
int main(int argc,char** argv)
{
SportObj_t *portObj = NULL;
SportErrorCode_e res;
portObj = (SportObj_t *)malloc(sizeof(SportObj_t));
memset(portObj, 0x0, sizeof(SportObj_t));
res = SPORT_Get_Opt(portObj, argc, argv);
if(res != SPORT_OK)
{
printf("device parm get fail!\n");
free(portObj);
return res;
}
res = SPORT_Open_Port(portObj);
if(res != SPORT_OK)
{
printf("device open fail!\n");
free(portObj);
return res;
}
res = SPORT_Get_Port_Atrribute(portObj);
if(res != SPORT_OK)
{
printf("device attribute get fail!\n");
free(portObj);
return res;
}
res = SPORT_Write(portObj, (char *)TEST_AT);
if(res != SPORT_OK)
{
printf("device write fail!\n");
free(portObj);
return res;
}
res = SPORT_Read(portObj);
if(res != SPORT_OK)
{
printf("device read fail!\n");
free(portObj);
return res;
}
res = SPORT_Close_Port(portObj);
if(res != SPORT_OK)
{
printf("device close fail!\n");
free(portObj);
return res;
}
free(portObj);
return 0;
}