• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef CAN_TEST_H
10 #define CAN_TEST_H
11 
12 #include "can_if.h"
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 #define CAN_TEST_BUS_NUM   31
19 #define CAN_TEST_BIT_RATE  (1000 * 10) // 1K
20 #define CAN_TEST_WORK_MODE CAN_BUS_LOOPBACK
21 
22 int32_t CanTestExecute(int cmd);
23 
24 enum CanTestCmd {
25     CAN_TEST_SEND_AND_READ = 0,
26     CAN_TEST_NO_BLOCK_READ,
27     CAN_TEST_BLOCK_READ,
28     CAN_TEST_ADD_DEL_FILTER,
29     CAN_TEST_ADD_MULTI_FILTER,
30     CAN_TEST_GET_BUS_STATE,
31     CAN_TEST_MULTI_THREAD_READ_SAME_HANDLE,
32     CAN_TEST_MULTI_THREAD_READ_MULTI_HANDLE,
33     CAN_TEST_MULTI_THREAD_SEND_SAME_HANDLE,
34     CAN_TEST_MULTI_THREAD_SEND_MULTI_HANDLE,
35     CAN_TEST_RELIABILITY,
36     CAN_TEST_CMD_MAX,
37 };
38 
39 struct CanTestConfig {
40     uint16_t busNum;
41     uint32_t bitRate;
42     uint8_t workMode;
43 };
44 
45 struct CanTester {
46     struct CanTestConfig config;
47     DevHandle handle;
48     uint16_t total;
49     uint16_t fails;
50     bool readerFlag;
51     bool pollerFlag;
52     struct CanMsg msg;
53 };
54 
55 #ifdef __cplusplus
56 }
57 #endif
58 #endif /* CAN_TEST_H */
59