-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathpcbatest_server.h
139 lines (125 loc) · 2.8 KB
/
pcbatest_server.h
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
* pcbatest_server.h
*
* Copyright (c) 2017 Rockchip Electronics Co. Ltd.
* Author: Bin Yang <yangbin@rock-chips.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __TCP_SERVER_H__
#define __TCP_SERVER_H__
#define TCP_QUEUE_LINE 10
#define SOURCE_PORT 6666
#define RECV_BUFFER_SIZE 200
#define SEND_BUFFER_SIZE 200
typedef enum _PCBA_COMMAND_FORMAT {
INDEX_TYPE = 0,
INDEX_TEST_ITEM = 1,
INDEX_CMD = 2,
INDEX_RES = 2,
INDEX_MSG = 3,
INDEX_STATUS = 4,
INDEX_RESULT = 5,
INDEX_ERRCODE = 6,
}PCBA_COMMAND_FORMAT;
typedef struct _PCBA_SINGLE_PARA {
char name[COMMAND_NAMESIZE];
char valuestr[COMMAND_VALUESIZE];
int value;
bool opt;
} PCBA_SINGLE_PARA;
PCBA_SINGLE_PARA recv_cmd_target[] = {
[INDEX_TYPE] = {
.name = "TYPE",
.opt = false,
},
[INDEX_TEST_ITEM] = {
.name = "TEST_ITEM",
.opt = true,
},
[INDEX_CMD] = {
.name = "CMD",
.opt = false,
},
[INDEX_MSG] = {
.name = "MSG",
.opt = true,
},
};
PCBA_SINGLE_PARA send_cmd_target[] = {
[INDEX_TYPE] = {
.name = "TYPE",
},
[INDEX_TEST_ITEM] = {
.name = "TEST_ITEM",
},
[INDEX_RES] = {
.name = "RES",
},
[INDEX_MSG] = {
.name = "MSG",
},
[INDEX_STATUS] = {
.name = "STATUS",
},
[INDEX_RESULT] = {
.name = "RESULT",
},
[INDEX_ERRCODE] = {
.name = "ERR_CODE",
},
};
#define RECV_COMMAND_PARANUM (sizeof(recv_cmd_target) / sizeof(PCBA_SINGLE_PARA))
#define SEND_COMMAND_PARANUM (sizeof(send_cmd_target) / sizeof(PCBA_SINGLE_PARA))
typedef struct _PCBA_COMMAND_PARA {
PCBA_SINGLE_PARA recv_paras[RECV_COMMAND_PARANUM];
PCBA_SINGLE_PARA send_paras[SEND_COMMAND_PARANUM];
} PCBA_COMMAND_PARA;
typedef enum _PCBA_CMD_NUM {
ENTER_CMD = 0,
EXIT_CMD = 1,
START_CMD = 2,
STOP_CMD = 3,
QUERY_CMD = 4,
HEARBEAT_CMD = 5,
}PCBA_CMD_NUM;
typedef struct _PCBA_CMD_TYPE {
char name[COMMAND_NAMESIZE];
} PCBA_CMD_TYPE;
PCBA_CMD_TYPE recv_cmd_type[] = {
[ENTER_CMD] = {
.name = "ENTER",
},
[EXIT_CMD] = {
.name = "EXIT",
},
[START_CMD] = {
.name = "START",
},
[STOP_CMD] = {
.name = "STOP",
},
[QUERY_CMD] = {
.name = "QUERY",
},
[HEARBEAT_CMD] = {
.name = "HEARBEAT",
},
};
#define RECV_CMD_NUM (sizeof(recv_cmd_type) / sizeof(PCBA_CMD_TYPE))
#define RECV_TYPE_NAME "CMD"
#define STORAGE_TESTITEM "write_storage"
#define NAK_STA "NAK"
#define ACK_STA "ACK"
#define DEV_WDT_NAME "/dev/watchdog"
#endif