mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-04 23:40:04 +00:00
Changing build type to RelWithDebInfo if ENABLE_GPERFTOOLS option is ON
This commit is contained in:
parent
3257d8cba1
commit
2445620e76
@ -186,10 +186,16 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
endif(${DARWIN_VERSION} MATCHES "10")
|
||||
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
|
||||
|
||||
#select the release build type by default to get optimization flags
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
message(STATUS "Build type not specified: defaulting to Release.")
|
||||
if(ENABLE_GPERFTOOLS)
|
||||
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
|
||||
message(STATUS "Build type not specified: defaulting to RelWithDebInfo.")
|
||||
else(ENABLE_GPERFTOOLS)
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
message(STATUS "Build type not specified: defaulting to Release.")
|
||||
endif(ENABLE_GPERFTOOLS)
|
||||
endif(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "")
|
||||
|
||||
|
@ -29,10 +29,10 @@ GNSS-SDR.SUPL_CI=0x31b0
|
||||
SignalSource.implementation=File_Signal_Source
|
||||
|
||||
;#filename: path to file with the captured GNSS signal samples to be processed
|
||||
SignalSource.filename=/media/DATALOGGER/Agilent GPS Generator/cap2/agilent_cap2.dat
|
||||
SignalSource.filename=../../../Documents/workspace/code2/trunk/data/2013_04_04_GNSS_SIGNAL_at_CTTC_SPAIN.dat
|
||||
|
||||
;#item_type: Type and resolution for each of the signal samples. Use only gr_complex in this version.
|
||||
SignalSource.item_type=gr_complex
|
||||
SignalSource.item_type=short
|
||||
|
||||
;#sampling_frequency: Original Signal sampling frequency in [Hz]
|
||||
SignalSource.sampling_frequency=4000000
|
||||
@ -69,13 +69,13 @@ SignalSource.enable_throttle_control=false
|
||||
;#implementation: Use [Pass_Through] or [Signal_Conditioner]
|
||||
;#[Pass_Through] disables this block and the [DataTypeAdapter], [InputFilter] and [Resampler] blocks
|
||||
;#[Signal_Conditioner] enables this block. Then you have to configure [DataTypeAdapter], [InputFilter] and [Resampler] blocks
|
||||
;SignalConditioner.implementation=Signal_Conditioner
|
||||
SignalConditioner.implementation=Pass_Through
|
||||
SignalConditioner.implementation=Signal_Conditioner
|
||||
;SignalConditioner.implementation=Pass_Through
|
||||
|
||||
;######### DATA_TYPE_ADAPTER CONFIG ############
|
||||
;## Changes the type of input data. Please disable it in this version.
|
||||
;#implementation: [Pass_Through] disables this block
|
||||
DataTypeAdapter.implementation=Pass_Through
|
||||
DataTypeAdapter.implementation=Ishort_To_Complex
|
||||
|
||||
;######### INPUT_FILTER CONFIG ############
|
||||
;## Filter the input data. Can be combined with frequency translation for IF signals
|
||||
@ -186,60 +186,9 @@ Channel.system=GPS
|
||||
|
||||
;#signal:
|
||||
;# "1C" GPS L1 C/A
|
||||
;# "1P" GPS L1 P
|
||||
;# "1W" GPS L1 Z-tracking and similar (AS on)
|
||||
;# "1Y" GPS L1 Y
|
||||
;# "1M" GPS L1 M
|
||||
;# "1N" GPS L1 codeless
|
||||
;# "2C" GPS L2 C/A
|
||||
;# "2D" GPS L2 L1(C/A)+(P2-P1) semi-codeless
|
||||
;# "2S" GPS L2 L2C (M)
|
||||
;# "2L" GPS L2 L2C (L)
|
||||
;# "2X" GPS L2 L2C (M+L)
|
||||
;# "2P" GPS L2 P
|
||||
;# "2W" GPS L2 Z-tracking and similar (AS on)
|
||||
;# "2Y" GPS L2 Y
|
||||
;# "2M" GPS GPS L2 M
|
||||
;# "2N" GPS L2 codeless
|
||||
;# "5I" GPS L5 I
|
||||
;# "5Q" GPS L5 Q
|
||||
;# "5X" GPS L5 I+Q
|
||||
;# "1C" GLONASS G1 C/A
|
||||
;# "1P" GLONASS G1 P
|
||||
;# "2C" GLONASS G2 C/A (Glonass M)
|
||||
;# "2P" GLONASS G2 P
|
||||
;# "1A" GALILEO E1 A (PRS)
|
||||
;# "1B" GALILEO E1 B (I/NAV OS/CS/SoL)
|
||||
;# "1C" GALILEO E1 C (no data)
|
||||
;# "1X" GALILEO E1 B+C
|
||||
;# "1Z" GALILEO E1 A+B+C
|
||||
;# "5I" GALILEO E5a I (F/NAV OS)
|
||||
;# "5Q" GALILEO E5a Q (no data)
|
||||
;# "5X" GALILEO E5a I+Q
|
||||
;# "7I" GALILEO E5b I
|
||||
;# "7Q" GALILEO E5b Q
|
||||
;# "7X" GALILEO E5b I+Q
|
||||
;# "8I" GALILEO E5 I
|
||||
;# "8Q" GALILEO E5 Q
|
||||
;# "8X" GALILEO E5 I+Q
|
||||
;# "6A" GALILEO E6 A
|
||||
;# "6B" GALILEO E6 B
|
||||
;# "6C" GALILEO E6 C
|
||||
;# "6X" GALILEO E6 B+C
|
||||
;# "6Z" GALILEO E6 A+B+C
|
||||
;# "1C" SBAS L1 C/A
|
||||
;# "5I" SBAS L5 I
|
||||
;# "5Q" SBAS L5 Q
|
||||
;# "5X" SBAS L5 I+Q
|
||||
;# "2I" COMPASS E2 I
|
||||
;# "2Q" COMPASS E2 Q
|
||||
;# "2X" COMPASS E2 IQ
|
||||
;# "7I" COMPASS E5b I
|
||||
;# "7Q" COMPASS E5b Q
|
||||
;# "7X" COMPASS E5b IQ
|
||||
;# "6I" COMPASS E6 I
|
||||
;# "6Q" COMPASS E6 Q
|
||||
;# "6X" COMPASS E6 IQ
|
||||
|
||||
;#if the option is disabled by default is assigned "1C" GPS L1 C/A
|
||||
Channel.signal=1C
|
||||
|
||||
@ -248,17 +197,17 @@ Channel.signal=1C
|
||||
|
||||
;######### CHANNEL 0 CONFIG ############
|
||||
|
||||
Channel0.system=GPS
|
||||
Channel0.signal=1C
|
||||
;Channel0.system=GPS
|
||||
;Channel0.signal=1C
|
||||
|
||||
;#satellite: Satellite PRN ID for this channel. Disable this option to random search
|
||||
Channel0.satellite=11
|
||||
;Channel0.satellite=11
|
||||
|
||||
;######### CHANNEL 1 CONFIG ############
|
||||
|
||||
Channel1.system=GPS
|
||||
Channel1.signal=1C
|
||||
Channel1.satellite=18
|
||||
;Channel1.system=GPS
|
||||
;Channel1.signal=1C
|
||||
;Channel1.satellite=18
|
||||
|
||||
|
||||
;######### ACQUISITION GLOBAL CONFIG ############
|
||||
@ -313,7 +262,8 @@ Acquisition.max_dwells=1
|
||||
;######### TRACKING GLOBAL CONFIG ############
|
||||
|
||||
;#implementation: Selected tracking algorithm: [GPS_L1_CA_DLL_PLL_Tracking] or [GPS_L1_CA_DLL_FLL_PLL_Tracking]
|
||||
Tracking.implementation=GPS_L1_CA_DLL_PLL_Optim_Tracking
|
||||
;Tracking.implementation=GPS_L1_CA_DLL_PLL_Optim_Tracking
|
||||
Tracking.implementation=GPS_L1_CA_DLL_PLL_Tracking
|
||||
;#item_type: Type and resolution for each of the signal samples. Use only [gr_complex] in this version.
|
||||
Tracking.item_type=gr_complex
|
||||
|
||||
@ -330,7 +280,7 @@ Tracking.dump_filename=./tracking_ch_
|
||||
Tracking.pll_bw_hz=50.0;
|
||||
|
||||
;#dll_bw_hz: DLL loop filter bandwidth [Hz]
|
||||
Tracking.dll_bw_hz=2.0;
|
||||
Tracking.dll_bw_hz=4.0;
|
||||
|
||||
;#fll_bw_hz: FLL loop filter bandwidth [Hz]
|
||||
Tracking.fll_bw_hz=10.0;
|
||||
|
@ -27,6 +27,7 @@ install(FILES
|
||||
gn3s_defines.h
|
||||
gn3s.h
|
||||
fusb.h
|
||||
fx2.h
|
||||
libusb_types.h
|
||||
fusb_linux.h
|
||||
DESTINATION include/gn3s
|
||||
|
@ -23,9 +23,8 @@
|
||||
#ifndef _FUSB_H_
|
||||
#define _FUSB_H_
|
||||
|
||||
#include "libusb_types.h"
|
||||
|
||||
struct libusb_context;
|
||||
struct usb_dev_handle;
|
||||
class fusb_ephandle;
|
||||
|
||||
/*!
|
||||
@ -34,15 +33,15 @@ class fusb_ephandle;
|
||||
class fusb_devhandle {
|
||||
private:
|
||||
// NOT IMPLEMENTED
|
||||
fusb_devhandle (const fusb_devhandle &rhs); // no copy constructor
|
||||
fusb_devhandle (const fusb_devhandle &rhs); // no copy constructor
|
||||
fusb_devhandle &operator= (const fusb_devhandle &rhs); // no assignment operator
|
||||
|
||||
protected:
|
||||
libusb_device_handle *d_udh;
|
||||
usb_dev_handle *d_udh;
|
||||
|
||||
public:
|
||||
// CREATORS
|
||||
fusb_devhandle (libusb_device_handle *udh);
|
||||
fusb_devhandle (usb_dev_handle *udh);
|
||||
virtual ~fusb_devhandle ();
|
||||
|
||||
// MANIPULATORS
|
||||
@ -51,10 +50,10 @@ public:
|
||||
* \brief return an ephandle of the correct subtype
|
||||
*/
|
||||
virtual fusb_ephandle *make_ephandle (int endpoint, bool input_p,
|
||||
int block_size = 0, int nblocks = 0) = 0;
|
||||
int block_size = 0, int nblocks = 0) = 0;
|
||||
|
||||
// ACCESSORS
|
||||
libusb_device_handle *get_usb_dev_handle () const { return d_udh; }
|
||||
usb_dev_handle *get_usb_dev_handle () const { return d_udh; }
|
||||
};
|
||||
|
||||
|
||||
@ -64,23 +63,23 @@ public:
|
||||
class fusb_ephandle {
|
||||
private:
|
||||
// NOT IMPLEMENTED
|
||||
fusb_ephandle (const fusb_ephandle &rhs); // no copy constructor
|
||||
fusb_ephandle (const fusb_ephandle &rhs); // no copy constructor
|
||||
fusb_ephandle &operator= (const fusb_ephandle &rhs); // no assignment operator
|
||||
|
||||
protected:
|
||||
int d_endpoint;
|
||||
bool d_input_p;
|
||||
int d_block_size;
|
||||
int d_nblocks;
|
||||
bool d_started;
|
||||
int d_endpoint;
|
||||
bool d_input_p;
|
||||
int d_block_size;
|
||||
int d_nblocks;
|
||||
bool d_started;
|
||||
|
||||
public:
|
||||
fusb_ephandle (int endpoint, bool input_p,
|
||||
int block_size = 0, int nblocks = 0);
|
||||
int block_size = 0, int nblocks = 0);
|
||||
virtual ~fusb_ephandle ();
|
||||
|
||||
virtual bool start () = 0; //!< begin streaming i/o
|
||||
virtual bool stop () = 0; //!< stop streaming i/o
|
||||
virtual bool start () = 0; //!< begin streaming i/o
|
||||
virtual bool stop () = 0; //!< stop streaming i/o
|
||||
|
||||
/*!
|
||||
* \returns \p nbytes if write was successfully enqueued, else -1.
|
||||
@ -115,8 +114,7 @@ public:
|
||||
/*!
|
||||
* \brief returns fusb_devhandle or throws if trouble
|
||||
*/
|
||||
static fusb_devhandle *make_devhandle (libusb_device_handle *udh,
|
||||
libusb_context *ctx = 0);
|
||||
static fusb_devhandle *make_devhandle (usb_dev_handle *udh);
|
||||
|
||||
/*!
|
||||
* \brief Returns max block size in bytes (hard limit).
|
||||
|
@ -30,113 +30,30 @@
|
||||
#define GN3S_H_
|
||||
|
||||
|
||||
/* Includes */
|
||||
/*--------------------------------------------------------------*/
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "fusb.h"
|
||||
#include "fusb_linux.h"
|
||||
//#include "usrp_bytesex.h"
|
||||
//#include "usrp_prims.h"
|
||||
/*--------------------------------------------------------------*/
|
||||
#define MODE_NARROW_16_I 32 /* SF:16.368MHz, IF:4.092MHz, 2bit, I */
|
||||
#define MODE_NARROW_8_IQ 36 /* SF: 8.184MHz, IF: 0MHz, 4bit, IQ */
|
||||
#define MODE_NARROW_5_I 38 /* SF: 5.456MHz, IF:4.092MHz, 2bit, I */
|
||||
#define MODE_NARROW_4_IQ 42 /* SF: 4.092MHz, IF: 0MHz, 4bit, IQ */
|
||||
#define MODE_WIDE_16_I 132 /* SF:16.368MHz, IF:4.092MHz, 2bit, I */
|
||||
#define MODE_WIDE_8_IQ 136 /* SF: 8.184MHz, IF: 0MHz, 4bit, IQ */
|
||||
#define MODE_WIDE_5_I 138 /* SF: 5.456MHz, IF:4.092MHz, 2bit, I */
|
||||
#define MODE_WIDE_4_IQ 142 /* SF: 4.092MHz, IF: 0MHz, 4bit, IQ */
|
||||
|
||||
#define GN3S_MODE MODE_NARROW_16_I /* GN3S operating mode */
|
||||
#define GN3S_DECIMATE 1 /* decimate mode */
|
||||
#define GN3S_PACK 1 /* pack mode */
|
||||
#define GN3S_BUFFSIZE 32*512 /* buffer size: 16 kB */
|
||||
|
||||
/* global functions */
|
||||
extern int gn3s_init(void);
|
||||
extern void gn3s_quit(void);
|
||||
extern void gn3s_exp_v2(unsigned char *buf, int n, char *expbuf);
|
||||
extern void gn3s_getbuff_v2(uint64_t buffloc, int n, int dtype, char *expbuf);
|
||||
extern void gn3s_exp_v3(unsigned char *buf, int n, int i_mode, char *expbuf);
|
||||
extern void gn3s_getbuff_v3(uint64_t buffloc, int n, int dtype, char *expbuf);
|
||||
extern int gn3s_pushtomembuf(void);
|
||||
extern void fgn3s_pushtomembuf(void);
|
||||
extern void fgn3s_getbuff(uint64_t buffloc, int n, int dtype, char *expbuf);
|
||||
|
||||
|
||||
/* FX2 Configuration Structure */
|
||||
/*--------------------------------------------------------------*/
|
||||
struct fx2Config
|
||||
{
|
||||
int interface;
|
||||
int altinterface;
|
||||
usb_dev_handle *udev;
|
||||
fusb_ephandle *d_ephandle;
|
||||
fusb_devhandle *d_devhandle;
|
||||
};
|
||||
/*--------------------------------------------------------------*/
|
||||
|
||||
|
||||
/* FX2 Stuff */
|
||||
/*--------------------------------------------------------------*/
|
||||
#define RX_ENDPOINT (0x86)
|
||||
#define VRT_VENDOR_IN (0xC0)
|
||||
#define VRT_VENDOR_OUT (0x40)
|
||||
#define RX_INTERFACE (2)
|
||||
#define RX_ALTINTERFACE (0)
|
||||
#define VRQ_GET_STATUS (0x80)
|
||||
#define GS_RX_OVERRUN (1) //!< Returns 1 byte
|
||||
#define VRQ_XFER (0x01)
|
||||
/*--------------------------------------------------------------*/
|
||||
|
||||
|
||||
/* GN3S Stuff */
|
||||
/*--------------------------------------------------------------*/
|
||||
#define GN3S_VID (0x16C0)
|
||||
#define GN3S_PID (0x072F)
|
||||
#define VID_OLD (0x1781)
|
||||
#define PID_OLD (0x0B39)
|
||||
#define PROG_SET_CMD (0xE600)
|
||||
#define FUSB_BUFFER_SIZE (16 * (1L << 20)) //!< 8 MB
|
||||
#define FUSB_BLOCK_SIZE (16 * (1L << 10)) //!< 16KB is hard limit
|
||||
#define FUSB_NBLOCKS (FUSB_BUFFER_SIZE / FUSB_BLOCK_SIZE)
|
||||
/*--------------------------------------------------------------*/
|
||||
|
||||
|
||||
/* The firmware is embedded into the executable */
|
||||
/*--------------------------------------------------------------*/
|
||||
extern char _binary_usrp_gn3s_firmware_ihx_start[];
|
||||
/*--------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/*! \ingroup CLASSES
|
||||
*
|
||||
*/
|
||||
class gn3s
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
/* First or second board */
|
||||
int which;
|
||||
|
||||
/* GN3S FX2 Stuff */
|
||||
struct fx2Config fx2_config;
|
||||
struct usb_device *fx2_device;
|
||||
struct usb_dev_handle *fx2_handle;
|
||||
|
||||
/* USB IDs */
|
||||
unsigned int gn3s_vid, gn3s_pid;
|
||||
|
||||
/* Pull in the binary firmware */
|
||||
int fstart;
|
||||
int fsize;
|
||||
//char *gn3s_firmware;
|
||||
|
||||
public:
|
||||
|
||||
gn3s(int _which); //!< Constructor
|
||||
~gn3s(); //!< Destructor
|
||||
|
||||
/* FX2 functions */
|
||||
struct usb_device* usb_fx2_find(int vid, int pid, char info, int ignore);
|
||||
bool usb_fx2_configure(struct usb_device *fx2, fx2Config *fx2c);
|
||||
fusb_devhandle* make_devhandle (usb_dev_handle *udh);
|
||||
int read(void *buff, int bytes);
|
||||
int write_cmd(int request, int value, int index, unsigned char *bytes, int len);
|
||||
bool _get_status(int which, bool *trouble);
|
||||
bool check_rx_overrun();
|
||||
bool usrp_xfer(char VRQ_TYPE, bool start);
|
||||
|
||||
/* Used to flash the GN3S */
|
||||
int atoz(char *s);
|
||||
void upload_ram(char *buf, int start, int len);
|
||||
void program_fx2(char *filename, char mem);
|
||||
int prog_gn3s_board();
|
||||
|
||||
};
|
||||
/*--------------------------------------------------------------*/
|
||||
|
||||
|
||||
#endif /*GN3S_H_ */
|
||||
#endif
|
||||
|
@ -22,7 +22,7 @@
|
||||
########################################################################
|
||||
include(GrPlatform) #define LIB_SUFFIX
|
||||
|
||||
add_library(gr-gn3s SHARED gn3s_source_cc.cc gn3s_source.cc gn3s.cc fusb.cc fusb_linux.cc)
|
||||
add_library(gr-gn3s SHARED gn3s_source_cc.cc gn3s_source.cc gn3s.cc fusb.cc fx2.cc fusb_linux.cc)
|
||||
target_link_libraries(gr-gn3s ${Boost_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES} "usb" ${LIBUSB_LIBRARIES})
|
||||
set_target_properties(gr-gn3s PROPERTIES DEFINE_SYMBOL "gr_gn3s_EXPORTS")
|
||||
|
||||
|
@ -25,525 +25,276 @@
|
||||
*/
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
|
||||
#include "gn3s.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <stdlib.h>
|
||||
#include <usb.h>
|
||||
#include "fusb_linux.h"
|
||||
#include "sdr.h"
|
||||
#include "fx2.h"
|
||||
|
||||
static char debug = 1; //!< 1 = Verbose
|
||||
/* global variables ----------------------------------------------------------*/
|
||||
using namespace std;
|
||||
Fx2_dev fx2_d;
|
||||
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
gn3s::gn3s(int _which)
|
||||
/* GN3S initialization ---------------------------------------------------------
|
||||
* search front end and initialization
|
||||
* args : none
|
||||
* return : int status 0:okay -1:failure
|
||||
*-----------------------------------------------------------------------------*/
|
||||
extern int gn3s_init(void)
|
||||
{
|
||||
char version; /* version of modules */
|
||||
unsigned char uc_flags[5];
|
||||
|
||||
//int fsize;
|
||||
bool ret;
|
||||
which = _which;
|
||||
|
||||
fx2_device = NULL;
|
||||
fx2_handle = NULL;
|
||||
gn3s_vid = GN3S_VID;
|
||||
gn3s_pid = GN3S_PID;
|
||||
|
||||
/* Get the firmware embedded in the executable */
|
||||
//fstart = (int) &_binary_usrp_gn3s_firmware_ihx_start;
|
||||
//fsize = strlen(_binary_usrp_gn3s_firmware_ihx_start);
|
||||
//gn3s_firmware = new char[fsize + 10];
|
||||
//memcpy(&gn3s_firmware[0], (void *)fstart, fsize);
|
||||
|
||||
// Load the firmware from external file (Javier)
|
||||
|
||||
|
||||
//gn3s_firmware[fsize] = NULL;
|
||||
|
||||
/* Search all USB busses for the device specified by VID/PID */
|
||||
fx2_device = usb_fx2_find(gn3s_vid, gn3s_pid, debug, 0);
|
||||
if (!fx2_device)
|
||||
{
|
||||
/* Program the board */
|
||||
ret = prog_gn3s_board();
|
||||
if(ret)
|
||||
{
|
||||
fprintf(stdout, "Could not flash GN3S device\n");
|
||||
throw(1);
|
||||
}
|
||||
|
||||
/* Need to wait to catch change */
|
||||
sleep(2);
|
||||
|
||||
/* Search all USB busses for the device specified by VID/PID */
|
||||
fx2_device = usb_fx2_find(gn3s_vid, gn3s_pid, debug, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stdout, "Found GN3S Device\n");
|
||||
}
|
||||
|
||||
/* Open and configure FX2 device if found... */
|
||||
ret = usb_fx2_configure(fx2_device, &fx2_config);
|
||||
if(ret)
|
||||
{
|
||||
fprintf(stdout, "Could not obtain a handle to the GN3S device\n");
|
||||
throw(1);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
gn3s::~gn3s()
|
||||
{
|
||||
|
||||
usrp_xfer(VRQ_XFER, 0);
|
||||
|
||||
//delete gn3s_firmware;
|
||||
delete fx2_config.d_ephandle;
|
||||
delete fx2_config.d_devhandle;
|
||||
|
||||
usb_release_interface(fx2_config.udev, fx2_config.interface);
|
||||
usb_close(fx2_config.udev);
|
||||
|
||||
}
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
int gn3s::prog_gn3s_board()
|
||||
{
|
||||
|
||||
char a;
|
||||
struct usb_bus *bus;
|
||||
struct usb_device *dev;
|
||||
//struct usb_dev_handle *han;
|
||||
int vid, pid;
|
||||
|
||||
dev = NULL;
|
||||
|
||||
usb_init();
|
||||
usb_find_busses();
|
||||
usb_find_devices();
|
||||
|
||||
vid = (VID_OLD);
|
||||
pid = (PID_OLD);
|
||||
|
||||
for(bus = usb_busses; bus; bus = bus->next)
|
||||
{
|
||||
for(dev = bus->devices; dev; dev = dev->next)
|
||||
{
|
||||
if((dev->descriptor.idVendor == vid) && (dev->descriptor.idProduct == pid))
|
||||
{
|
||||
fx2_device = dev;
|
||||
fprintf(stdout,"GN3S Device Found... awaiting firmware flash \n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(fx2_device == NULL)
|
||||
{
|
||||
fprintf(stderr,"Cannot find vid 0x%x pid 0x%x \n", vid, pid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("Using device vendor id 0x%04x product id 0x%04x\n",
|
||||
fx2_device->descriptor.idVendor, fx2_device->descriptor.idProduct);
|
||||
|
||||
fx2_handle = usb_open(fx2_device);
|
||||
|
||||
/* Do the first set 0xE600 1 */
|
||||
char c[] = "1";
|
||||
char d[] = "0";
|
||||
|
||||
a = atoz(c);
|
||||
|
||||
fprintf(stdout,"GN3S flashing ... \n");
|
||||
|
||||
upload_ram(&a, (PROG_SET_CMD),1);
|
||||
|
||||
program_fx2(NULL, 1);
|
||||
|
||||
a = atoz(d);
|
||||
|
||||
upload_ram(&a, (PROG_SET_CMD),1);
|
||||
|
||||
fprintf(stdout,"GN3S flash complete! \n");
|
||||
|
||||
usb_close(fx2_handle);
|
||||
|
||||
return(0);
|
||||
}
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
int gn3s::atoz(char *s)
|
||||
{
|
||||
int a;
|
||||
if(!strncasecmp("0x", s, 2)){
|
||||
sscanf(s, "%x", &a);
|
||||
return a;
|
||||
/* Look for a device */
|
||||
fx2_d = Fx2_dev(1); /* PID 0x0b39 */
|
||||
if (fx2_d.usb_fx2_find() != 0) {
|
||||
version = 2;
|
||||
if (sdrini.fend!=FEND_GN3SV2) {
|
||||
SDRPRINTF("error: wrong frontend type, GN3SV2 is found\n");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
fx2_d = Fx2_dev(2); /* PID 0x0b3a */
|
||||
if (fx2_d.usb_fx2_find() != 0) {
|
||||
version = 3;
|
||||
if (sdrini.fend!=FEND_GN3SV3) {
|
||||
SDRPRINTF("error: wrong frontend type, GN3SV3 is found\n");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
fx2_d = Fx2_dev(3); /* PID 0x0b3f */
|
||||
if(fx2_d.usb_fx2_find()!=0) {
|
||||
version = 3;
|
||||
if (sdrini.fend!=FEND_GN3SV3) {
|
||||
SDRPRINTF("error: wrong frontend type, GN3SV3 is found\n");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
SDRPRINTF("error: no GN3S frontend found\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return atoi(s);
|
||||
fx2_d.usb_fx2_init();
|
||||
/* version 2 */
|
||||
if (version==2) {
|
||||
fx2_d.usrp_xfer(VRQ_XFER, 1);
|
||||
}
|
||||
/* version 3 */
|
||||
if (version==3) {
|
||||
fx2_d.usrp_xfer (VRQ_AGC,0); /* AGC OFF */
|
||||
fx2_d.usrp_xfer (VRQ_CMODE,132 );
|
||||
fx2_d.usrp_xfer (VRQ_XFER, 0 );
|
||||
fx2_d.usrp_xfer (VRQ_XFER, 1);
|
||||
fx2_d.usrp_xfer2(VRQ_FLAGS, 0, uc_flags, 5);
|
||||
fx2_d.usrp_xfer (VRQ_XFER, 0 );
|
||||
fx2_d.usrp_xfer(VRQ_CMODE,GN3S_MODE);
|
||||
fx2_d.usrp_xfer(VRQ_XFER, 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
void gn3s::upload_ram(char *buf, int start, int len)
|
||||
/* stop front-end --------------------------------------------------------------
|
||||
* stop grabber of front end
|
||||
* args : none
|
||||
* return : none
|
||||
*-----------------------------------------------------------------------------*/
|
||||
extern void gn3s_quit(void)
|
||||
{
|
||||
int i;
|
||||
int tlen;
|
||||
int quanta = 16;
|
||||
int a;
|
||||
|
||||
for (i = start; i < start + len; i += quanta) {
|
||||
tlen = len + start - i;
|
||||
|
||||
if (tlen > quanta)
|
||||
tlen = quanta;
|
||||
|
||||
if (debug >= 3)
|
||||
printf("i = %d, tlen = %d \n", i, tlen);
|
||||
a = usb_control_msg(fx2_handle, 0x40, 0xa0, i, 0,
|
||||
buf + (i - start), tlen, 1000);
|
||||
|
||||
if (a < 0) {
|
||||
fprintf(stderr, "Request to upload ram contents failed: %s\n",
|
||||
usb_strerror());
|
||||
return;
|
||||
}
|
||||
}
|
||||
fx2_d.close();
|
||||
fx2_d.~Fx2_dev();
|
||||
}
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
void gn3s::program_fx2(char *filename, char mem)
|
||||
/* data expansion to binary (GN3S v2) ------------------------------------------
|
||||
* get current data buffer from memory buffer
|
||||
* args : char *buf I memory buffer
|
||||
* int n I number of grab data
|
||||
* char *expbuff O extracted data buffer
|
||||
* return : none
|
||||
*-----------------------------------------------------------------------------*/
|
||||
extern void gn3s_exp_v2(unsigned char *buf, int n, char *expbuf)
|
||||
{
|
||||
FILE *f;
|
||||
char s[1024];
|
||||
char data[256];
|
||||
char checksum, a;
|
||||
int length, addr, type, i;
|
||||
unsigned int b;
|
||||
int i;
|
||||
char LUT_1bit[2]={1,-1};
|
||||
char shift=0, endshift=0;
|
||||
|
||||
// *** mod javier: load firmware from external file ***
|
||||
/* data shift (refer gn3s-full.cc) */
|
||||
/* http://ccar.colorado.edu/gnss/files/GN3Sv2.7z */
|
||||
if ((buf[ 0]&0x02)!=2) shift=1;
|
||||
if ((buf[n-1]&0x02)!=0) endshift=1;
|
||||
|
||||
//f = tmpfile();
|
||||
|
||||
/* Dump firmware into temp file */
|
||||
//fputs(gn3s_firmware, f);
|
||||
//rewind(f);
|
||||
|
||||
f = fopen ("gn3s_firmware.ihx","r");
|
||||
if (f!=NULL)
|
||||
{
|
||||
printf("GN3S firmware file found!\n");
|
||||
}else{
|
||||
printf("Could not open GN3S firmware file!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
while (!feof(f)) {
|
||||
fgets(s, 1024, f); /* we should not use more than 263 bytes normally */
|
||||
|
||||
if (s[0] != ':') {
|
||||
fprintf(stderr, "%s: invalid string: \"%s\"\n", filename, s);
|
||||
continue;
|
||||
}
|
||||
|
||||
sscanf(s + 1, "%02x", &length);
|
||||
sscanf(s + 3, "%04x", &addr);
|
||||
sscanf(s + 7, "%02x", &type);
|
||||
|
||||
if (type == 0) {
|
||||
// printf("Programming %3d byte%s starting at 0x%04x",
|
||||
// length, length==1?" ":"s", addr);
|
||||
a = length + (addr & 0xff) + (addr >> 8) + type;
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
sscanf(s + 9 + i * 2, "%02x", &b);
|
||||
data[i] = b;
|
||||
a = a + data[i];
|
||||
}
|
||||
|
||||
sscanf(s + 9 + length * 2, "%02x", &b);
|
||||
checksum = b;
|
||||
|
||||
if (((a + checksum) & 0xff) != 0x00) {
|
||||
printf(" ** Checksum failed: got 0x%02x versus 0x%02x\n", (-a)
|
||||
& 0xff, checksum);
|
||||
continue;
|
||||
} else {
|
||||
//printf(", checksum ok\n");
|
||||
}
|
||||
|
||||
upload_ram(data, addr, length);
|
||||
|
||||
} else {
|
||||
if (type == 0x01) {
|
||||
printf("End of file\n");
|
||||
fclose(f);
|
||||
|
||||
return;
|
||||
} else {
|
||||
if (type == 0x02) {
|
||||
printf("Extended address: whatever I do with it ?\n");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
for (i=0;i<n;i++) {
|
||||
if (shift) {
|
||||
if ((i==(n-1))&&!endshift) expbuf[i]=0;
|
||||
else if ((i==(n-1))&&endshift) expbuf[i-1]=0;
|
||||
else expbuf[i]=LUT_1bit[buf[i+1]&0x01];
|
||||
} else {
|
||||
if ((i==(n-1))&&endshift) expbuf[i]=0;
|
||||
else expbuf[i]=LUT_1bit[buf[i]&0x01];
|
||||
}
|
||||
}
|
||||
}
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
struct usb_device* gn3s::usb_fx2_find(int vid, int pid, char info, int ignore)
|
||||
/* get current data buffer (GN3S v2) -------------------------------------------
|
||||
* get current data buffer from memory buffer
|
||||
* args : uint64_t buffloc I buffer location
|
||||
* int n I number of grab data
|
||||
* int dtype I data type (DTYPEI or DTYPEIQ)
|
||||
* char *expbuff O extracted data buffer
|
||||
* return : none
|
||||
*-----------------------------------------------------------------------------*/
|
||||
extern void gn3s_getbuff_v2(uint64_t buffloc, int n, int dtype, char *expbuf)
|
||||
{
|
||||
struct usb_bus *bus;
|
||||
struct usb_device *dev;
|
||||
struct usb_device *fx2 = NULL;
|
||||
usb_dev_handle *udev;
|
||||
int count = 0;
|
||||
int ret;
|
||||
char str[256];
|
||||
uint64_t membuffloc=2*buffloc%(MEMBUFFLEN*GN3S_BUFFSIZE);
|
||||
int nout;
|
||||
n=2*n;
|
||||
nout=(int)((membuffloc+n)-(MEMBUFFLEN*GN3S_BUFFSIZE));
|
||||
|
||||
usb_init();
|
||||
usb_find_busses();
|
||||
usb_find_devices();
|
||||
|
||||
for(bus = usb_busses; bus; bus = bus->next)
|
||||
{
|
||||
for(dev = bus->devices; dev; dev = dev->next)
|
||||
{
|
||||
if((dev->descriptor.idVendor == vid) && (dev->descriptor.idProduct == pid))
|
||||
{
|
||||
fx2 = dev;
|
||||
}
|
||||
|
||||
if(fx2 != NULL && info)
|
||||
{
|
||||
udev = usb_open(fx2);
|
||||
if(udev && dev->descriptor.idVendor == vid && dev->descriptor.idProduct == pid && count < ignore)
|
||||
{
|
||||
if(fx2->descriptor.iManufacturer)
|
||||
{
|
||||
ret = usb_get_string_simple(udev, fx2->descriptor.iManufacturer, str, sizeof(str));
|
||||
|
||||
if(ret > 0)
|
||||
printf("- Manufacturer : %s\n", str);
|
||||
else
|
||||
printf("- Unable to fetch manufacturer string\n");
|
||||
}
|
||||
|
||||
if(fx2->descriptor.iProduct)
|
||||
{
|
||||
ret = usb_get_string_simple(udev, fx2->descriptor.iProduct, str, sizeof(str));
|
||||
|
||||
if(ret > 0)
|
||||
printf("- Product : %s\n", str);
|
||||
else
|
||||
printf("- Unable to fetch product string\n");
|
||||
}
|
||||
|
||||
if(fx2->descriptor.iSerialNumber)
|
||||
{
|
||||
ret = usb_get_string_simple(udev, fx2->descriptor.iSerialNumber, str, sizeof(str));
|
||||
|
||||
if(ret > 0)
|
||||
printf("- Serial Number: %s\n", str);
|
||||
else
|
||||
printf("- Unable to fetch serial number string\n");
|
||||
}
|
||||
|
||||
usb_close (udev);
|
||||
return fx2;
|
||||
}
|
||||
else if(udev && dev->descriptor.idVendor == vid && dev->descriptor.idProduct == pid && count >= ignore)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
|
||||
if(!fx2->config)
|
||||
{
|
||||
printf(" Could not retrieve descriptors\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
for(int i = 0; i < fx2->descriptor.bNumConfigurations; i++)
|
||||
{
|
||||
//print_configuration(&fx2->config[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fx2;
|
||||
mlock(hbuffmtx);
|
||||
if (nout>0) {
|
||||
gn3s_exp_v2(&sdrstat.buff[membuffloc],n-nout,expbuf);
|
||||
gn3s_exp_v2(&sdrstat.buff[0],nout,&expbuf[n-nout]);
|
||||
} else {
|
||||
gn3s_exp_v2(&sdrstat.buff[membuffloc],n,expbuf);
|
||||
}
|
||||
unmlock(hbuffmtx);
|
||||
}
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
bool gn3s::usb_fx2_configure(struct usb_device *fx2, fx2Config *fx2c)
|
||||
/* data expansion to binary (GN3S v3) ------------------------------------------
|
||||
* get current data buffer from memory buffer
|
||||
* args : char *buf I memory buffer
|
||||
* int n I number of grab data
|
||||
* int i_mode I GN3S data grabber mode
|
||||
* char *expbuff O extracted data buffer
|
||||
* return : none
|
||||
*-----------------------------------------------------------------------------*/
|
||||
extern void gn3s_exp_v3(unsigned char *buf, int n, int i_mode, char *expbuf)
|
||||
{
|
||||
int i=0;
|
||||
int i_idx=0;
|
||||
int i_dtype=0;
|
||||
char LUT_2bit[4]={1,-1,3,-3};
|
||||
char LUT_I_4bit[16]={1,-1,0,0,3,-3,0,0,0,0,0,0,0,0,0,0};
|
||||
char LUT_Q_4bit[16]={1,0,-1,0,0,0,0,0,3,0,-3,0,0,0,0,0};
|
||||
char MASK_2bit=0x03;
|
||||
char MASK_4bit_I=0x05;
|
||||
char MASK_4bit_Q=0x0A;
|
||||
|
||||
char status = 0;
|
||||
int interface = RX_INTERFACE;
|
||||
int altinterface = RX_ALTINTERFACE;
|
||||
usb_dev_handle *udev;
|
||||
fusb_ephandle *d_ephandle;
|
||||
fusb_devhandle *d_devhandle;
|
||||
/* determine mode */
|
||||
if (((i_mode% 100)==32)|| ((i_mode% 100)==38)) {
|
||||
i_dtype =2;
|
||||
}
|
||||
if (((i_mode% 100)==36)|| ((i_mode% 100)==42)) {
|
||||
i_dtype =4;
|
||||
}
|
||||
|
||||
udev = usb_open(fx2);
|
||||
|
||||
if(!udev)
|
||||
{
|
||||
fprintf(stdout, "Could not obtain a handle to GNSS Front-End device \n");
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(debug)
|
||||
printf("Received handle for GNSS Front-End device \n");
|
||||
|
||||
if(usb_set_configuration (udev, 1) < 0)
|
||||
{
|
||||
fprintf (stdout,
|
||||
"error in %s, \n%s \n",
|
||||
__FUNCTION__,
|
||||
usb_strerror());
|
||||
usb_close (udev);
|
||||
status = -1;
|
||||
}
|
||||
|
||||
if(usb_claim_interface (udev, interface) < 0)
|
||||
{
|
||||
fprintf (stdout,
|
||||
"error in %s, \n%s \n",
|
||||
__FUNCTION__,
|
||||
usb_strerror());
|
||||
usb_close (udev);
|
||||
fprintf (stdout, "\nDevice not programmed? \n");
|
||||
usb_close (udev);
|
||||
status = -1;
|
||||
throw(0);
|
||||
}
|
||||
|
||||
if(usb_set_altinterface (udev, altinterface) < 0)
|
||||
{
|
||||
fprintf (stdout,
|
||||
"error in %s, \n%s \n",
|
||||
__FUNCTION__,
|
||||
usb_strerror());
|
||||
usb_close (udev);
|
||||
usb_release_interface (udev, interface);
|
||||
usb_close (udev);
|
||||
status = -1;
|
||||
}
|
||||
|
||||
d_devhandle = make_devhandle(udev);
|
||||
d_ephandle = d_devhandle->make_ephandle(RX_ENDPOINT, true, FUSB_BLOCK_SIZE, FUSB_NBLOCKS);
|
||||
|
||||
if(!d_ephandle->start())
|
||||
{
|
||||
fprintf (stdout, "usrp0_rx: failed to start end point streaming");
|
||||
usb_strerror ();
|
||||
status = -1;
|
||||
}
|
||||
|
||||
if(status == 0)
|
||||
{
|
||||
fx2c->interface = interface;
|
||||
fx2c->altinterface = altinterface;
|
||||
fx2c->udev = udev;
|
||||
fx2c->d_devhandle = d_devhandle;
|
||||
fx2c->d_ephandle = d_ephandle;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
for (i=0;i<n;i++) {
|
||||
switch (i_dtype) {
|
||||
case 2:
|
||||
expbuf[i_idx]=LUT_2bit[buf[i] & MASK_2bit];
|
||||
i_idx++;
|
||||
break;
|
||||
case 4:
|
||||
expbuf[i_idx]=LUT_I_4bit[buf[i] & MASK_4bit_I];
|
||||
i_idx++;
|
||||
expbuf[i_idx]=LUT_Q_4bit[buf[i] & MASK_4bit_Q];
|
||||
i_idx++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
fusb_devhandle* gn3s::make_devhandle(usb_dev_handle *udh)
|
||||
/* get current data buffer (GN3S v3) -------------------------------------------
|
||||
* get current data buffer from memory buffer
|
||||
* args : uint64_t buffloc I buffer location
|
||||
* int n I number of grab data
|
||||
* int dtype I data type (DTYPEI or DTYPEIQ)
|
||||
* char *expbuff O extracted data buffer
|
||||
* return : none
|
||||
*-----------------------------------------------------------------------------*/
|
||||
extern void gn3s_getbuff_v3(uint64_t buffloc, int n, int dtype, char *expbuf)
|
||||
{
|
||||
return new fusb_devhandle_linux(udh);
|
||||
uint64_t membuffloc=buffloc%(MEMBUFFLEN*GN3S_BUFFSIZE);
|
||||
int nout=(int)((membuffloc+n)-(MEMBUFFLEN*GN3S_BUFFSIZE));
|
||||
|
||||
mlock(hbuffmtx);
|
||||
if (nout>0) {
|
||||
gn3s_exp_v3(&sdrstat.buff[membuffloc],n-nout,GN3S_MODE,expbuf);
|
||||
gn3s_exp_v3(&sdrstat.buff[0],nout,GN3S_MODE,&expbuf[dtype*(n-nout)]);
|
||||
} else {
|
||||
gn3s_exp_v3(&sdrstat.buff[membuffloc],n,GN3S_MODE,expbuf);
|
||||
}
|
||||
unmlock(hbuffmtx);
|
||||
}
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
int gn3s::read(void *buff, int bytes)
|
||||
/* push data to memory buffer --------------------------------------------------
|
||||
* push data to memory buffer from GN3S front end
|
||||
* args : none
|
||||
* return : none
|
||||
*-----------------------------------------------------------------------------*/
|
||||
extern int gn3s_pushtomembuf(void)
|
||||
{
|
||||
return(fx2_config.d_ephandle->read(buff, bytes));
|
||||
bool b_overrun=false;
|
||||
int nbuff;
|
||||
|
||||
/* check buffer overrun */
|
||||
fx2_d.check_rx_overrun(&b_overrun);
|
||||
if (b_overrun) return -1;
|
||||
|
||||
mlock(hbuffmtx);
|
||||
nbuff=fx2_d.read_IF(
|
||||
&sdrstat.buff[(sdrstat.buffcnt%MEMBUFFLEN)*GN3S_BUFFSIZE]);
|
||||
unmlock(hbuffmtx);
|
||||
|
||||
if (nbuff!=GN3S_BUFFSIZE) {
|
||||
SDRPRINTF("GN3S read IF error...\n");
|
||||
}
|
||||
|
||||
mlock(hreadmtx);
|
||||
sdrstat.buffcnt++;
|
||||
unmlock(hreadmtx);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
bool gn3s::check_rx_overrun()
|
||||
/* push data to memory buffer --------------------------------------------------
|
||||
* post-processing function: push data to memory buffer from GN3S binary IF file
|
||||
* args : none
|
||||
* return : none
|
||||
*-----------------------------------------------------------------------------*/
|
||||
extern void fgn3s_pushtomembuf(void)
|
||||
{
|
||||
bool overrun;
|
||||
size_t nread;
|
||||
|
||||
_get_status(GS_RX_OVERRUN, &overrun);
|
||||
mlock(hbuffmtx);
|
||||
|
||||
return(overrun);
|
||||
nread=fread(&sdrstat.buff[(sdrstat.buffcnt%MEMBUFFLEN)*GN3S_BUFFSIZE],
|
||||
1,GN3S_BUFFSIZE,sdrini.fp1);
|
||||
|
||||
unmlock(hbuffmtx);
|
||||
|
||||
if (nread<GN3S_BUFFSIZE) {
|
||||
sdrstat.stopflag=ON;
|
||||
SDRPRINTF("end of file!\n");
|
||||
}
|
||||
|
||||
mlock(hreadmtx);
|
||||
sdrstat.buffcnt++;
|
||||
unmlock(hreadmtx);
|
||||
}
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
bool gn3s::_get_status(int command, bool *trouble)
|
||||
/* get current data buffer from IF file ----------------------------------------
|
||||
* post-processing function: get current data buffer from memory buffer
|
||||
* args : uint64_t buffloc I buffer location
|
||||
* int n I number of grab data
|
||||
* int dtype I data type (DTYPEI or DTYPEIQ)
|
||||
* char *expbuff O extracted data buffer
|
||||
* return : none
|
||||
*-----------------------------------------------------------------------------*/
|
||||
extern void fgn3s_getbuff(uint64_t buffloc, int n, int dtype, char *expbuf)
|
||||
{
|
||||
unsigned char status;
|
||||
uint64_t membuffloc=dtype*buffloc%(MEMBUFFLEN*dtype*GN3S_BUFFSIZE);
|
||||
int nout;
|
||||
|
||||
if(write_cmd(VRQ_GET_STATUS, 0, command, &status, sizeof(status)) != sizeof (status))
|
||||
return false;
|
||||
n=dtype*n;
|
||||
nout=(int)((membuffloc+n)-(MEMBUFFLEN*dtype*GN3S_BUFFSIZE));
|
||||
|
||||
*trouble = status;
|
||||
return true;
|
||||
mlock(hbuffmtx);
|
||||
if (nout>0) {
|
||||
memcpy(expbuf,&sdrstat.buff[membuffloc],n-nout);
|
||||
memcpy(&expbuf[(n-nout)],&sdrstat.buff[0],nout);
|
||||
} else {
|
||||
memcpy(expbuf,&sdrstat.buff[membuffloc],n);
|
||||
}
|
||||
unmlock(hbuffmtx);
|
||||
}
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
bool gn3s::usrp_xfer(char VRQ_TYPE, bool start)
|
||||
{
|
||||
int r;
|
||||
|
||||
r = write_cmd(VRQ_TYPE, start, 0, 0, 0);
|
||||
|
||||
return(r == 0);
|
||||
}
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
int gn3s::write_cmd(int request, int value, int index, unsigned char *bytes, int len)
|
||||
{
|
||||
int requesttype;
|
||||
int r;
|
||||
|
||||
requesttype = (request & 0x80) ? VRT_VENDOR_IN : VRT_VENDOR_OUT;
|
||||
r = usb_control_msg (fx2_config.udev, requesttype, request, value, index, (char *) bytes, len, 1000);
|
||||
if(r < 0)
|
||||
{
|
||||
/* We get EPIPE if the firmware stalls the endpoint. */
|
||||
if(errno != EPIPE)
|
||||
fprintf (stdout, "usb_control_msg failed: %s\n", usb_strerror());
|
||||
}
|
||||
return r;
|
||||
}
|
||||
/*----------------------------------------------------------------------------------------------*/
|
||||
|
@ -1,29 +0,0 @@
|
||||
#define MUL_RE(a,b) (a.x*b.x - a.y*b.y)
|
||||
#define MUL_IM(a,b) (a.x*b.y + a.y*b.x)
|
||||
#define SUM_RE(a,b) (a.x + b.x)
|
||||
#define SUM_IM(a,b) (a.y + b.y)
|
||||
|
||||
__kernel void add_vectors(__global const float2* src1, __global const float2* src2, __global float2* dest)
|
||||
{
|
||||
int gid = get_global_id(0);
|
||||
dest[gid] = (float2)(SUM_RE(src1[gid],src2[gid]),SUM_IM(src1[gid],src2[gid]));
|
||||
}
|
||||
|
||||
__kernel void mult_vectors(__global const float2* src1, __global const float2* src2, __global float2* dest)
|
||||
{
|
||||
int gid = get_global_id(0);
|
||||
dest[gid] = (float2)(MUL_RE(src1[gid],src2[gid]),MUL_IM(src1[gid],src2[gid]));
|
||||
}
|
||||
|
||||
__kernel void conj_vector(__global const float2* src, __global float2* dest)
|
||||
{
|
||||
int gid = get_global_id(0);
|
||||
dest[gid] = ((float2)(1,-1)) * src[gid];
|
||||
}
|
||||
|
||||
__kernel void magnitude_squared(__global const float2* src, __global float* dest)
|
||||
{
|
||||
int gid = get_global_id(0);
|
||||
dest[gid] = src[gid].x*src[gid].x + src[gid].y*src[gid].y;
|
||||
}
|
||||
|
@ -21,7 +21,8 @@ set(GNSS_SDR_OPTIONAL_HEADERS "")
|
||||
|
||||
if(ENABLE_GPERFTOOLS)
|
||||
if(GPERFTOOLS_FOUND)
|
||||
set(GNSS_SDR_OPTIONAL_LIBS "${GNSS_SDR_OPTIONAL_LIBS};${GPERFTOOLS_LIBRARIES}")
|
||||
#set(GNSS_SDR_OPTIONAL_LIBS "${GNSS_SDR_OPTIONAL_LIBS};${GPERFTOOLS_LIBRARIES}")
|
||||
set(GNSS_SDR_OPTIONAL_LIBS "${GNSS_SDR_OPTIONAL_LIBS};${GPERFTOOLS_PROFILER};${GPERFTOOLS_TCMALLOC}")
|
||||
set(GNSS_SDR_OPTIONAL_HEADERS "${GNSS_SDR_OPTIONAL_HEADERS};${GPERFTOOLS_INCLUDE_DIR}")
|
||||
endif(GPERFTOOLS_FOUND)
|
||||
endif(ENABLE_GPERFTOOLS)
|
||||
|
Loading…
Reference in New Issue
Block a user