Commit 921e69af authored by Henrik Brix Andersen's avatar Henrik Brix Andersen Committed by Carles Cufi
Browse files

samples: canbus: isotp: add option for running in loopback mode



Add Kconfig option for running the CAN ISO-TP sample in loopback mode. This
removes the need for a fixture when running the sample via twister.

Exclude the loopback tests for kvaser,pcican. See
836f5826 for more information.

Signed-off-by: default avatarHenrik Brix Andersen <hebad@vestas.com>
parent 250f2126
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
# Private config options to the ISO-TP sample

# Copyright (c) 2023 Vestas Wind Systems A/S
# SPDX-License-Identifier: Apache-2.0

mainmenu "ISO-TP sample"

config SAMPLE_LOOPBACK_MODE
	bool "Use CAN loopback mode"
	help
	  Set the CAN controller to loopback mode. This allows testing without a second board.

source "Kconfig.zephyr"
+5 −4
Original line number Diff line number Diff line
sample:
  name: ISO-TP lib sample
  name: ISO-TP sample
tests:
  sample.subsys.canbus.isotp:
    tags: can isotp
    depends_on: can
    filter: dt_chosen_enabled("zephyr,canbus")
    filter: dt_chosen_enabled("zephyr,canbus") and not dt_compat_enabled("kvaser,pcican")
    extra_configs:
      - CONFIG_SAMPLE_LOOPBACK_MODE=y
    harness: console
    harness_config:
      type: one_line
      regex:
        - "(.*)Got 248 bytes in total"
      fixture: fixture_can_two_boards
        - "(.*)Got 247 bytes in total"
+8 −0
Original line number Diff line number Diff line
@@ -154,6 +154,14 @@ void main(void)
		return;
	}

#ifdef CONFIG_SAMPLE_LOOPBACK_MODE
	ret = can_set_mode(can_dev, CAN_MODE_LOOPBACK);
	if (ret != 0) {
		printk("CAN: Failed to set loopback mode [%d]", ret);
		return;
	}
#endif /* CONFIG_SAMPLE_LOOPBACK_MODE */

	ret = can_start(can_dev);
	if (ret != 0) {
		printk("CAN: Failed to start device [%d]\n", ret);