]> rtime.felk.cvut.cz Git - socketcan-devel.git/blobdiff - kernel/2.6/Documentation/networking/can.txt
Fix common misspellings
[socketcan-devel.git] / kernel / 2.6 / Documentation / networking / can.txt
index 6cd6627c3293ded2cf0d97ea1f3be4886182d223..e74386efef56bcece1dae45d9fbc9ea4e0735591 100644 (file)
@@ -22,9 +22,11 @@ This file contains
       4.1.2 RAW socket option CAN_RAW_ERR_FILTER
       4.1.3 RAW socket option CAN_RAW_LOOPBACK
       4.1.4 RAW socket option CAN_RAW_RECV_OWN_MSGS
+      4.1.5 RAW socket returned message flags
     4.2 Broadcast Manager protocol sockets (SOCK_DGRAM)
     4.3 connected transport protocols (SOCK_SEQPACKET)
     4.4 unconnected transport protocols (SOCK_DGRAM)
+    4.5 Timestamps
 
   5 Socket CAN core module
     5.1 can.ko module params
@@ -239,7 +241,7 @@ solution for a couple of reasons:
   the user application using the common CAN filter mechanisms. Inside
   this filter definition the (interested) type of errors may be
   selected. The reception of error frames is disabled by default.
-  The format of the CAN error frame is briefly decribed in the Linux
+  The format of the CAN error frame is briefly described in the Linux
   header file "include/linux/can/error.h".
 
 4. How to use Socket CAN
@@ -334,7 +336,7 @@ solution for a couple of reasons:
             return 1;
     }
 
-    /* paraniod check ... */
+    /* paranoid check ... */
     if (nbytes < sizeof(struct can_frame)) {
             fprintf(stderr, "read: incomplete CAN frame\n");
             return 1;
@@ -471,10 +473,42 @@ solution for a couple of reasons:
     setsockopt(s, SOL_CAN_RAW, CAN_RAW_RECV_OWN_MSGS,
                &recv_own_msgs, sizeof(recv_own_msgs));
 
+  4.1.5 RAW socket returned message flags
+
+  When using recvmsg() call, the msg->msg_flags may contain following flags:
+
+    MSG_DONTROUTE: set when the received frame was created on the local host.
+
+    MSG_CONFIRM: set when the frame was sent via the socket it is received on.
+      This flag can be interpreted as a 'transmission confirmation' when the
+      CAN driver supports the echo of frames on driver level, see 3.2 and 6.2.
+      In order to receive such messages, CAN_RAW_RECV_OWN_MSGS must be set.
+
   4.2 Broadcast Manager protocol sockets (SOCK_DGRAM)
   4.3 connected transport protocols (SOCK_SEQPACKET)
   4.4 unconnected transport protocols (SOCK_DGRAM)
 
+  4.5 Timestamps
+  
+  For applications in the CAN environment it is often of interest an
+  accurate timestamp of the instant a message from CAN bus has been received.
+  Such a timestamp can be read with ioctl(2) after reading a message from
+  the socket. Example:
+
+    struct timeval tv;
+    ioctl(s, SIOCGSTAMP, &tv);
+
+  The timestamp on Linux has a resolution of one microsecond and it is set
+  automatically at the reception of a CAN frame.
+
+  Alternatively the timestamp can be obtained as a control message (cmsg) using
+  the recvmsg() system call. After enabling the timestamps in the cmsg's by
+
+    const int timestamp = 1;
+    setsockopt(s, SOL_SOCKET, SO_TIMESTAMP, &timestamp, sizeof(timestamp));  
+
+  the data structures filled by recvmsg() need to be parsed for
+  cmsg->cmsg_type == SO_TIMESTAMP to get the timestamp. See cmsg() manpage.
 
 5. Socket CAN core module
 -------------------------