How to get time in UTC with millisecond (~10 ms) granularity?

Hi,

I need a time value with millisecond granularity to coordinate communication between multiple flight controllers from a Lua script.

  • millis() would provide the granularity but drifts way too much.
  • gps:time_week_ms() would provide a precise time but is only updated at 5 Hz

What is the proper way to access the internal clock (that should be synchronized to GPS)?

Is adding a custom binding to get_time_utc() or get_utc_usec provided by AP_RTC.h the way to go?

Thank you in advance,
Stephan