drivers: can: shell: add support for setting triple sampling mode
Add support for setting triple sampling mode. Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
parent
fd6213b8cc
commit
97d9ab8c18
1 changed files with 16 additions and 3 deletions
|
@ -21,7 +21,7 @@ static struct k_poll_event msgq_events[1] = {
|
|||
|
||||
static inline int read_config_options(const struct shell *sh, int pos,
|
||||
char **argv, bool *listenonly, bool *loopback,
|
||||
bool *oneshot)
|
||||
bool *oneshot, bool *triple)
|
||||
{
|
||||
char *arg = argv[pos];
|
||||
|
||||
|
@ -52,6 +52,13 @@ static inline int read_config_options(const struct shell *sh, int pos,
|
|||
*oneshot = true;
|
||||
}
|
||||
break;
|
||||
case 't':
|
||||
if (triple == NULL) {
|
||||
shell_error(sh, "Unknown option %c", *arg);
|
||||
} else {
|
||||
*triple = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
shell_error(sh, "Unknown option %c", *arg);
|
||||
return -EINVAL;
|
||||
|
@ -242,6 +249,7 @@ static int cmd_config(const struct shell *sh, size_t argc, char **argv)
|
|||
bool listenonly = false;
|
||||
bool loopback = false;
|
||||
bool oneshot = false;
|
||||
bool triple = false;
|
||||
can_mode_t mode = CAN_MODE_NORMAL;
|
||||
uint32_t bitrate;
|
||||
int ret;
|
||||
|
@ -255,7 +263,7 @@ static int cmd_config(const struct shell *sh, size_t argc, char **argv)
|
|||
|
||||
pos++;
|
||||
|
||||
pos = read_config_options(sh, pos, argv, &listenonly, &loopback, &oneshot);
|
||||
pos = read_config_options(sh, pos, argv, &listenonly, &loopback, &oneshot, &triple);
|
||||
if (pos < 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -272,6 +280,10 @@ static int cmd_config(const struct shell *sh, size_t argc, char **argv)
|
|||
mode |= CAN_MODE_ONE_SHOT;
|
||||
}
|
||||
|
||||
if (triple) {
|
||||
mode |= CAN_MODE_3_SAMPLES;
|
||||
}
|
||||
|
||||
ret = can_set_mode(can_dev, mode);
|
||||
if (ret) {
|
||||
shell_error(sh, "Failed to set mode [%d]",
|
||||
|
@ -461,7 +473,8 @@ SHELL_STATIC_SUBCMD_SET_CREATE(sub_can,
|
|||
" Usage: config device_name [-slo] bitrate\n"
|
||||
" -s Listen-only mode\n"
|
||||
" -l Loopback mode\n"
|
||||
" -o One-shot mode",
|
||||
" -o One-shot mode\n"
|
||||
" -t Triple sampling mode",
|
||||
cmd_config, 3, 1),
|
||||
SHELL_CMD_ARG(send, NULL,
|
||||
"Send a CAN frame.\n"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue