From: Oliver Hartkopp <socketcan@hartkopp.net>
To: "Fischer, Claudio" <Claudio.Fischer@weinig.com>,
"linux-can@vger.kernel.org" <linux-can@vger.kernel.org>
Subject: Re: question about time stamp for writing can messages
Date: Wed, 17 Feb 2016 18:45:16 +0100 [thread overview]
Message-ID: <56C4B1AC.5040400@hartkopp.net> (raw)
In-Reply-To: <56C4785C.1070900@dimter-weinig.de>
Hi Claudio,
On 02/17/2016 02:40 PM, Fischer, Claudio wrote:
> I have a question about the time stamp for writing can messages:
>
> I'm using the time stamp feature when reading can messages with
> socketcan on linux.
> Is there a possibility to use the same clock reference / time stamp
> feature for writing
> can messages?
>
> I'm asking this, because I want to record all written and read can
> messages in
> chronologic sequence without building my own timestamp for written messages.
When you run e.g. 'candump -ta <interface>' on a terminal you would see, that
even your sent CAN frames appear with a correct in-order timestamp.
When you send a CAN frame this CAN frame is 'echoed' back to the system to
allow all applications on your system (multi-user) to get the correct
representation of what happened on the wire.
The timestamp is usually set when the TX-ok interrupt occurred after the frame
has been successfully send on the CAN bus. Then the stamped frame is
'received' by the system again - so you already have a correct timestamp of
your outgoing CAN frames.
See http://lxr.free-electrons.com/source/Documentation/networking/can.txt#L184
When you have a CAN driver that does not support the ECHO functionality (e.g.
slcan devices) the timestamp is generated on network layer as fallback - which
is not that precise and may be out of order then.
Usually you do not see the sent frame on your CAN_RAW socket, as it is
(historically) unusual to receive your own traffic.
If you want to receive the traffic on the same socket where it was sent you'll
have to set the CAN_RAW_RECV_OWN_MSGS socket option:
http://lxr.free-electrons.com/source/Documentation/networking/can.txt#L537
Best regards,
Oliver
prev parent reply other threads:[~2016-02-17 17:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-17 13:40 question about time stamp for writing can messages Fischer, Claudio
2016-02-17 17:45 ` Oliver Hartkopp [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56C4B1AC.5040400@hartkopp.net \
--to=socketcan@hartkopp.net \
--cc=Claudio.Fischer@weinig.com \
--cc=linux-can@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.