question about time stamp for writing can messages
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
Hi Claudio,
Quoted 11 lines · Claudio
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