Hello,

Wolfgang Grandegger wrote:
>>> I saw that the mcp2515 chip supports a one-shot mode. It's just setting bit
>>> 3 (OSM) of the CANCTRL register. I'd mentioned this to Christian, and I
>>> don't thing setting the register is a big deal, but the issue will be
>>> setting this mode with ip or some other user space tool.
>> what about adding the one shot mode to the ctrl_mode? It already holds
>> the tipple sample and listen-only feature.

[...]

> I will apply the patch to the SVN trunk. Are you going to prepare a
> patch for mainline as well? If yes, please post it together with the
> necessary changes for iproute2, which should be trivial.

Here it goes, compile time tested only:

cheers, Marc

---

From 8c0479ef365a52d53212fb4b8905b755a2a4c5e2 Mon Sep 17 00:00:00 2001
From: Marc Kleine-Budde <[email protected]>
Date: Tue, 22 Dec 2009 20:30:17 +0100
Subject: [PATCH] iplink_can: add support to set one-shot mode

Signed-off-by: Marc Kleine-Budde <[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


-- 
Pengutronix e.K.                         | Marc Kleine-Budde           |
Linux Solutions for Science and Industry | Phone: +49-231-2826-924     |
Vertretung West/Dortmund                 | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686         | http://www.pengutronix.de   |

Attachment: signature.asc
Description: OpenPGP digital signature

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

Reply via email to