It took me a while to produce one more function, which is hackrf-open
. This delay was mainly because I had a shaky understanding of some of the Racket FFI concepts and functions, so I had to go back and relearn several things, especially relating to handling C pointers in Racket. Another thing that is interesting: In C you are expected to manually allocate and deallocate memory, and signal errors via an integer return value, whereas in Scheme we are expecting the memory management to happen automatically, with errors being signaled by exceptions, so there is some work to be done bridging between to two ideas.
Anyway, hackrf-open
was a good step as it gives you access to the hackrf_device pointer, which has to be passed to most of the other hackrf control functions.
racket@hackrf.rkt> (define dev (hackrf-open)) racket@hackrf.rkt> dev #<cpointer:hackrf_device>
If you run (exit) or assign something else to dev
, the program will run hackrf_close
on #<cpointer:hackrf_device>
.
git clone git://git.librehacker.com/pub/git/hackrf-rkt.git