All of lore.kernel.org
 help / color / mirror / Atom feed
* question about time stamp for writing can messages
@ 2016-02-17 13:40 Fischer, Claudio
  2016-02-17 17:45 ` Oliver Hartkopp
  0 siblings, 1 reply; 2+ messages in thread
From: Fischer, Claudio @ 2016-02-17 13:40 UTC (permalink / raw)
  To: linux-can

Hi,

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.

Regards,
Claudio

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: question about time stamp for writing can messages
  2016-02-17 13:40 question about time stamp for writing can messages Fischer, Claudio
@ 2016-02-17 17:45 ` Oliver Hartkopp
  0 siblings, 0 replies; 2+ messages in thread
From: Oliver Hartkopp @ 2016-02-17 17:45 UTC (permalink / raw)
  To: Fischer, Claudio, linux-can

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-02-17 17:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-17 13:40 question about time stamp for writing can messages Fischer, Claudio
2016-02-17 17:45 ` Oliver Hartkopp

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.