Configurable LSL clock source (e.g. PTP-disciplined clock) via lsl_api.cfg

Aperta
#347 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
8/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Attiva
Stack tecnologico
cpp, linux, macos

Direzione di ricerca

The clock behind lsl_local_clock() is defined in src/common.cpp, and the offset estimation lives in the LSL:timedata probe exchange. Before any code, the maintainers need to agree on the design: how lsl_api.cfg selects a clock, how a clock-domain token is advertised, and how steps are detected. Done means an agreed design and a scoped first step, not an implementation.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

lsl_local_clock() is always std::chrono::steady_clock (src/common.cpp): CLOCK_MONOTONIC on Linux, mach_continuous_time on macOS, QPC on Windows. Each host's clock has an arbitrary epoch and its own rate, so every inlet has to estimate the offset with the NTP-style LSL:timedata probes.

When every host on the network is already synchronised by PTP, that estimate is the weakest link. Measurements on a Pi 5 / Gemini HUB2 / Mac mini rig, against a PTP reference:

  • liblsl's offset error comes from per-host stamping bias: [(s_A − r_A) − (s_B − r_B)]/2. It is about ±5 µs on well-configured hosts, ±27 µs with default NIC interrupt coalescing on the Pi, and shifts by tens of µs with load. Nothing in the reported uncertainty shows it.
  • PTP with hardware timestamps keeps the same hosts within ~1 µs.

Proposal: an lsl_api.cfg option to select the clock behind lsl_local_clock(), plus a way for inlets to skip the offset estimate when both ends share a synchronised clock domain.

Possible clock sources:

  • Linux: CLOCK_REALTIME or CLOCK_TAI when phc2sys disciplines the system clock to the PHC, or the PHC itself via clock_gettime(FD_TO_CLOCKID(fd)) on /dev/ptpN.
  • Windows: GetSystemTimePreciseAsFileTime. The w32time PTP client (Windows 11 / Server 2019+) steers system time, not QPC.
  • macOS: the system clock is not disciplined by gPTP. The kernel's 802.1AS mapping from mach time is reachable only through a private framework (see jclark/mac-gptp), so macOS may have to stay on steady_clock.

Design points:

  • Shared clock domain. Extend the clock token added for same-clock detection, so the timedata reply can advertise a domain such as ptp:<grandmasterIdentity>:<domainNumber>. The inlet then uses offset 0 when both ends match, and falls back to probing otherwise. The grandmaster identity is readable via pmc or the linuxptp management socket.
  • Steps and slews. A wall-clock source can step. It must be monotonic in practice, and steps must be detected; reject the option, or warn, if the system clock is not disciplined.
  • Double precision. Epoch-based seconds (~1.8e9) in a double resolve only ~0.24 µs. That is acceptable but worth stating, and an argument for an epoch offset or for keeping lsl_local_clock_ns() as the primary interface.
  • Mixed configurations. Hosts using steady_clock and hosts using a PTP clock must interoperate. That works with today's probes, since the offset is simply large.

Not in scope now; filed to record the idea.

Lingua principale
C++
Stelle
184
Fork
93
Merge medio
1g 14h
PR unite (30g)
6

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di sccn/liblsl

Tutte le issue di sccn/liblsl

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.