Support compiling with Visual Studio
This commit is contained in:
@ -24,12 +24,15 @@
|
||||
set(INSTALL_DEFAULT_BINDIR "bin" CACHE STRING "Appended to CMAKE_INSTALL_PREFIX")
|
||||
|
||||
INCLUDE(FindPkgConfig)
|
||||
pkg_check_modules(FFTW REQUIRED fftw3f)
|
||||
|
||||
if(MSVC)
|
||||
add_library(libgetopt_static STATIC
|
||||
../getopt/getopt.c
|
||||
)
|
||||
else()
|
||||
pkg_check_modules(FFTW REQUIRED fftw3f)
|
||||
LIST(APPEND TOOLS hackrf_sweep)
|
||||
LIST(APPEND TOOLS_LINK_LIBS m fftw3f)
|
||||
endif()
|
||||
|
||||
SET(TOOLS
|
||||
@ -41,7 +44,6 @@ SET(TOOLS
|
||||
hackrf_cpldjtag
|
||||
hackrf_info
|
||||
hackrf_operacake
|
||||
hackrf_sweep
|
||||
)
|
||||
|
||||
if(NOT libhackrf_SOURCE_DIR)
|
||||
@ -55,8 +57,6 @@ if(MSVC)
|
||||
LIST(APPEND TOOLS_LINK_LIBS libgetopt_static)
|
||||
endif()
|
||||
|
||||
LIST(APPEND TOOLS_LINK_LIBS m fftw3f)
|
||||
|
||||
foreach(tool ${TOOLS})
|
||||
add_executable(${tool} ${tool}.c)
|
||||
target_link_libraries(${tool} ${TOOLS_LINK_LIBS})
|
||||
|
@ -379,19 +379,21 @@ int rx_callback(hackrf_transfer* transfer) {
|
||||
}
|
||||
}
|
||||
if (stream_size>0){
|
||||
if ((stream_size-1+stream_head-stream_tail)%stream_size <bytes_to_write){
|
||||
#ifndef _WIN32
|
||||
if ((stream_size-1+stream_head-stream_tail)%stream_size <bytes_to_write) {
|
||||
stream_drop++;
|
||||
}else{
|
||||
if(stream_tail+bytes_to_write <= stream_size){
|
||||
} else {
|
||||
if(stream_tail+bytes_to_write <= stream_size) {
|
||||
memcpy(stream_buf+stream_tail,transfer->buffer,bytes_to_write);
|
||||
}else{
|
||||
} else {
|
||||
memcpy(stream_buf+stream_tail,transfer->buffer,(stream_size-stream_tail));
|
||||
memcpy(stream_buf,transfer->buffer+(stream_size-stream_tail),bytes_to_write-(stream_size-stream_tail));
|
||||
};
|
||||
__atomic_store_n(&stream_tail,(stream_tail+bytes_to_write)%stream_size,__ATOMIC_RELEASE);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}else{
|
||||
} else {
|
||||
bytes_written = fwrite(transfer->buffer, 1, bytes_to_write, fd);
|
||||
if ((bytes_written != bytes_to_write)
|
||||
|| (limit_num_samples && (bytes_to_xfer == 0))) {
|
||||
@ -490,7 +492,10 @@ static void usage() {
|
||||
printf("\t[-s sample_rate_hz] # Sample rate in Hz (4/8/10/12.5/16/20MHz, default %sMHz).\n",
|
||||
u64toa((DEFAULT_SAMPLE_RATE_HZ/FREQ_ONE_MHZ),&ascii_u64_data1));
|
||||
printf("\t[-n num_samples] # Number of samples to transfer (default is unlimited).\n");
|
||||
#ifndef _WIN32
|
||||
/* The required atomic load/store functions aren't available when using C with MSVC */
|
||||
printf("\t[-S buf_size] # Enable receive streaming with buffer size buf_size.\n");
|
||||
#endif
|
||||
printf("\t[-c amplitude] # CW signal source mode, amplitude 0-127 (DC value to DAC).\n");
|
||||
printf("\t[-R] # Repeat TX mode (default is off) \n");
|
||||
printf("\t[-b baseband_filter_bw_hz] # Set baseband filter bandwidth in Hz.\n\tPossible values: 1.75/2.5/3.5/5/5.5/6/7/8/9/10/12/14/15/20/24/28MHz, default < sample_rate_hz.\n" );
|
||||
@ -1041,10 +1046,11 @@ int main(int argc, char** argv) {
|
||||
uint32_t byte_count_now;
|
||||
struct timeval time_now;
|
||||
float time_difference, rate;
|
||||
if (stream_size>0){
|
||||
if(stream_head==stream_tail){
|
||||
if (stream_size>0) {
|
||||
#ifndef _WIN32
|
||||
if(stream_head==stream_tail) {
|
||||
usleep(10000); // queue empty
|
||||
}else{
|
||||
} else {
|
||||
ssize_t len;
|
||||
ssize_t bytes_written;
|
||||
uint32_t _st= __atomic_load_n(&stream_tail,__ATOMIC_ACQUIRE);
|
||||
@ -1053,19 +1059,19 @@ int main(int argc, char** argv) {
|
||||
else
|
||||
len=stream_size-stream_head;
|
||||
bytes_written = fwrite(stream_buf+stream_head, 1, len, fd);
|
||||
if (len != bytes_written){
|
||||
if (len != bytes_written) {
|
||||
printf("write failed");
|
||||
do_exit=true;
|
||||
};
|
||||
stream_head=(stream_head+len)%stream_size;
|
||||
}
|
||||
if(stream_drop>0){
|
||||
if(stream_drop>0) {
|
||||
uint32_t drops= __atomic_exchange_n (&stream_drop,0,__ATOMIC_SEQ_CST);
|
||||
printf("dropped frames: [%d]\n",drops);
|
||||
}
|
||||
}else{
|
||||
#endif
|
||||
} else {
|
||||
sleep(1);
|
||||
|
||||
gettimeofday(&time_now, NULL);
|
||||
|
||||
byte_count_now = byte_count;
|
||||
|
@ -26,6 +26,11 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <libusb.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
/* Avoid redefinition of timespec from time.h (included by libusb.h) */
|
||||
#define HAVE_STRUCT_TIMESPEC 1
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
|
||||
#ifndef bool
|
||||
@ -396,7 +401,7 @@ hackrf_device_list_t* ADDCALL hackrf_device_list()
|
||||
serial_number_length = libusb_get_string_descriptor_ascii(usb_device, serial_descriptor_index, (unsigned char*)serial_number, sizeof(serial_number));
|
||||
if( serial_number_length == 32 ) {
|
||||
serial_number[32] = 0;
|
||||
list->serial_numbers[idx] = strndup(serial_number, serial_number_length);
|
||||
list->serial_numbers[idx] = strdup(serial_number);
|
||||
}
|
||||
|
||||
libusb_close(usb_device);
|
||||
|
@ -216,8 +216,8 @@ extern ADDAPI int ADDCALL hackrf_init_sweep(hackrf_device* device,
|
||||
int length, uint32_t dwell_time);
|
||||
|
||||
/* Operacake functions */
|
||||
int ADDCALL hackrf_get_operacake_boards(hackrf_device* device, uint8_t* boards);
|
||||
int ADDCALL hackrf_set_operacake_ports(hackrf_device* device,
|
||||
extern ADDAPI int ADDCALL hackrf_get_operacake_boards(hackrf_device* device, uint8_t* boards);
|
||||
extern ADDAPI int ADDCALL hackrf_set_operacake_ports(hackrf_device* device,
|
||||
uint8_t address,
|
||||
uint8_t port_a,
|
||||
uint8_t port_b);
|
||||
|
Reference in New Issue
Block a user