tl;dr: I can set radio parameters and also transfer RX data to a file.
I created many of the bindings for setting radio parameters, such as setting the center frequency and the sample rate. Those bindings were easy.
Figuring out the binding for the hackrf_start_rx function, and figuring out how to make use of it, was difficult and took a lot of time. This is because internally hackrf_start_rx utilizes pthreads, which apparently does not play well with the Racket environment unless you pass in special parameters to _fun ctype. Once I figured that out, I had a lot of difficult figuring out how pull data from the hackrf_transfer buffer, and I kept trying to write the data to a file but couldn’t seem to pull it off.
Anyway, I figured that out for the most part, and was able to dump RX data to a file at a speed that seemed to match up with my set sample rate, which was 8 mhz. However, I’m not quite sure about the efficiency of that operation as I was calling write-byte for each byte in the buffer. I wanted to use write-bytes instead to transfer the whole buffer in one call, but I was having trouble getting that to work.
email@example.com> (hackrf-init) firstname.lastname@example.org> (define h (hackrf-open)) email@example.com> (sensible-defaults h) firstname.lastname@example.org> (define out (open-output-file "out.bin")) email@example.com> (define cb (cb-rx-to-port out)) firstname.lastname@example.org> (hackrf-start-rx h cb)
christopher@nightshade:~/Repos/hackrf-rkt$ hexdump out.bin | head 0000000 fa00 0201 f6ff 0303 f802 0100 fc00 ff04 0000010 fff7 fa03 01f8 fdfe fefe fbfd 0000 f6fe 0000020 0305 f9fe fb08 02fb f803 05fd fbff ffff 0000030 fbf9 0100 faf9 ff03 fcfd f702 0200 f902 0000040 0102 fc03 fefe fcfc 0203 fdf4 fe06 fff8 0000050 f9fe 0202 f7fe 0104 f401 0000 feff fb04 0000060 05fa f702 03fa fffc fe00 fdfc fe04 f6fb 0000070 0105 fafd f906 02ff f500 0600 fdfc 0000 0000080 fdfc fe01 fef6 fd04 fffc f500 0004 f7fb 0000090 0103 fb01 fe01 fdfc 0003 02f5 fd05 01fb