From f8d9566a843ceeab7b856e47d7c28eaecb830127 Mon Sep 17 00:00:00 2001 From: Wouter Symons Date: Sat, 22 Aug 2020 11:28:09 +0200 Subject: [PATCH] tests/candev: Prevent user from attempting to use native can interface on non-native board --- tests/candev/Makefile | 14 +++++++++++--- tests/candev/main.c | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/candev/Makefile b/tests/candev/Makefile index f7b1d3adae..b96b30d0d0 100644 --- a/tests/candev/Makefile +++ b/tests/candev/Makefile @@ -1,11 +1,21 @@ include ../Makefile.tests_common +BOARD_WHITELIST := native USEMODULE += shell USEMODULE += can USEMODULE += isrpipe # define the CAN driver you want to use here -CAN_DRIVER ?= native +CAN_DRIVER ?= CAN_NATIVE + +# prevent using native driver on non-native board +ifeq ($(CAN_DRIVER), CAN_NATIVE) + ifneq ($(BOARD), native) + $(error native can driver can only be used on native board!) + endif +endif + + ifeq ($(CAN_DRIVER), PERIPH_CAN) # periph_can modules/variables go here @@ -15,6 +25,4 @@ else ifeq ($(CAN_DRIVER), CAN_NATIVE) endif -CFLAGS += -DCAN_DRIVER_$(CAN_DRIVER) - include $(RIOTBASE)/Makefile.include diff --git a/tests/candev/main.c b/tests/candev/main.c index b2a9421ea8..7e6e692507 100644 --- a/tests/candev/main.c +++ b/tests/candev/main.c @@ -30,7 +30,7 @@ #include "shell.h" #include "can/device.h" -#ifdef BOARD_NATIVE +#if IS_USED(MODULE_CAN_LINUX) #include @@ -192,7 +192,7 @@ int main(void) puts("candev test application\n"); isrpipe_init(&rxbuf, (uint8_t *)rx_ringbuf, sizeof(rx_ringbuf)); -#ifdef BOARD_NATIVE +#if IS_USED(MODULE_CAN_LINUX) puts("Initializing Linux Can device"); candev_linux_init( &linux_dev, &(candev_linux_conf[0])); /* vcan0 */ candev = (candev_t *)&linux_dev;