Merge pull request #1161 from greatscottgadgets/wee-bugs
clean-up and small bug fixes
This commit is contained in:
@ -335,7 +335,6 @@ bool signalsource = false;
|
|||||||
uint32_t amplitude = 0;
|
uint32_t amplitude = 0;
|
||||||
|
|
||||||
bool hw_sync = false;
|
bool hw_sync = false;
|
||||||
uint32_t hw_sync_enable = 0;
|
|
||||||
|
|
||||||
bool receive = false;
|
bool receive = false;
|
||||||
bool receive_wav = false;
|
bool receive_wav = false;
|
||||||
@ -397,7 +396,7 @@ void stop_main_loop(void)
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
SetEvent(interrupt_handle);
|
SetEvent(interrupt_handle);
|
||||||
#else
|
#else
|
||||||
kill(0, SIGALRM);
|
kill(getpid(), SIGALRM);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -639,7 +638,7 @@ static void usage()
|
|||||||
printf("\t[-b baseband_filter_bw_hz] # Set baseband filter bandwidth in Hz.\n");
|
printf("\t[-b baseband_filter_bw_hz] # Set baseband filter bandwidth in Hz.\n");
|
||||||
printf("\tPossible values: 1.75/2.5/3.5/5/5.5/6/7/8/9/10/12/14/15/20/24/28MHz, default <= 0.75 * sample_rate_hz.\n");
|
printf("\tPossible values: 1.75/2.5/3.5/5/5.5/6/7/8/9/10/12/14/15/20/24/28MHz, default <= 0.75 * sample_rate_hz.\n");
|
||||||
printf("\t[-C ppm] # Set Internal crystal clock error in ppm.\n");
|
printf("\t[-C ppm] # Set Internal crystal clock error in ppm.\n");
|
||||||
printf("\t[-H hw_sync_enable] # Synchronise USB transfer using GPIO pins.\n");
|
printf("\t[-H hw_sync] # Synchronize RX/TX to external input signal.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static hackrf_device* device = NULL;
|
static hackrf_device* device = NULL;
|
||||||
@ -693,15 +692,12 @@ int main(int argc, char** argv)
|
|||||||
stats_t stats = {0, 0};
|
stats_t stats = {0, 0};
|
||||||
static int32_t preload_bytes = 0;
|
static int32_t preload_bytes = 0;
|
||||||
|
|
||||||
while ((opt =
|
while ((opt = getopt(argc, argv, "Hwr:t:f:i:o:m:a:p:s:Fn:b:l:g:x:c:d:C:RS:Bh?")) !=
|
||||||
getopt(argc,
|
EOF) {
|
||||||
argv,
|
|
||||||
"H:wr:t:f:i:o:m:a:p:s:Fn:b:l:g:x:c:d:C:RS:Bh?")) != EOF) {
|
|
||||||
result = HACKRF_SUCCESS;
|
result = HACKRF_SUCCESS;
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'H':
|
case 'H':
|
||||||
hw_sync = true;
|
hw_sync = true;
|
||||||
result = parse_u32(optarg, &hw_sync_enable);
|
|
||||||
break;
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
receive_wav = true;
|
receive_wav = true;
|
||||||
@ -1166,10 +1162,10 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "call hackrf_set_hw_sync_mode(%d)\n", hw_sync_enable);
|
fprintf(stderr, "call hackrf_set_hw_sync_mode(%d)\n", hw_sync ? 1 : 0);
|
||||||
result = hackrf_set_hw_sync_mode(
|
result = hackrf_set_hw_sync_mode(
|
||||||
device,
|
device,
|
||||||
hw_sync_enable ? HW_SYNC_MODE_ON : HW_SYNC_MODE_OFF);
|
hw_sync ? HW_SYNC_MODE_ON : HW_SYNC_MODE_OFF);
|
||||||
if (result != HACKRF_SUCCESS) {
|
if (result != HACKRF_SUCCESS) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"hackrf_set_hw_sync_mode() failed: %s (%d)\n",
|
"hackrf_set_hw_sync_mode() failed: %s (%d)\n",
|
||||||
@ -1253,6 +1249,8 @@ int main(int argc, char** argv)
|
|||||||
result |= hackrf_set_lna_gain(device, lna_gain);
|
result |= hackrf_set_lna_gain(device, lna_gain);
|
||||||
result |= hackrf_start_rx(device, rx_callback, NULL);
|
result |= hackrf_start_rx(device, rx_callback, NULL);
|
||||||
} else {
|
} else {
|
||||||
|
preload_bytes = hackrf_get_transfer_queue_depth(device) *
|
||||||
|
hackrf_get_transfer_buffer_size(device);
|
||||||
result = hackrf_set_txvga_gain(device, txvga_gain);
|
result = hackrf_set_txvga_gain(device, txvga_gain);
|
||||||
result |= hackrf_enable_tx_flush(device, 1);
|
result |= hackrf_enable_tx_flush(device, 1);
|
||||||
result |= hackrf_start_tx(device, tx_callback, NULL);
|
result |= hackrf_start_tx(device, tx_callback, NULL);
|
||||||
@ -1283,9 +1281,6 @@ int main(int argc, char** argv)
|
|||||||
.it_value = {.tv_sec = 1, .tv_usec = 0}};
|
.it_value = {.tv_sec = 1, .tv_usec = 0}};
|
||||||
setitimer(ITIMER_REAL, &interval_timer, NULL);
|
setitimer(ITIMER_REAL, &interval_timer, NULL);
|
||||||
#endif
|
#endif
|
||||||
preload_bytes = hackrf_get_transfer_queue_depth(device) *
|
|
||||||
hackrf_get_transfer_buffer_size(device);
|
|
||||||
|
|
||||||
while ((hackrf_is_streaming(device) == HACKRF_TRUE) && (do_exit == false)) {
|
while ((hackrf_is_streaming(device) == HACKRF_TRUE) && (do_exit == false)) {
|
||||||
uint64_t byte_count_now;
|
uint64_t byte_count_now;
|
||||||
struct timeval time_now;
|
struct timeval time_now;
|
||||||
@ -1356,8 +1351,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
time_difference = TimevalDiff(&time_now, &time_start);
|
time_difference = TimevalDiff(&time_now, &time_start);
|
||||||
rate = (float) byte_count_now / time_difference;
|
rate = (float) byte_count_now / time_difference;
|
||||||
if (byte_count_now == 0 && hw_sync == true &&
|
if ((byte_count_now == 0) && (hw_sync)) {
|
||||||
hw_sync_enable != 0) {
|
|
||||||
fprintf(stderr, "Waiting for sync...\n");
|
fprintf(stderr, "Waiting for sync...\n");
|
||||||
} else {
|
} else {
|
||||||
double full_scale_ratio = (double) stream_power_now /
|
double full_scale_ratio = (double) stream_power_now /
|
||||||
@ -1395,8 +1389,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
time_start = time_now;
|
time_start = time_now;
|
||||||
|
|
||||||
if (byte_count_now == 0 &&
|
if ((byte_count_now == 0) && (!hw_sync)) {
|
||||||
(hw_sync == false || hw_sync_enable == 0)) {
|
|
||||||
exit_code = EXIT_FAILURE;
|
exit_code = EXIT_FAILURE;
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"\nCouldn't transfer any bytes for one second.\n");
|
"\nCouldn't transfer any bytes for one second.\n");
|
||||||
|
@ -154,7 +154,9 @@ typedef struct hackrf_device hackrf_device;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* USB transfer information passed to RX or TX callback.
|
* USB transfer information passed to RX or TX callback.
|
||||||
* A callback should treat all these fields as read-only except that a TX callback should write to the data buffer.
|
* A callback should treat all these fields as read-only except that a TX
|
||||||
|
* callback should write to the data buffer and may write to valid_length to
|
||||||
|
* indicate that a smaller number of bytes is to be transmitted.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
hackrf_device* device; /**< HackRF USB device for this transfer */
|
hackrf_device* device; /**< HackRF USB device for this transfer */
|
||||||
|
Reference in New Issue
Block a user