amiro-os / unittests / lld / src / ut_lld_rtcan.c @ ab0b6b11
History | View | Annotate | Download (2.278 KB)
1 | d2931db9 | Julian L | /*
|
---|---|---|---|
2 | AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
|
||
3 | Copyright (C) 2016..2018 Thomas Schöpping et al.
|
||
4 | |||
5 | This program is free software: you can redistribute it and/or modify
|
||
6 | it under the terms of the GNU General Public License as published by
|
||
7 | the Free Software Foundation, either version 3 of the License, or
|
||
8 | (at your option) any later version.
|
||
9 | |||
10 | This program is distributed in the hope that it will be useful,
|
||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | GNU General Public License for more details.
|
||
14 | |||
15 | You should have received a copy of the GNU General Public License
|
||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
17 | */
|
||
18 | |||
19 | #include <stdint.h> |
||
20 | #include <hal.h> |
||
21 | #include <module.h> |
||
22 | #include <hal_can.h> |
||
23 | #include <aos_rtcan.h> |
||
24 | #include <ut_lld_rtcan.h> |
||
25 | |||
26 | |||
27 | #if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
||
28 | #include <aos_debug.h> |
||
29 | #include <chprintf.h> |
||
30 | #include <aos_thread.h> |
||
31 | |||
32 | /**
|
||
33 | * @brief RTCAN unit test function.
|
||
34 | *
|
||
35 | * @param[in] stream Stream for input/output.
|
||
36 | * @param[in] ut Unit test object.
|
||
37 | *
|
||
38 | * @return Unit test result value.
|
||
39 | */
|
||
40 | aos_utresult_t utLldRtCanFunc(BaseSequentialStream* stream, aos_unittest_t* ut) |
||
41 | { |
||
42 | |||
43 | aosDbgCheck(ut->data != NULL && ((ut_rtcandata_t*)ut->data)->operation!= NULL); |
||
44 | // local variables
|
||
45 | // rtcanTransmit and reveive Test necessary
|
||
46 | aos_utresult_t result = {0, 0}; |
||
47 | //aos_getTime irgendwas
|
||
48 | msg_t msg = MSG_TIMEOUT; |
||
49 | char* operation = ((ut_rtcandata_t*)ut->data)->operation;
|
||
50 | |||
51 | if(strcmp(operation, "send")==0){ |
||
52 | CANTxFrame ctfp; |
||
53 | ctfp.RTR = CAN_RTR_DATA; |
||
54 | ctfp.IDE = CAN_IDE_STD; |
||
55 | ctfp.DLC = 0;
|
||
56 | ctfp.SID = 0x003;
|
||
57 | msg = rtcan_transmit(&MODULE_HAL_CAN,CAN_ANY_MAILBOX,&ctfp); |
||
58 | }else if (strcmp(operation, "receive")==0){ |
||
59 | CANRxFrame crfp; |
||
60 | crfp.RTR = CAN_RTR_DATA; |
||
61 | crfp.IDE = CAN_IDE_STD; |
||
62 | crfp.DLC = 0;
|
||
63 | crfp.SID = 0x003;
|
||
64 | msg = rtcan_receive(&MODULE_HAL_CAN,CAN_ANY_MAILBOX,&crfp); |
||
65 | } |
||
66 | |||
67 | if(msg == MSG_OK){
|
||
68 | aosUtPassedMsg(stream,&result,"Message transmitted");
|
||
69 | }else{
|
||
70 | aosUtFailedMsg(stream,&result,"Timeout");
|
||
71 | } |
||
72 | |||
73 | return result;
|
||
74 | } |
||
75 | |||
76 | #endif /* (AMIROOS_CFG_TESTS_ENABLE == true) && defined(AMIROLLD_CFG_USE_LED) */ |
||
77 |