From: Stephane Grosjean <s.grosjean@peak-system.com>
To: Oliver Hartkopp <socketcan@hartkopp.net>
Cc: "linux-can@vger.kernel.org" <linux-can@vger.kernel.org>
Subject: Re: About timestamping and can-utils
Date: Thu, 06 Mar 2014 12:03:48 +0100 [thread overview]
Message-ID: <53185614.5040307@peak-system.com> (raw)
In-Reply-To: <53184641.1040506@hartkopp.net>
Hi Oliver,
(sending this message again, first was in HTML... Sorry for the noise)
Thanks for your quick answer.
Meanwhile, I finally found by myself how to get the "hardware"
timestamps the (peak_usb) driver is saving for each CAN frame it receives...
Comparing to your candump patch, there are several things a bit
different I want to discuss about:
Your patch enables to get the (so-called) "hardware raw timestamp" as
well as the "hardware system transformed timestamp", right ?
When I look into net/socket.c, both timestamps are copied by
"__sock_recv_timestamp()", according to:
- SOCK_TIMESTAMPING_RAW_HARDWARE flag ("shhwtstamps->hwtstamp" is copied
into the skb ctrlmsg)
- SOCK_TIMESTAMPING_SYS_HARDWARE flag ("shhwtstamps->syststamp" is
copied into the skb ctrlmsg)
If I understand well:
"hwtstamp" is the RAW timestamp received from the CAN device, without
ANY transformation, while "syststamp" is a "system transformed hardware
timestamp", which I understand as a timestamp the CAN device driver has
computed (according to the "raw timestamp" for example), to be
consistent with the system/kernel time.
So, a well-mannered linux-can device driver should (in case it is able
to get hardware timestamps from its device):
- store in "hwstamp" the raw value received from the device
- store in "syststamp" the "transformed" value the driver computes
Is it right?
Regards,
Stéphane
Le 06/03/2014 10:56, Oliver Hartkopp a écrit :
> Hi Stephane,
>
> here's a discussion thread from last year focussing HW timestamping:
>
> http://marc.info/?l=linux-can&m=138210737431112&w=2
>
> Additionally I attached two patches:
>
> cants-test.patch:
> added some functionality to add a monotonic (sw) timestamp to sja1000
>
> candump-hwts.patch:
> added some functionality to candump to get these timestamps
>
> The candump patch is from the time before the include file cleanup inside the
> can-utils provided by Uwe. (including from socketcan directory)
>
> Together with the discussion thread from above, this should give a good
> starting point.
>
> Regards,
> Oliver
>
>
> On 06.03.2014 10:25, Stephane Grosjean wrote:
>> Hi linux-can team,
>>
>> I've got one question about how timestamping is done now in linux-can,
>> regarding to HW timestamps.
>>
>> In the early ages (~v3.4), the CAN hardware driver could set the timestamp of
>> an skb by itself and push it with the received CAN frame, so that the
>> application could get it using SO_TIMESTAMP socket option, right?
>> Now, this "hardware" timestamp is to be copied into "hwstamp" field of the
>> "skb_hwtstamps(skb)" area.
>>
>> But how does user application manage to get this hardware timestamp on its
>> side? AFAIK, the "candump" can-utils utility always reads and displays the
>> "network" timestamp (that is, always uses SO_TIMESTAMP socket option). I had a
>> quick look to the Kernel sources and tried to find the links between things
>> but it's not very clear to me: first idea I tested was to set the
>> SO_TIMESTAMPING socket option, but candump never received any hw timestamp in
>> the control messages he reads from the CAN socket...
>>
>> Any help would be appreciated.
>>
>> Regards,
>>
>> Stéphane
>> --
>> PEAK-System Technik GmbH, Otto-Roehm-Strasse 69, D-64293 Darmstadt
>> Geschaeftsleitung: A.Gach/U.Wilhelm,St.Nr.:007/241/13586 FA Darmstadt HRB-9183
>> Darmstadt, Ust.IdNr.:DE 202220078, WEE-Reg.-Nr.: DE39305391 Tel.+49
>> (0)6151-817320 / Fax:+49 (0)6151-817329,info@peak-system.com
>> --
--
PEAK-System Technik GmbH, Otto-Roehm-Strasse 69, D-64293 Darmstadt
Geschaeftsleitung: A.Gach/U.Wilhelm,St.Nr.:007/241/13586 FA Darmstadt
HRB-9183 Darmstadt, Ust.IdNr.:DE 202220078, WEE-Reg.-Nr.: DE39305391
Tel.+49 (0)6151-817320 / Fax:+49 (0)6151-817329, info@peak-system.com
next prev parent reply other threads:[~2014-03-06 11:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-06 9:25 About timestamping and can-utils Stephane Grosjean
2014-03-06 9:56 ` Oliver Hartkopp
2014-03-06 11:03 ` Stephane Grosjean [this message]
2014-03-06 18:47 ` Oliver Hartkopp
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=53185614.5040307@peak-system.com \
--to=s.grosjean@peak-system.com \
--cc=linux-can@vger.kernel.org \
--cc=socketcan@hartkopp.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).