From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Martin Kozusky <mkozusky@kkmicro.cz>
Cc: linux-can@vger.kernel.org
Subject: Re: Flexcan - timestamp from message buffer to userspace
Date: Tue, 22 Oct 2013 21:36:40 +0200 [thread overview]
Message-ID: <5266D3C8.90304@hartkopp.net> (raw)
In-Reply-To: <52666E0A.6000100@kkmicro.cz>
On 22.10.2013 14:22, Martin Kozusky wrote:
> Then I noticed, that I have ctrmsg used in recvmsg
> msg.msg_control = &ctrlmsg
> msg.msg_controllen = sizeof(ctrlmsg);
>
> defined as
> char ctrlmsg[CMSG_SPACE(sizeof(struct timeval)) + CMSG_SPACE(sizeof(__u32))];
> (yes, copied from candump when I was starting :)
>
OMG!
What a shame. It's the classic situation not seeing a bug and a guy passing by
your place is pointing at the problem on the monitor :-)
> I tried to use definition from
> http://lxr.free-electrons.com/source/Documentation/networking/timestamping/timestamping.c
>
>
> struct {
> struct cmsghdr cm;
> char control[512];
> } ctrlmsg;
>
> and wow, it's working now :)
\o/
> I have all 3 timestamps available and correct. And I can also use
> SO_TIMESTAMPING and SO_TIMESTAMP together
Me too.
>
> I also added support for the call of ioctl/SIOCSHWTSTAMP to the flexcan driver
> (although it does nothing and later I removed this call from the program and
> just use setsockopt/SO_TIMESTAMPING)
Yes. I can see the HW timestamp from the PCAN USB driver directly now - after
enabling the HW timestamping flags in the TIMESTAMPING sockopt().
>
> this is my patch for flexcan.c, I could also add support for hwtstamp to error
> frames, but I don't need that now.
This would be a good idea to implement this for error messages too.
I assume this was the reason to implement the ioctl() to configure if the
driver should do the work of evaluating the extra timestamps.
Btw. we know how to deal with the API for now. I was searching for a monotonic
SW timestamp that is not affected by any system time adjustments.
Maybe SOF_TIMESTAMPING_SYS_HARDWARE could be used for this, when a HW
timestamp is not available anyway.
Alternatively a fourth element could be added to the existing timestamps in
struct scm_timestamping {
struct timespec systime;
struct timespec hwtimetrans;
struct timespec hwtimeraw;
struct timespec monotonic; /* ??? */
};
Let's see ...
Thanks,
Oliver
prev parent reply other threads:[~2013-10-22 19:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-18 9:56 Flexcan - timestamp from message buffer to userspace Martin Kozusky
2013-10-18 10:55 ` Martin Kozusky
2013-10-18 14:42 ` Oliver Hartkopp
2013-10-21 6:54 ` Martin Kozusky
2013-10-21 8:00 ` Wolfgang Grandegger
2013-10-21 8:11 ` Wolfgang Grandegger
2013-10-21 8:54 ` Martin Kozusky
2013-10-21 9:51 ` Martin Kozusky
2013-10-21 11:23 ` Wolfgang Grandegger
2013-10-21 16:29 ` Oliver Hartkopp
2013-10-22 12:22 ` Martin Kozusky
2013-10-22 19:36 ` 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=5266D3C8.90304@hartkopp.net \
--to=socketcan@hartkopp.net \
--cc=linux-can@vger.kernel.org \
--cc=mkozusky@kkmicro.cz \
/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.