1 /*
2 * Copyright (c) 2024 Vestas Wind Systems A/S
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include <zephyr/device.h>
8 #include <zephyr/shell/shell.h>
9
10 static const struct device *chosen = DEVICE_DT_GET(DT_CHOSEN(zephyr_canbus));
11
cmd_can_host_chosen(const struct shell * sh,size_t argc,char ** argv)12 static int cmd_can_host_chosen(const struct shell *sh, size_t argc, char **argv)
13 {
14 ARG_UNUSED(argc);
15 ARG_UNUSED(argv);
16
17 if (!device_is_ready(chosen)) {
18 shell_error(sh, "zephyr,canbus device %s not ready", chosen->name);
19 return -ENODEV;
20 }
21
22 shell_print(sh, "zephyr,canbus: %s", chosen->name);
23
24 return 0;
25 }
26
27 SHELL_STATIC_SUBCMD_SET_CREATE(sub_can_host_cmds,
28 SHELL_CMD(chosen, NULL,
29 "Get zephyr,canbus chosen device name\n"
30 "Usage: can_host chosen",
31 cmd_can_host_chosen),
32 SHELL_SUBCMD_SET_END
33 );
34
35 SHELL_CMD_REGISTER(can_host, &sub_can_host_cmds, "CAN host test commands", NULL);
36