Page 1 of 1

Timestamps with SocketCAN using recvmsg and ioctl

Posted: Wed 17. Jun 2015, 17:50
by marc.andrew
Hi,

I am currently looking into SocketCAN with a focus on timestamps.

My setup is as following:
Ubuntu 14.01LTS Laptop (Kernel 3.16.0)
SocketCAN
PCAN USB Adapter using the mainline driver

My question is: What kind of timestamp is generated when using recvmsg (HW timestamp, driver timestamp ,...)?
Is there a difference when using ioctl as I read in some internet forums?

Thanks for your help!

Re: Timestamps with SocketCAN using recvmsg and ioctl

Posted: Thu 18. Jun 2015, 11:15
by S.Grosjean
Hello!

The timestamps received from the socket layer are multiple.

You should have a look to this first:

https://www.kernel.org/doc/Documentatio ... stamping.c

The "default" timestamp tools like "candump" may display is a "network layer" timestamp, which is obtained with using SO_TIMESTAMP socket option (see https://github.com/linux-can/can-utils/ ... ump.c#L554).

Fortunately, the peak-usb driver is able to provide its own timestamps read from the PCAN-USB device, so called "hardware" timestamps. These can be obtained by using the SIOCSHWTSTAMP socket option, as described in the above Kernel timestamping.c.

To complete the answer, this "hardware" timestamp is the same that is returned by the "chardev" interface of the out-of-tree "pcan" driver (that is, by the ioctl() call you talked about).

Hope this helps,

Regards,

Stéphane