MCPcopy Create free account
hub / github.com/facebook/time / PPSSinkFromDevice

Function PPSSinkFromDevice

phc/pps_source.go:265–294  ·  view source on GitHub ↗

PPSSinkFromDevice configures the targetDevice to be a PPS sink and report PPS timestamp events

(targetDevice DeviceController, pinIndex uint)

Source from the content-addressed store, hash-verified

263}
264
265// PPSSinkFromDevice configures the targetDevice to be a PPS sink and report PPS timestamp events
266func PPSSinkFromDevice(targetDevice DeviceController, pinIndex uint) (*PPSSink, error) {
267 pfd := unix.PollFd{
268 Events: unix.POLLIN | unix.POLLPRI,
269 Fd: int32(targetDevice.Fd()),
270 }
271 ppsSink := PPSSink{
272 InputPin: pinIndex,
273 Polarity: unix.PTP_RISING_EDGE,
274 PulseWidth: defaultPulseWidth,
275 Device: targetDevice,
276 pollDescriptor: pfd,
277 }
278
279 req := &PtpExttsRequest{
280 Flags: unix.PTP_ENABLE_FEATURE | ppsSink.Polarity,
281 Index: uint32(ppsSink.InputPin), //nolint:gosec // InputPin is a small pin index that always fits in uint32
282 }
283
284 err := targetDevice.setPinFunc(pinIndex, unix.PTP_PF_EXTTS, defaultTs2PhcChannel)
285 if err != nil {
286 return nil, fmt.Errorf("error setting extts input pin for device %s: %w", targetDevice.File().Name(), err)
287 }
288
289 err = targetDevice.extTTSRequest(req)
290 if err != nil {
291 return nil, fmt.Errorf("error during extts request for device %s: %w", targetDevice.File().Name(), err)
292 }
293
294 return &ppsSink, nil
295}
296
297// getPPSEventTimestamp reads the first PPS event from the sink file descriptor and returns the timestamp of the event

Callers 1

ts2phcRunFunction · 0.92

Calls 5

FdMethod · 0.65
setPinFuncMethod · 0.65
NameMethod · 0.65
FileMethod · 0.65
extTTSRequestMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…