* Modified API hackrf_is_streaming() now it returns an int HACKRF_TRUE when streaming is running.
* Added new hackrf_error especially for streaming to return more details. * Adding management of usb transfer cancelled for hackrf_stop_rx()/hackrf_stop_tx(). * Added robustness on hackrf_close() to correctly close libusb related stuff even if USB device is removed or other problems. * Fixed threading problems (start, stop() then start() ...). * Cleanup the whole code.
This commit is contained in:
@ -572,7 +572,7 @@ int main(int argc, char** argv) {
|
|||||||
gettimeofday(&time_start, NULL);
|
gettimeofday(&time_start, NULL);
|
||||||
|
|
||||||
printf("Stop with Ctrl-C\n");
|
printf("Stop with Ctrl-C\n");
|
||||||
while( (hackrf_is_streaming(device)) &&
|
while( (hackrf_is_streaming(device) == HACKRF_TRUE) &&
|
||||||
(do_exit == false) )
|
(do_exit == false) )
|
||||||
{
|
{
|
||||||
sleep(1);
|
sleep(1);
|
||||||
@ -597,10 +597,13 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result = hackrf_is_streaming(device);
|
||||||
if (do_exit)
|
if (do_exit)
|
||||||
|
{
|
||||||
printf("\nUser cancel, exiting...\n");
|
printf("\nUser cancel, exiting...\n");
|
||||||
else
|
} else {
|
||||||
printf("\nExiting...\n");
|
printf("\nExiting... hackrf_is_streaming() result: %s (%d)\n", hackrf_error_name(result), result);
|
||||||
|
}
|
||||||
|
|
||||||
struct timeval t_end;
|
struct timeval t_end;
|
||||||
gettimeofday(&t_end, NULL);
|
gettimeofday(&t_end, NULL);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -49,12 +49,16 @@
|
|||||||
|
|
||||||
enum hackrf_error {
|
enum hackrf_error {
|
||||||
HACKRF_SUCCESS = 0,
|
HACKRF_SUCCESS = 0,
|
||||||
|
HACKRF_TRUE = 1,
|
||||||
HACKRF_ERROR_INVALID_PARAM = -2,
|
HACKRF_ERROR_INVALID_PARAM = -2,
|
||||||
HACKRF_ERROR_NOT_FOUND = -5,
|
HACKRF_ERROR_NOT_FOUND = -5,
|
||||||
HACKRF_ERROR_BUSY = -6,
|
HACKRF_ERROR_BUSY = -6,
|
||||||
HACKRF_ERROR_NO_MEM = -11,
|
HACKRF_ERROR_NO_MEM = -11,
|
||||||
HACKRF_ERROR_LIBUSB = -1000,
|
HACKRF_ERROR_LIBUSB = -1000,
|
||||||
HACKRF_ERROR_THREAD = -1001,
|
HACKRF_ERROR_THREAD = -1001,
|
||||||
|
HACKRF_ERROR_STREAMING_THREAD_ERR = -1002,
|
||||||
|
HACKRF_ERROR_STREAMING_STOPPED = -1003,
|
||||||
|
HACKRF_ERROR_STREAMING_EXIT_CALLED = -1004,
|
||||||
HACKRF_ERROR_OTHER = -9999,
|
HACKRF_ERROR_OTHER = -9999,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -99,7 +103,8 @@ extern ADDAPI int ADDCALL hackrf_stop_rx(hackrf_device* device);
|
|||||||
extern ADDAPI int ADDCALL hackrf_start_tx(hackrf_device* device, hackrf_sample_block_cb_fn callback, void* tx_ctx);
|
extern ADDAPI int ADDCALL hackrf_start_tx(hackrf_device* device, hackrf_sample_block_cb_fn callback, void* tx_ctx);
|
||||||
extern ADDAPI int ADDCALL hackrf_stop_tx(hackrf_device* device);
|
extern ADDAPI int ADDCALL hackrf_stop_tx(hackrf_device* device);
|
||||||
|
|
||||||
extern ADDAPI bool ADDCALL hackrf_is_streaming(hackrf_device* device);
|
/* return HACKRF_TRUE if success */
|
||||||
|
extern ADDAPI int ADDCALL hackrf_is_streaming(hackrf_device* device);
|
||||||
|
|
||||||
extern ADDAPI int ADDCALL hackrf_max2837_read(hackrf_device* device, uint8_t register_number, uint16_t* value);
|
extern ADDAPI int ADDCALL hackrf_max2837_read(hackrf_device* device, uint8_t register_number, uint16_t* value);
|
||||||
extern ADDAPI int ADDCALL hackrf_max2837_write(hackrf_device* device, uint8_t register_number, uint16_t value);
|
extern ADDAPI int ADDCALL hackrf_max2837_write(hackrf_device* device, uint8_t register_number, uint16_t value);
|
||||||
|
Reference in New Issue
Block a user