Correct way to correlate TSC to PTP to convert TSC SOF to UTC time

Please provide the following info (tick the boxes after creating this topic):
Software Version
DRIVE OS 6.0.8.1
DRIVE OS 6.0.6
DRIVE OS 6.0.5
DRIVE OS 6.0.4 (rev. 1)
DRIVE OS 6.0.4 SDK
other

Target Operating System
Linux
QNX
other

Hardware Platform
DRIVE AGX Orin Developer Kit (940-63710-0010-300)
DRIVE AGX Orin Developer Kit (940-63710-0010-200)
DRIVE AGX Orin Developer Kit (940-63710-0010-100)
DRIVE AGX Orin Developer Kit (940-63710-0010-D00)
DRIVE AGX Orin Developer Kit (940-63710-0010-C00)
DRIVE AGX Orin Developer Kit (not sure its number)
other

SDK Manager Version
1.9.3.10904
other

Host Machine Version
native Ubuntu Linux 20.04 Host installed with SDK Manager
native Ubuntu Linux 20.04 Host installed with DRIVE OS Docker Containers
native Ubuntu Linux 18.04 Host installed with DRIVE OS Docker Containers
other

I was wondering how others convert an SOF timestamp to a PTP UTC timestamp? What I did was modify nvsipl_camera to keep track of the average TSC-PTP offset using ioctl calls and a rolling average. Crude, but couldn’t think of anything else. Then, when the frame is written, the file name includes the SOF timestamp and average offset to PTP (which should just be the time at which PTP and TSC are synced) - basically taking SOF*32 + PTP offset and convert to datetime based on ns since epoch.

This is the only approach I see as the camera meta data does not include any field for PTP time, but to make stamps meaningful as a real world time, you need to know that offset. Or is there somewhere in the device that stores the TSC time that PTP is synchronized and NVPPS takes control? Is there anything I am missing?

Thanks!

Dear @collin.day,
SOF will be in TSC. Does Orin Time Sync | NVIDIA Docs helps?

Could you share the sample changes you have made?

Sure!

See attached.
CFileWriter.txt (13.5 KB)

main.txt (100.6 KB)

You should just need to rename these to .cpp / .hpp where appropriate and drop them into the nvsipl_camera source directory.

In main.cpp - lines 197 to 275, add a class that maintains a thread that keeps track of the ptp offset using the ioctl(fd, NVPPS_GETEVENT, &ts) ioctl and is started on lines 1119 and 1120.

In the FileWriter - modified Init to keep track of the file name, but instead of write all data to one file by modifying WriteBufferToFile to accept the average PTP-TSC offset and then create a file that has the SOF TSC timestamp and the PTP offset in the file name.

Also - in this version, I noticed that I was quickly filling up my drive and had frame drops resulting from the buffer write, so I decided to just not actually write the buffer for the time being since I am only interested in the time stamps themselves.

There is no update from you for a period, assuming this is not an issue any more.
Hence we are closing this topic. If need further support, please open a new one.
Thanks

Dear @collin.day,
My apologies for missing this topic. Does this topic still need support?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.