Skip to content

Commit

Permalink
bindings,test: Type SampleRate as Nat instead of Int
Browse files Browse the repository at this point in the history
Signed-off-by: Edward O'Callaghan <edward@antitrust.cc>
  • Loading branch information
antitrustcc committed Oct 10, 2024
1 parent 0c09f32 commit 298fcf2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Bindings/RtlSdr/Sampling.idr
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import Bindings.RtlSdr.Raw.Sampling
||| 900001 - 3200000 Hz
||| sample loss is to be expected for rates > 2400000
export
setSampleRate : Ptr RtlSdrHandle -> Int -> IO (Either RTLSDR_ERROR ())
setSampleRate : Ptr RtlSdrHandle -> Nat -> IO (Either RTLSDR_ERROR ())
setSampleRate h r = do
r <- fromPrim $ set_sample_rate h r
r <- fromPrim $ set_sample_rate h (cast {to = Int} r)
io_pure $ if r == 0 then Right () else Left RtlSdrInvalidRate

||| Get actual sample rate the device is configured to.
Expand Down
4 changes: 2 additions & 2 deletions test/src/Main.idr
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ freqStr v = case v of
decodeRTLSDRError : (Show a) => Either RTLSDR_ERROR a -> String
decodeRTLSDRError v = fromMaybe "<unknown>" $ map show $ getRight v

cfgRTL : Ptr RtlSdrHandle -> Int -> Int -> Int -> IO ()
cfgRTL : Ptr RtlSdrHandle -> Int -> Int -> Nat -> IO ()
cfgRTL h fq ppm r = do
_ <- setTunerGainMode h False -- manual gain
_ <- setTunerGain h (-100) -- auto
Expand Down Expand Up @@ -146,7 +146,7 @@ testAM args = do
putErr $ "Using a in rate of: " ++ (show $ rate_in `div` 1_000) ++ " kHz."
let rate_downsample = (1_000_000 `div` rate_in) + 1
putErr $ "Calculated downsampling of: " ++ (show rate_downsample) ++ "x."
let rate_iq = rate_downsample * rate_in
let rate_iq = cast $ rate_downsample * rate_in
putErr $ "Sampling IQ stream at: " ++ (show $ rate_iq `div` 1_000) ++ "kHz."

let ppm = fromMaybe 0 args.ppm -- default ppm of zero.
Expand Down

0 comments on commit 298fcf2

Please sign in to comment.