@@ -21,7 +21,7 @@ static struct k_poll_event msgq_events[1] = {
2121
2222static inline int read_config_options (const struct shell * sh , int pos ,
2323 char * * argv , bool * listenonly , bool * loopback ,
24- bool * oneshot )
24+ bool * oneshot , bool * triple )
2525{
2626 char * arg = argv [pos ];
2727
@@ -52,6 +52,13 @@ static inline int read_config_options(const struct shell *sh, int pos,
5252 * oneshot = true;
5353 }
5454 break ;
55+ case 't' :
56+ if (triple == NULL ) {
57+ shell_error (sh , "Unknown option %c" , * arg );
58+ } else {
59+ * triple = true;
60+ }
61+ break ;
5562 default :
5663 shell_error (sh , "Unknown option %c" , * arg );
5764 return - EINVAL ;
@@ -242,6 +249,7 @@ static int cmd_config(const struct shell *sh, size_t argc, char **argv)
242249 bool listenonly = false;
243250 bool loopback = false;
244251 bool oneshot = false;
252+ bool triple = false;
245253 can_mode_t mode = CAN_MODE_NORMAL ;
246254 uint32_t bitrate ;
247255 int ret ;
@@ -255,7 +263,7 @@ static int cmd_config(const struct shell *sh, size_t argc, char **argv)
255263
256264 pos ++ ;
257265
258- pos = read_config_options (sh , pos , argv , & listenonly , & loopback , & oneshot );
266+ pos = read_config_options (sh , pos , argv , & listenonly , & loopback , & oneshot , & triple );
259267 if (pos < 0 ) {
260268 return - EINVAL ;
261269 }
@@ -272,6 +280,10 @@ static int cmd_config(const struct shell *sh, size_t argc, char **argv)
272280 mode |= CAN_MODE_ONE_SHOT ;
273281 }
274282
283+ if (triple ) {
284+ mode |= CAN_MODE_3_SAMPLES ;
285+ }
286+
275287 ret = can_set_mode (can_dev , mode );
276288 if (ret ) {
277289 shell_error (sh , "Failed to set mode [%d]" ,
@@ -461,7 +473,8 @@ SHELL_STATIC_SUBCMD_SET_CREATE(sub_can,
461473 " Usage: config device_name [-slo] bitrate\n"
462474 " -s Listen-only mode\n"
463475 " -l Loopback mode\n"
464- " -o One-shot mode" ,
476+ " -o One-shot mode\n"
477+ " -t Triple sampling mode" ,
465478 cmd_config , 3 , 1 ),
466479 SHELL_CMD_ARG (send , NULL ,
467480 "Send a CAN frame.\n"
0 commit comments