Skip to content

Implement has/set/getFrequencyCorrection - #48

Open
ievans wants to merge 1 commit into
pothosware:masterfrom
ievans:claude/dazzling-albattani-zoyemv
Open

ievans wants to merge 1 commit into
pothosware:masterfrom
ievans:claude/dazzling-albattani-zoyemv

Conversation

@ievans

@ievans ievans commented Oct 2, 2026

Copy link
Copy Markdown

Hello, as discussed in #32 I took a stab at implementing the has/set/getFrequencyCorrection functions. Please let me know what kind of testing plan would be helpful.

I used Claude Opus to help get familiar with the codebase. Claude's summary of the PR is below for reference.


Design notes:

  • The correction matches gr-osmosdr's hackrf source/sink
    (real_freq = freq * (1.0 + ppm * 0.000001)), so a ppm value
    calibrated in gr-osmosdr based tools carries over unchanged.
  • Like gr-osmosdr, only the LO frequency is corrected.
  • The correction is a single value shared by RX and TX (the direction
    argument is ignored), since both paths use the same reference oscillator.
  • All tuning goes through a tuneFrequency() helper so no code path can
    skip the correction.
  • The minimum SoapySDR version is raised to 0.6.0, which introduced the
    frequency correction API.

Potential improvements (intentionally left out for now):

  • Also correct the sample rate, since the sample clock is derived from the
    same reference oscillator as the LO.
  • Validate the ppm value (reject non-finite values or anything beyond a
    sane bound such as ±1000 ppm); a value of -1e6 or below currently makes
    the corrected frequency zero or negative before the cast to uint64_t.
  • Clamp the corrected frequency to the advertised 7.25 GHz range, so a
    positive correction near the top of the band does not request an
    out-of-range frequency.

Testing: builds cleanly; the correction math was checked against a
stubbed libhackrf. Not yet verified on hardware across the band.

Fixes #32

🤖 Generated with Claude Code

Implement has/set/getFrequencyCorrection so clients such as SatNOGS can
compensate for HackRF reference clock error.

- Apply the correction as freq * (1.0 + ppm * 0.000001), matching
  gr-osmosdr's hackrf source/sink so existing ppm values carry over
- Correct only the LO; getFrequency still reports the requested frequency
- Share one correction between RX and TX, and retune when it changes
- Route all tuning through a tuneFrequency() helper
- Require SoapySDR 0.6.0, which introduced the frequency correction API

Fixes pothosware#32

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BxbvUpdbUDsNz18oPZFCP1
@ievans ievans changed the title Claude/dazzling albattani zoyemv Implement has/set/getFrequencyCorrection Oct 2, 2026
@ievans ievans mentioned this pull request Oct 2, 2026
@zuckschwerdt

Copy link
Copy Markdown
Member

This looks quite complete. Testing would be scanning through some PPM values and verify that the effect is as intended (maybe check that signal moves as expected in a waterfall).

I don't know about the sample rate suggestion, wouldn't that affect downstream processing?
The other two are good bounds to check (and clamp). PR that later as the next improvement if you like.

@ievans

ievans commented Oct 2, 2026

Copy link
Copy Markdown
Author

Thanks for your quick response. I just verified that it works with my hackrf on openwebrx, honoring a "ppm": 24.85 setting on the NOAA broadcasts, also verified it up at 900Mhz.

without patch:
Screenshot 2026-10-02 at 11 26 10 AM

with patch:
Screenshot 2026-10-02 at 11 23 08 AM

May make another PR for the bounds check & clamping later.

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.

Frequency Corrections

3 participants