You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There should be a way to obtain the timestamp of receiption for a CAN-frame. Ideally, this should be the HW-timestamp, if the device supports it (using SIOCSHWTSTAMP). According to the socketcan documentation, timestamps can be obtained by an ioctl-call after reading a message from the socket.
I tried hacking something into socketcan.h but failed.
My approach was to just add
ioctl(socket_.native_handle(), SIOCGSTAMP, &tv);
at the beginning of SocketCANInterface::readFrame(...) and
in the init(...) method.
However, the values seem wrong (inconsistent, jumping, in the range of 10^12). So it probably just proves how few I understand about socketcan and boost::asio.
Is there a possibility for a recent implementation of this feature request or could you provide some hints how to realize this? Thanks!
The text was updated successfully, but these errors were encountered:
I tried it myself some time ago, but for some reason I did not include it somewhere.
If I remember it correctly, not all devices set these time stamps and in addition it is unclear what time base they use.
As far as I understand, even if the hardware does not support it, there is at least the option to retrieve the socket timestamp (SO_TIMESTAMP) of the last received packet. I think, this is also what candump does: https://github.com/linux-can/can-utils/blob/master/candump.c#L676
This source mentions the following. It might the reason for the inconsistent timestamp.
Note that SIOCGSTAMP and SO_TIMESTAMP are mutually exclusive - if you're going to use SIOCGSTAMP you should disable SO_TIMESTAMP (with enabled = 0). This is because SO_TIMESTAMP directs the kernel to make the timestamp available via recvmmsg ancillary data instead of via SIOCGSTAMP.
There should be a way to obtain the timestamp of receiption for a CAN-frame. Ideally, this should be the HW-timestamp, if the device supports it (using SIOCSHWTSTAMP). According to the socketcan documentation, timestamps can be obtained by an ioctl-call after reading a message from the socket.
I tried hacking something into socketcan.h but failed.
My approach was to just add
at the beginning of SocketCANInterface::readFrame(...) and
in the init(...) method.
However, the values seem wrong (inconsistent, jumping, in the range of 10^12). So it probably just proves how few I understand about socketcan and boost::asio.
Is there a possibility for a recent implementation of this feature request or could you provide some hints how to realize this? Thanks!
The text was updated successfully, but these errors were encountered: