• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <stdio.h>
17 #include <string.h>
18 #include "hdf_base.h"
19 #include "hdf_log.h"
20 #include "usb_dev_test.h"
21 
22 #define OPTION_LENGTH 2
23 
ShowUsage(void)24 static void ShowUsage(void)
25 {
26     printf("Usage options:\n");
27     printf("-1 : acm_read\n");
28     printf("-2 : acm_write\n");
29     printf("-3 : acm_test\n");
30     printf("-4 : prop_test\n");
31     printf("-5 : acm_speed_read\n");
32     printf("-6 : acm_speed_write\n");
33     printf("-h : show usage\n");
34 }
35 
main(int32_t argc,char * argv[])36 int32_t main(int32_t argc, char *argv[])
37 {
38     if (argc < OPTION_LENGTH) {
39         printf("argv too flew\n");
40         HDF_LOGE("%s:%d argc=%d is too flew!", __func__, __LINE__, argc);
41         return -1;
42     }
43     const char **arg = (const char **)&argv[1];
44     if (strcmp(arg[0], "-1") == 0) {
45         acm_read(argc - 1, arg);
46     } else if (strcmp(arg[0], "-2") == 0) {
47         acm_write(argc - 1, arg);
48     } else if (strcmp(arg[0], "-3") == 0) {
49         acm_test(argc - 1, arg);
50     } else if (strcmp(arg[0], "-4") == 0) {
51         prop_test(argc - 1, arg);
52     } else if (strcmp(arg[0], "-5") == 0) {
53         acm_speed_read(argc - 1, arg);
54     } else if (strcmp(arg[0], "-6") == 0) {
55         acm_speed_write(argc - 1, arg);
56     } else if (strcmp(arg[0], "-h") == 0 || \
57         strcmp(arg[0], "?") == 0) {
58         ShowUsage();
59     } else {
60         printf("unkown cmd\n");
61     }
62     return 0;
63 }
64