Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hackrf.h ### Example TX code utilizing the transfer and flush callbacks. #432

Closed
smileyrekiere opened this issue Apr 2, 2024 · 2 comments

Comments

@smileyrekiere
Copy link

smileyrekiere commented Apr 2, 2024

Compiling the Example TX code utilizing the transfer and flush callback that is in hackrf.h file, copied to another file rfgen_tx.c

There was a compile error when doing (note: possible fix below, others may run into this issue). If the fix is incorrect possibly understand why.

gcc -o rfgen_tx rfgen_tx.c -lm -lhackrf

rfgen_tx.c: In function ‘main’:
rfgen_tx.c:80:36: warning: passing argument 2 of ‘hackrf_enable_tx_flush’ from incompatible pointer type [-Wincompatible-pointer-types]
80 | hackrf_enable_tx_flush(device, flush_callback, NULL);
| ^~~~~~~~~~~~~~
| |
| void (*)(hackrf_transfer ) {aka void ()(struct )}
In file included from rfgen_tx.c:3:
/usr/local/include/libhackrf/hackrf.h:1150:21: note: expected ‘hackrf_flush_cb_fn’ {aka ‘void (
)(void , int)’} but argument is of type ‘void ()(hackrf_transfer )’ {aka ‘void ()(struct *)’}
1150 | hackrf_flush_cb_fn callback,

Needed to change line
** void flush_callback(hackrf_transfer *transfer) { **

to:
void flush_callback(void * transfer, int success) {

to get the source to compile and run the file.

Verified the signal transmitted and debug printed

hackrf_open
hackrf_open_setup
libusb_get_configuration result: 0
hackrf_open_setup: set_hackrf_configuration result: 0
libusb_claim_interface result: 0
hackrf_set_freq
hackrf_set_txvga_gain
hackrf_enable_tx_flush
hackrf_close

Thank-you for the Code Example provided by :
// Transmit a 440Hz triangle wave through FM (144.5MHz) using the libhackrf API
// Copyright (c) 2022 László Baráth "Uncle Dino" HA7DN https://github.com/Sasszem

hackrf_info:
hackrf_info version: git-6211fbb0*
libhackrf version: git-6211fbb0* (0.8)
Found HackRF
Index: 0
Serial number: 000000000000000057b068dc22276763
hackrf_open_setup
libusb_get_configuration result: 0
hackrf_open_setup: set_hackrf_configuration result: 0
libusb_claim_interface result: 0
Board ID Number: 2 (HackRF One)
Firmware Version: 2023.01.1 (API:1.07)
Part ID Number: 0xa000cb3c 0x00644754
Hardware Revision: older than r6
Hardware supported by installed firmware:
HackRF One
hackrf_close

Host code also at 2023.

@zuckschwerdt
Copy link
Member

zuckschwerdt commented Apr 2, 2024

This seems to be about HackRF?

Can you add information explaining: how is this linked to SoapySDR? What didn't work, and what (code, example, or wiki) needs to be fixed?

edit: indeed this references hackrf.h verbatim and does not concern SoapySDR. Closing.

@smileyrekiere
Copy link
Author

@zuckschwerdt Thank-you for pointing out my error. I couldn't figure out why I couldn't find it in https://github.com/greatscottgadgets/hackrf/issues after I wrote it.

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

No branches or pull requests

2 participants