Skip to content

term: support kernel PPS on FreeBSD - #425

Open
jclark wants to merge 2 commits into
freebsd-kppsfrom
serial-pps-freebsd
Open

term: support kernel PPS on FreeBSD#425
jclark wants to merge 2 commits into
freebsd-kppsfrom
serial-pps-freebsd

Conversation

@jclark

@jclark jclark commented Aug 21, 2026

Copy link
Copy Markdown
Owner

The watch is much shorter than the Linux one: FreeBSD serial drivers implement the PPS source on the TTY itself, so there is no line discipline to attach, no sysfs scan, and no udev retry loop. The watch requires the sysctl that configures the device PPS capture (dev.uart.N.pps_mode for uart(4), hw.usb.ucom.pps_mode for ucom(4)) to select exactly the requested pin: the invert and narrow-pulse options change what the captured edges mean, so a mismatch is reported as unavailable, naming the value to set, and automatic method selection falls back to poll. With the options clear, kernel ASSERT means the pin became asserted in the TIOCM sense, so the sequence accounting is shared with the Linux watch, moved unchanged to kernelpps.go.

Verified on FreeBSD 15.1 against a u-blox receiver on an onboard 16950 UART and a CASIC receiver on an FT232H USB adapter: 30 seconds each with no missed edges, a 6 us timestamp spread on the UART, and about 130 us of USB status-report latency on the FT232H.

Based on the freebsd-kpps branch, which it merges after.

Part of #426.

The watch is much shorter than the Linux one: FreeBSD serial drivers
implement the PPS source on the TTY itself, so there is no line
discipline to attach, no sysfs scan, and no udev retry loop. The
watch requires the sysctl that configures the device PPS capture
(dev.uart.N.pps_mode for uart(4), hw.usb.ucom.pps_mode for ucom(4))
to select exactly the requested pin: the invert and narrow-pulse
options change what the captured edges mean, so a mismatch is
reported as unavailable, naming the value to set, and automatic
method selection falls back to poll. With the options clear, kernel
ASSERT means the pin became asserted in the TIOCM sense, so the
sequence accounting is shared with the Linux watch, moved unchanged
to kernelpps.go.

Verified on FreeBSD 15.1 against a u-blox receiver on an onboard
16950 UART and a CASIC receiver on an FT232H USB adapter: 30 seconds
each with no missed edges, a 6 us timestamp spread on the UART, and
about 130 us of USB status-report latency on the FT232H.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5264a0393c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread gps/lib/term/kernelpps_freebsd.go
@jclark jclark changed the title term: use kernel PPS for the pin watch on FreeBSD term: suport kernel PPS on FreeBSD Aug 21, 2026
@jclark jclark changed the title term: suport kernel PPS on FreeBSD term: support kernel PPS on FreeBSD Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant