1 /* 2 * pcbatest_server.h 3 * 4 * Copyright (c) 2017 Rockchip Electronics Co. Ltd. 5 * Author: Bin Yang <yangbin@rock-chips.com> 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20 #ifndef __TCP_SERVER_H__ 21 #define __TCP_SERVER_H__ 22 23 24 #define TCP_QUEUE_LINE 10 25 #define SOURCE_PORT 6666 26 #define RECV_BUFFER_SIZE 200 27 #define SEND_BUFFER_SIZE 200 28 29 typedef enum _PCBA_COMMAND_FORMAT { 30 INDEX_TYPE = 0, 31 INDEX_TEST_ITEM = 1, 32 INDEX_CMD = 2, 33 INDEX_RES = 2, 34 INDEX_MSG = 3, 35 INDEX_STATUS = 4, 36 INDEX_RESULT = 5, 37 INDEX_ERRCODE = 6, 38 }PCBA_COMMAND_FORMAT; 39 40 typedef struct _PCBA_SINGLE_PARA { 41 char name[COMMAND_NAMESIZE]; 42 char valuestr[COMMAND_VALUESIZE]; 43 int value; 44 bool opt; 45 } PCBA_SINGLE_PARA; 46 47 PCBA_SINGLE_PARA recv_cmd_target[] = { 48 [INDEX_TYPE] = { 49 .name = "TYPE", 50 .opt = false, 51 }, 52 [INDEX_TEST_ITEM] = { 53 .name = "TEST_ITEM", 54 .opt = true, 55 }, 56 [INDEX_CMD] = { 57 .name = "CMD", 58 .opt = false, 59 }, 60 [INDEX_MSG] = { 61 .name = "MSG", 62 .opt = true, 63 }, 64 }; 65 66 PCBA_SINGLE_PARA send_cmd_target[] = { 67 [INDEX_TYPE] = { 68 .name = "TYPE", 69 }, 70 [INDEX_TEST_ITEM] = { 71 .name = "TEST_ITEM", 72 }, 73 [INDEX_RES] = { 74 .name = "RES", 75 }, 76 [INDEX_MSG] = { 77 .name = "MSG", 78 }, 79 [INDEX_STATUS] = { 80 .name = "STATUS", 81 }, 82 [INDEX_RESULT] = { 83 .name = "RESULT", 84 }, 85 [INDEX_ERRCODE] = { 86 .name = "ERR_CODE", 87 }, 88 }; 89 90 #define RECV_COMMAND_PARANUM (sizeof(recv_cmd_target) / sizeof(PCBA_SINGLE_PARA)) 91 #define SEND_COMMAND_PARANUM (sizeof(send_cmd_target) / sizeof(PCBA_SINGLE_PARA)) 92 93 typedef struct _PCBA_COMMAND_PARA { 94 PCBA_SINGLE_PARA recv_paras[RECV_COMMAND_PARANUM]; 95 PCBA_SINGLE_PARA send_paras[SEND_COMMAND_PARANUM]; 96 } PCBA_COMMAND_PARA; 97 98 typedef enum _PCBA_CMD_NUM { 99 ENTER_CMD = 0, 100 EXIT_CMD = 1, 101 START_CMD = 2, 102 STOP_CMD = 3, 103 QUERY_CMD = 4, 104 HEARBEAT_CMD = 5, 105 CAPTURE_CMD = 6, 106 }PCBA_CMD_NUM; 107 108 typedef struct _PCBA_CMD_TYPE { 109 char name[COMMAND_NAMESIZE]; 110 } PCBA_CMD_TYPE; 111 112 PCBA_CMD_TYPE recv_cmd_type[] = { 113 [ENTER_CMD] = { 114 .name = "ENTER", 115 }, 116 [EXIT_CMD] = { 117 .name = "EXIT", 118 }, 119 [START_CMD] = { 120 .name = "START", 121 }, 122 [STOP_CMD] = { 123 .name = "STOP", 124 }, 125 [QUERY_CMD] = { 126 .name = "QUERY", 127 }, 128 [HEARBEAT_CMD] = { 129 .name = "HEARBEAT", 130 }, 131 [CAPTURE_CMD] = { 132 .name = "CAPTURE_IMAGE", 133 }, 134 }; 135 136 #define RECV_CMD_NUM (sizeof(recv_cmd_type) / sizeof(PCBA_CMD_TYPE)) 137 #define RECV_TYPE_NAME "CMD" 138 #define STORAGE_TESTITEM "write_storage" 139 #define NAK_STA "NAK" 140 #define ACK_STA "ACK" 141 #define DEV_WDT_NAME "/dev/watchdog" 142 143 #endif 144