This patch adds the flag CAN_CTRLMODE_ONE_SHOT. It is used as mask
or flag in the "struct can_ctrlmode".

It also adds to "ip" the option to set a CAN controller into the special
"one-shot" mode. In this mode, if supported by the CAN controller,
tries only once to deliver a CAN frame and aborts it if an error
(e.g.: arbitration lost) happens.

Signed-off-by: Marc Kleine-Budde <[email protected]>
Acked-by: Wolfgang Grandegger <[email protected]>
---
 include/linux/can/netlink.h |    1 +
 ip/iplink_can.c             |    6 ++++++
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/include/linux/can/netlink.h b/include/linux/can/netlink.h
index 9ecbb78..c818335 100644
--- a/include/linux/can/netlink.h
+++ b/include/linux/can/netlink.h
@@ -80,6 +80,7 @@ struct can_ctrlmode {
 #define CAN_CTRLMODE_LOOPBACK  0x1     /* Loopback mode */
 #define CAN_CTRLMODE_LISTENONLY        0x2     /* Listen-only mode */
 #define CAN_CTRLMODE_3_SAMPLES 0x4     /* Triple sampling mode */
+#define CAN_CTRLMODE_ONE_SHOT  0x8     /* One-Shot mode */
 
 /*
  * CAN device statistics
diff --git a/ip/iplink_can.c b/ip/iplink_can.c
index 50221e1..5d0d82c 100644
--- a/ip/iplink_can.c
+++ b/ip/iplink_can.c
@@ -30,6 +30,7 @@ static void usage(void)
                "\t[ loopback { on | off } ]\n"
                "\t[ listen-only { on | off } ]\n"
                "\t[ triple-sampling { on | off } ]\n"
+               "\t[ one-shot { on | off } ]\n"
                "\n"
                "\t[ restart-ms TIME-MS ]\n"
                "\t[ restart ]\n"
@@ -84,6 +85,7 @@ static void print_ctrlmode(FILE *f, __u32 cm)
        _PF(CAN_CTRLMODE_LOOPBACK, "LOOPBACK");
        _PF(CAN_CTRLMODE_LISTENONLY, "LISTEN-ONLY");
        _PF(CAN_CTRLMODE_3_SAMPLES, "TRIPLE-SAMPLING");
+       _PF(CAN_CTRLMODE_ONE_SHOT, "ONE-SHOT");
 #undef _PF
        if (cm)
                fprintf(f, "%x", cm);
@@ -142,6 +144,10 @@ static int can_parse_opt(struct link_util *lu, int argc, 
char **argv,
                        NEXT_ARG();
                        set_ctrlmode("triple-sampling", *argv, &cm,
                                     CAN_CTRLMODE_3_SAMPLES);
+               } else if (matches(*argv, "one-shot") == 0) {
+                       NEXT_ARG();
+                       set_ctrlmode("one-shot", *argv, &cm,
+                                    CAN_CTRLMODE_ONE_SHOT);
                } else if (matches(*argv, "restart") == 0) {
                        __u32 val = 1;
 
-- 
1.6.5.7

_______________________________________________
Socketcan-core mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core

Reply via email to