From 2543b3d2b6994d535ee44c98e29e06bcbd3096be Mon Sep 17 00:00:00 2001 From: Firas Hamdi Date: Mon, 23 May 2022 18:35:31 +0200 Subject: [PATCH] tests/candev: update test application --- tests/candev/main.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/tests/candev/main.c b/tests/candev/main.c index ce7d9772d5..e9f7f41737 100644 --- a/tests/candev/main.c +++ b/tests/candev/main.c @@ -223,14 +223,28 @@ if (IS_ACTIVE(CONFIG_USE_LOOPBACK_MODE)) { if (IS_ACTIVE(MCP2515_RECV_FILTER_EN)) { /* CAN filters examples */ - struct can_filter filter[3]; + struct can_filter filter[4]; filter[0].can_mask = 0x7FF; - filter[0].can_id = 0x001; /* messages with CAN ID 0x001 will be received in mailbox 0 */ + filter[0].can_id = 0x001; +#if defined(MODULE_MCP2515) + filter[0].target_mailbox = 0; /* messages with CAN ID 0x001 will be received in mailbox 0 */ +#endif filter[1].can_mask = 0x7FF; - filter[1].can_id = 0x003; /* messages with CAN ID 0x003 will be received in mailbox 0 */ + filter[1].can_id = 0x002; +#if defined(MODULE_MCP2515) + filter[1].target_mailbox = 1; /* messages with CAN ID 0x002 will be received in mailbox 1 */ +#endif filter[2].can_mask = 0x7FF; - filter[2].can_id = 0x002; /* messages with CAN ID 0x002 will be received in mailbox 1 */ - for (uint8_t i = 0; i < 3; i++) { + filter[2].can_id = 0x003; +#if defined(MODULE_MCP2515) + filter[2].target_mailbox = 0; /* messages with CAN ID 0x003 will be received in mailbox 0 */ +#endif + filter[3].can_mask = 0x7FF; + filter[3].can_id = 0x004; +#if defined(MODULE_MCP2515) + filter[3].target_mailbox = 0; /* this filter won't be applied. Reason is no space found in the first mailbox as it supports only two filters */ +#endif + for (uint8_t i = 0; i < 4; i++) { candev->driver->set_filter(candev, &filter[i]); } /* All other messages won't be received */