This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
mac-pps implements two approaches for timestamping Pulse Per Second (PPS) signals on macOS for precision timing applications with GPS receivers and atomic clocks:
- pollpps - Monitors USB-to-serial adapter CTS modem control lines (with chrony integration)
- audiopps - Captures PPS signals converted to audio impulses via CoreAudio (chrony integration pending)
make./pollpps <device>
# Example: ./pollpps /dev/tty.usbserial-0001make clean
make- chrony_client.c/h - Shared library for communicating with chrony via SOCK refclock
- pollpps.c - USB-to-serial CTS line monitoring program (chrony integration complete)
- audiopps.c - CoreAudio-based PPS detection program (chrony integration pending)
- Opens USB-to-serial device and monitors CTS modem control line
- Polls CTS status every 100 microseconds using
ioctl(TIOCMGET) - Detects falling edges (CTS on→off transitions) representing PPS pulses
- Timestamps using
clock_gettime(CLOCK_REALTIME) - Calculates offset and optionally sends to chrony via shared chrony_client library
Key technical aspects:
- Polls CTS line every 100 microseconds
- Typical timing jitter: ~1ms due to USB latency
- Uses signal handlers for graceful shutdown
- Handles RS232 to TTL signal polarity conversion (CTS asserted = 0V, deasserted = 3.3V)
Currently implements Phase 1 of audio-plan.md:
- Audio device enumeration and selection
- CoreAudio capture setup with threshold detection
- Sample-accurate pulse timing within audio buffers
- Console output of timestamps
Pending: Integration with shared chrony_client library for Phase 2
- The code contains detailed comments explaining signal polarity and timing
- Error handling is implemented for all device operations
- The binary targets ARM64 architecture (Apple Silicon)
- No external dependencies beyond standard C libraries