operacake: replace hackrf_set_operacake_ranges with hackrf_set_operacake_freq_ranges
This commit is contained in:
@ -34,7 +34,6 @@ typedef int bool;
|
|||||||
|
|
||||||
#define FREQ_MIN_MHZ (0) /* 0 MHz */
|
#define FREQ_MIN_MHZ (0) /* 0 MHz */
|
||||||
#define FREQ_MAX_MHZ (7250) /* 7250 MHz */
|
#define FREQ_MAX_MHZ (7250) /* 7250 MHz */
|
||||||
#define MAX_FREQ_RANGES 8
|
|
||||||
|
|
||||||
#define INVALID_ADDRESS 0xFF
|
#define INVALID_ADDRESS 0xFF
|
||||||
#define INVALID_MODE 0xFF
|
#define INVALID_MODE 0xFF
|
||||||
@ -66,12 +65,6 @@ static struct option long_options[] = {
|
|||||||
{ 0, 0, 0, 0 },
|
{ 0, 0, 0, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint16_t freq_min;
|
|
||||||
uint16_t freq_max;
|
|
||||||
uint8_t port;
|
|
||||||
} hackrf_oc_range;
|
|
||||||
|
|
||||||
int parse_uint16(char* const s, uint16_t* const value) {
|
int parse_uint16(char* const s, uint16_t* const value) {
|
||||||
char* s_end = s;
|
char* s_end = s;
|
||||||
const long long_value = strtol(s, &s_end, 10);
|
const long long_value = strtol(s, &s_end, 10);
|
||||||
@ -128,7 +121,7 @@ int parse_port(char* str, uint8_t* port) {
|
|||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int parse_range(char* s, hackrf_oc_range* range) {
|
int parse_range(char* s, hackrf_operacake_freq_range* range) {
|
||||||
char port[16];
|
char port[16];
|
||||||
float min;
|
float min;
|
||||||
float max;
|
float max;
|
||||||
@ -180,7 +173,7 @@ int main(int argc, char** argv) {
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
hackrf_device* device = NULL;
|
hackrf_device* device = NULL;
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
hackrf_oc_range ranges[MAX_FREQ_RANGES];
|
hackrf_operacake_freq_range ranges[HACKRF_OPERACAKE_MAX_FREQ_RANGES];
|
||||||
hackrf_operacake_dwell_time dwell_times[HACKRF_OPERACAKE_MAX_DWELL_TIMES];
|
hackrf_operacake_dwell_time dwell_times[HACKRF_OPERACAKE_MAX_DWELL_TIMES];
|
||||||
uint8_t range_idx = 0;
|
uint8_t range_idx = 0;
|
||||||
uint8_t dwell_idx = 0;
|
uint8_t dwell_idx = 0;
|
||||||
@ -220,10 +213,10 @@ int main(int argc, char** argv) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
if(MAX_FREQ_RANGES == range_idx) {
|
if (HACKRF_OPERACAKE_MAX_FREQ_RANGES == range_idx) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"argument error: specify a maximum of %u frequency ranges.\n",
|
"argument error: specify a maximum of %u frequency ranges.\n",
|
||||||
MAX_FREQ_RANGES);
|
HACKRF_OPERACAKE_MAX_FREQ_RANGES);
|
||||||
usage();
|
usage();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
@ -432,21 +425,10 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(range_idx) {
|
if (range_idx) {
|
||||||
uint8_t range_bytes[MAX_FREQ_RANGES * sizeof(hackrf_oc_range)];
|
result = hackrf_set_operacake_freq_ranges(device, ranges, range_idx);
|
||||||
uint8_t ptr;
|
if (result) {
|
||||||
for(i=0; i<range_idx; i++) {
|
printf("hackrf_set_operacake_freq_ranges() failed: %s (%d)\n", hackrf_error_name(result), result);
|
||||||
ptr = 5*i;
|
|
||||||
range_bytes[ptr] = ranges[i].freq_min >> 8;
|
|
||||||
range_bytes[ptr+1] = ranges[i].freq_min & 0xFF;
|
|
||||||
range_bytes[ptr+2] = ranges[i].freq_max >> 8;
|
|
||||||
range_bytes[ptr+3] = ranges[i].freq_max & 0xFF;
|
|
||||||
range_bytes[ptr+4] = ranges[i].port;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = hackrf_set_operacake_ranges(device, range_bytes, range_idx*5);
|
|
||||||
if( result ) {
|
|
||||||
printf("hackrf_set_operacake_ranges() failed: %s (%d)\n", hackrf_error_name(result), result);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2266,6 +2266,9 @@ int ADDCALL hackrf_reset(hackrf_device* device) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated This has been replaced by @ref hackrf_set_operacake_freq_ranges
|
||||||
|
*/
|
||||||
int ADDCALL hackrf_set_operacake_ranges(hackrf_device* device, uint8_t* ranges, uint8_t len_ranges)
|
int ADDCALL hackrf_set_operacake_ranges(hackrf_device* device, uint8_t* ranges, uint8_t len_ranges)
|
||||||
{
|
{
|
||||||
USB_API_REQUIRED(device, 0x0103)
|
USB_API_REQUIRED(device, 0x0103)
|
||||||
@ -2290,6 +2293,43 @@ int ADDCALL hackrf_set_operacake_ranges(hackrf_device* device, uint8_t* ranges,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ADDCALL hackrf_set_operacake_freq_ranges(hackrf_device* device, hackrf_operacake_freq_range* freq_ranges, uint8_t count)
|
||||||
|
{
|
||||||
|
USB_API_REQUIRED(device, 0x0103)
|
||||||
|
|
||||||
|
uint8_t range_bytes[HACKRF_OPERACAKE_MAX_FREQ_RANGES * sizeof(hackrf_operacake_freq_range)];
|
||||||
|
uint8_t ptr;
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < count; i++) {
|
||||||
|
ptr = 5*i;
|
||||||
|
range_bytes[ptr] = freq_ranges[i].freq_min >> 8;
|
||||||
|
range_bytes[ptr+1] = freq_ranges[i].freq_min & 0xFF;
|
||||||
|
range_bytes[ptr+2] = freq_ranges[i].freq_max >> 8;
|
||||||
|
range_bytes[ptr+3] = freq_ranges[i].freq_max & 0xFF;
|
||||||
|
range_bytes[ptr+4] = freq_ranges[i].port;
|
||||||
|
}
|
||||||
|
|
||||||
|
int result;
|
||||||
|
int len_ranges = count*5;
|
||||||
|
result = libusb_control_transfer(
|
||||||
|
device->usb_device,
|
||||||
|
LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
|
||||||
|
HACKRF_VENDOR_REQUEST_OPERACAKE_SET_RANGES,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
range_bytes,
|
||||||
|
len_ranges,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
|
if (result < len_ranges) {
|
||||||
|
last_libusb_error = result;
|
||||||
|
return HACKRF_ERROR_LIBUSB;
|
||||||
|
} else {
|
||||||
|
return HACKRF_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#define DWELL_TIME_SIZE 5
|
#define DWELL_TIME_SIZE 5
|
||||||
static uint8_t dwell_data[DWELL_TIME_SIZE*HACKRF_OPERACAKE_MAX_DWELL_TIMES];
|
static uint8_t dwell_data[DWELL_TIME_SIZE*HACKRF_OPERACAKE_MAX_DWELL_TIMES];
|
||||||
int ADDCALL hackrf_set_operacake_dwell_times(hackrf_device* device, hackrf_operacake_dwell_time *dwell_times, uint8_t count)
|
int ADDCALL hackrf_set_operacake_dwell_times(hackrf_device* device, hackrf_operacake_dwell_time *dwell_times, uint8_t count)
|
||||||
|
@ -53,6 +53,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI
|
|||||||
#define HACKRF_OPERACAKE_ADDRESS_INVALID 0xFF
|
#define HACKRF_OPERACAKE_ADDRESS_INVALID 0xFF
|
||||||
#define HACKRF_OPERACAKE_MAX_BOARDS 8
|
#define HACKRF_OPERACAKE_MAX_BOARDS 8
|
||||||
#define HACKRF_OPERACAKE_MAX_DWELL_TIMES 16
|
#define HACKRF_OPERACAKE_MAX_DWELL_TIMES 16
|
||||||
|
#define HACKRF_OPERACAKE_MAX_FREQ_RANGES 8
|
||||||
|
|
||||||
enum hackrf_error {
|
enum hackrf_error {
|
||||||
HACKRF_SUCCESS = 0,
|
HACKRF_SUCCESS = 0,
|
||||||
@ -144,6 +145,11 @@ typedef struct {
|
|||||||
uint8_t port;
|
uint8_t port;
|
||||||
} hackrf_operacake_dwell_time;
|
} hackrf_operacake_dwell_time;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint16_t freq_min;
|
||||||
|
uint16_t freq_max;
|
||||||
|
uint8_t port;
|
||||||
|
} hackrf_operacake_freq_range;
|
||||||
|
|
||||||
struct hackrf_device_list {
|
struct hackrf_device_list {
|
||||||
char **serial_numbers;
|
char **serial_numbers;
|
||||||
@ -267,6 +273,7 @@ extern ADDAPI int ADDCALL hackrf_set_operacake_ports(hackrf_device* device,
|
|||||||
uint8_t port_a,
|
uint8_t port_a,
|
||||||
uint8_t port_b);
|
uint8_t port_b);
|
||||||
extern ADDAPI int ADDCALL hackrf_set_operacake_dwell_times(hackrf_device* device, hackrf_operacake_dwell_time *dwell_times, uint8_t count);
|
extern ADDAPI int ADDCALL hackrf_set_operacake_dwell_times(hackrf_device* device, hackrf_operacake_dwell_time *dwell_times, uint8_t count);
|
||||||
|
extern ADDAPI int ADDCALL hackrf_set_operacake_freq_ranges(hackrf_device* device, hackrf_operacake_freq_range *freq_ranges, uint8_t count);
|
||||||
|
|
||||||
extern ADDAPI int ADDCALL hackrf_reset(hackrf_device* device);
|
extern ADDAPI int ADDCALL hackrf_reset(hackrf_device* device);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user