RTL-SDR IQ sample reader
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocaml-rtlsdr: defer file I/O behind read_capture / with_meta

The README example called [Rtlsdr.of_file "capture.raw"] at top level,
so mdx execution failed [Sys_error: No such file or directory]. Wrap
the IO into [read_capture path] and [with_meta path] functions and
switch [Printf.printf] to [Fmt.pr], adding [fmt] to the mdx libraries.

+15 -13
+14 -12
README.md
··· 31 31 ## Usage 32 32 33 33 ```ocaml 34 - (* Read IQ samples from a raw capture file *) 35 - let src = Rtlsdr.of_file "capture.raw" 36 - let () = Printf.printf "%d samples available\n" (Rtlsdr.sample_count src) 37 - let samples = Rtlsdr.read src 4096 38 - let () = Rtlsdr.close src 34 + (* Read IQ samples from a raw capture file. *) 35 + let read_capture path = 36 + let src = Rtlsdr.of_file path in 37 + Fmt.pr "%d samples available@." (Rtlsdr.sample_count src); 38 + let samples = Rtlsdr.read src 4096 in 39 + Rtlsdr.close src; 40 + samples 39 41 40 - (* Attach recording metadata *) 41 - let meta = 42 - Rtlsdr.of_file "capture.raw" 42 + (* Attach recording metadata. *) 43 + let with_meta path = 44 + Rtlsdr.of_file path 43 45 |> Rtlsdr.with_metadata 44 46 { center_freq = 137.5e6; sample_rate = 2.4e6; gain = 40.0 } 45 47 46 - (* Generate a synthetic BPSK signal for testing *) 48 + (* Generate a synthetic BPSK signal for testing. *) 47 49 let bits = Bytes.of_string "\x01\x00\x01\x01\x00" 50 + 48 51 let iq = 49 - Rtlsdr.generate_bpsk 50 - ~sample_rate:48000.0 ~symbol_rate:1200.0 51 - ~bits ~carrier_freq:1800.0 52 + Rtlsdr.generate_bpsk ~sample_rate:48000.0 ~symbol_rate:1200.0 ~bits 53 + ~carrier_freq:1800.0 52 54 ``` 53 55 54 56 ## API Overview
+1 -1
dune
··· 4 4 5 5 (mdx 6 6 (files README.md) 7 - (libraries rtlsdr)) 7 + (libraries rtlsdr fmt))