mirror of https://github.com/pvnis/srsRAN_4G.git
Merge with master
commit
90634182ce
@ -1,40 +0,0 @@
|
|||||||
# - Try to find LIBSDRGUI
|
|
||||||
# Once done this will define
|
|
||||||
# LIBSDRGUI_FOUND - System has libsdrgui
|
|
||||||
# LIBSDRGUI_INCLUDE_DIRS - The libsdrgui include directories
|
|
||||||
# LIBSDRGUI_LIBRARIES - The libsdrgui library
|
|
||||||
|
|
||||||
find_package(PkgConfig)
|
|
||||||
pkg_check_modules(PC_LIBSDRGUI QUIET libsdrgui)
|
|
||||||
set(LIBSDRGUI_DEFINITIONS ${PC_LIBSDRGUI_CFLAGS_OTHER})
|
|
||||||
|
|
||||||
FIND_PATH(
|
|
||||||
LIBSDRGUI_INCLUDE_DIRS
|
|
||||||
NAMES libsdrgui/libsdrgui.h
|
|
||||||
HINTS ${PC_LIBSDRGUI_INCLUDEDIR}
|
|
||||||
${PC_LIBSDRGUI_INCLUDE_DIRS}
|
|
||||||
$ENV{LIBSDRGUI_DIR}/include
|
|
||||||
PATHS /usr/local/include
|
|
||||||
/usr/include
|
|
||||||
)
|
|
||||||
|
|
||||||
FIND_LIBRARY(
|
|
||||||
LIBSDRGUI_LIBRARIES
|
|
||||||
NAMES sdrgui
|
|
||||||
HINTS ${PC_LIBSDRGUI_LIBDIR}
|
|
||||||
${CMAKE_INSTALL_PREFIX}/lib
|
|
||||||
${CMAKE_INSTALL_PREFIX}/lib64
|
|
||||||
$ENV{LIBSDRGUI_DIR}/lib
|
|
||||||
PATHS /usr/local/lib
|
|
||||||
/usr/local/lib64
|
|
||||||
/usr/lib
|
|
||||||
/usr/lib64
|
|
||||||
)
|
|
||||||
|
|
||||||
message(STATUS "LIBSDRGUI LIBRARIES " ${LIBSDRGUI_LIBRARIES})
|
|
||||||
message(STATUS "LIBSDRGUI INCLUDE DIRS " ${LIBSDRGUI_INCLUDE_DIRS})
|
|
||||||
|
|
||||||
INCLUDE(FindPackageHandleStandardArgs)
|
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBSDRGUI DEFAULT_MSG LIBSDRGUI_LIBRARIES LIBSDRGUI_INCLUDE_DIRS)
|
|
||||||
MARK_AS_ADVANCED(LIBSDRGUI_LIBRARIES LIBSDRGUI_INCLUDE_DIRS)
|
|
||||||
|
|
@ -0,0 +1,42 @@
|
|||||||
|
# - Try to find SRSGUI
|
||||||
|
# Once done this will define
|
||||||
|
# SRSGUI_FOUND - System has srsgui
|
||||||
|
# SRSGUI_INCLUDE_DIRS - The srsgui include directories
|
||||||
|
# SRSGUI_LIBRARIES - The srsgui library
|
||||||
|
|
||||||
|
find_package(PkgConfig)
|
||||||
|
pkg_check_modules(PC_SRSGUI QUIET srsgui)
|
||||||
|
IF(NOT SRSGUI_FOUND)
|
||||||
|
|
||||||
|
FIND_PATH(
|
||||||
|
SRSGUI_INCLUDE_DIRS
|
||||||
|
NAMES srsgui/srsgui.h
|
||||||
|
HINTS ${PC_SRSGUI_INCLUDEDIR}
|
||||||
|
${PC_SRSGUI_INCLUDE_DIRS}
|
||||||
|
$ENV{SRSGUI_DIR}/include
|
||||||
|
PATHS /usr/local/include
|
||||||
|
/usr/include
|
||||||
|
)
|
||||||
|
|
||||||
|
FIND_LIBRARY(
|
||||||
|
SRSGUI_LIBRARIES
|
||||||
|
NAMES srsgui
|
||||||
|
HINTS ${PC_SRSGUI_LIBDIR}
|
||||||
|
${CMAKE_INSTALL_PREFIX}/lib
|
||||||
|
${CMAKE_INSTALL_PREFIX}/lib64
|
||||||
|
$ENV{SRSGUI_DIR}/lib
|
||||||
|
PATHS /usr/local/lib
|
||||||
|
/usr/local/lib64
|
||||||
|
/usr/lib
|
||||||
|
/usr/lib64
|
||||||
|
)
|
||||||
|
|
||||||
|
message(STATUS "SRSGUI LIBRARIES " ${SRSGUI_LIBRARIES})
|
||||||
|
message(STATUS "SRSGUI INCLUDE DIRS " ${SRSGUI_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SRSGUI DEFAULT_MSG SRSGUI_LIBRARIES SRSGUI_INCLUDE_DIRS)
|
||||||
|
MARK_AS_ADVANCED(SRSGUI_LIBRARIES SRSGUI_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
ENDIF(NOT SRSGUI_FOUND)
|
||||||
|
|
@ -0,0 +1,150 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* \section COPYRIGHT
|
||||||
|
*
|
||||||
|
* Copyright 2013-2014 The srsLTE Developers. See the
|
||||||
|
* COPYRIGHT file at the top-level directory of this distribution.
|
||||||
|
*
|
||||||
|
* \section LICENSE
|
||||||
|
*
|
||||||
|
* This file is part of the srsLTE library.
|
||||||
|
*
|
||||||
|
* srsLTE is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of
|
||||||
|
* the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* srsLTE is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* A copy of the GNU Lesser General Public License can be found in
|
||||||
|
* the LICENSE file in the top-level directory of this distribution
|
||||||
|
* and at http://www.gnu.org/licenses/.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "srslte/srslte.h"
|
||||||
|
#include "srslte/cuhd/cuhd.h"
|
||||||
|
#include "srslte/io/filesink.h"
|
||||||
|
|
||||||
|
static bool keep_running = true;
|
||||||
|
char *output_file_name;
|
||||||
|
char *uhd_args="";
|
||||||
|
float uhd_gain=40.0, uhd_freq=-1.0, uhd_rate=0.96;
|
||||||
|
int nof_samples = -1;
|
||||||
|
|
||||||
|
void int_handler(int dummy) {
|
||||||
|
keep_running = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void usage(char *prog) {
|
||||||
|
printf("Usage: %s [agrnv] -f rx_frequency_hz -o output_file\n", prog);
|
||||||
|
printf("\t-a UHD args [Default %s]\n", uhd_args);
|
||||||
|
printf("\t-g UHD Gain [Default %.2f dB]\n", uhd_gain);
|
||||||
|
printf("\t-r UHD Rate [Default %.6f MHz]\n", uhd_rate);
|
||||||
|
printf("\t-n nof_samples [Default %d]\n", nof_samples);
|
||||||
|
printf("\t-v srslte_verbose\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse_args(int argc, char **argv) {
|
||||||
|
int opt;
|
||||||
|
while ((opt = getopt(argc, argv, "agrnvfo")) != -1) {
|
||||||
|
switch (opt) {
|
||||||
|
case 'o':
|
||||||
|
output_file_name = argv[optind];
|
||||||
|
break;
|
||||||
|
case 'a':
|
||||||
|
uhd_args = argv[optind];
|
||||||
|
break;
|
||||||
|
case 'g':
|
||||||
|
uhd_gain = atof(argv[optind]);
|
||||||
|
break;
|
||||||
|
case 'r':
|
||||||
|
uhd_rate = atof(argv[optind]);
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
uhd_freq = atof(argv[optind]);
|
||||||
|
break;
|
||||||
|
case 'n':
|
||||||
|
nof_samples = atoi(argv[optind]);
|
||||||
|
break;
|
||||||
|
case 'v':
|
||||||
|
srslte_verbose++;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
usage(argv[0]);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (uhd_freq < 0) {
|
||||||
|
usage(argv[0]);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
cf_t *buffer;
|
||||||
|
int sample_count, n;
|
||||||
|
void *uhd;
|
||||||
|
srslte_filesink_t sink;
|
||||||
|
int32_t buflen;
|
||||||
|
|
||||||
|
signal(SIGINT, int_handler);
|
||||||
|
|
||||||
|
parse_args(argc, argv);
|
||||||
|
|
||||||
|
buflen = 4800;
|
||||||
|
sample_count = 0;
|
||||||
|
|
||||||
|
buffer = malloc(sizeof(cf_t) * buflen);
|
||||||
|
if (!buffer) {
|
||||||
|
perror("malloc");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
srslte_filesink_init(&sink, output_file_name, SRSLTE_COMPLEX_FLOAT_BIN);
|
||||||
|
|
||||||
|
printf("Opening UHD device...\n");
|
||||||
|
if (cuhd_open(uhd_args, &uhd)) {
|
||||||
|
fprintf(stderr, "Error opening uhd\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
printf("Set RX freq: %.6f MHz\n", cuhd_set_rx_freq(uhd, uhd_freq) / 1000000);
|
||||||
|
printf("Set RX gain: %.1f dB\n", cuhd_set_rx_gain(uhd, uhd_gain));
|
||||||
|
printf("Set RX rate: %.6f MHz\n", cuhd_set_rx_srate(uhd, uhd_rate*1e6) / 1000000);
|
||||||
|
cuhd_rx_wait_lo_locked(uhd);
|
||||||
|
cuhd_start_rx_stream(uhd);
|
||||||
|
|
||||||
|
|
||||||
|
while((sample_count < nof_samples || nof_samples == -1)
|
||||||
|
&& keep_running){
|
||||||
|
n = cuhd_recv(uhd, buffer, buflen, 1);
|
||||||
|
if (n < 0) {
|
||||||
|
fprintf(stderr, "Error receiving samples\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
srslte_filesink_write(&sink, buffer, buflen);
|
||||||
|
sample_count += buflen;
|
||||||
|
}
|
||||||
|
|
||||||
|
srslte_filesink_free(&sink);
|
||||||
|
free(buffer);
|
||||||
|
cuhd_close(uhd);
|
||||||
|
|
||||||
|
printf("Ok - wrote %d samples\n", sample_count);
|
||||||
|
exit(0);
|
||||||
|
}
|
@ -0,0 +1,169 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* \section COPYRIGHT
|
||||||
|
*
|
||||||
|
* Copyright 2013-2014 The srsLTE Developers. See the
|
||||||
|
* COPYRIGHT file at the top-level directory of this distribution.
|
||||||
|
*
|
||||||
|
* \section LICENSE
|
||||||
|
*
|
||||||
|
* This file is part of the srsLTE library.
|
||||||
|
*
|
||||||
|
* srsLTE is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of
|
||||||
|
* the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* srsLTE is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* A copy of the GNU Lesser General Public License can be found in
|
||||||
|
* the LICENSE file in the top-level directory of this distribution
|
||||||
|
* and at http://www.gnu.org/licenses/.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* File: ue_phy.h
|
||||||
|
*
|
||||||
|
* Description: Top-level class wrapper for PHY layer.
|
||||||
|
*
|
||||||
|
* Reference:
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include "srslte/srslte.h"
|
||||||
|
#include "srslte/utils/queue.h"
|
||||||
|
|
||||||
|
#ifndef UEPHY_H
|
||||||
|
#define UEPHY_H
|
||||||
|
|
||||||
|
#define SYNC_MODE_CV 0
|
||||||
|
#define SYNC_MODE_CALLBACK 1
|
||||||
|
#define SYNC_MODE SYNC_MODE_CV
|
||||||
|
|
||||||
|
namespace srslte {
|
||||||
|
|
||||||
|
typedef _Complex float cf_t;
|
||||||
|
|
||||||
|
class ue_phy
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef enum {DOWNLINK, UPLINK} direction_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
PDCCH_UL_SEARCH_CRNTI = 0,
|
||||||
|
PDCCH_UL_SEARCH_RA_PROC,
|
||||||
|
PDCCH_UL_SEARCH_SPS,
|
||||||
|
PDCCH_UL_SEARCH_TEMPORAL,
|
||||||
|
PDCCH_UL_SEARCH_TPC_PUSCH,
|
||||||
|
PDCCH_UL_SEARCH_TPC_PUCCH
|
||||||
|
} pdcch_ul_search_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
PDCCH_DL_SEARCH_CRNTI = 0,
|
||||||
|
PDCCH_DL_SEARCH_SIRNTI,
|
||||||
|
PDCCH_DL_SEARCH_PRNTI,
|
||||||
|
PDCCH_DL_SEARCH_RARNTI,
|
||||||
|
PDCCH_DL_SEARCH_TEMPORAL,
|
||||||
|
PDCCH_DL_SEARCH_SPS
|
||||||
|
} pdcch_dl_search_t;
|
||||||
|
|
||||||
|
/* Uplink/Downlink scheduling grant generated by a successfully decoded PDCCH */
|
||||||
|
class sched_grant {
|
||||||
|
public:
|
||||||
|
uint16_t get_rnti();
|
||||||
|
uint32_t get_rv();
|
||||||
|
void set_rv(uint32_t rv);
|
||||||
|
bool get_ndi();
|
||||||
|
bool get_cqi_request();
|
||||||
|
uint32_t get_harq_process();
|
||||||
|
private:
|
||||||
|
union {
|
||||||
|
srslte_ra_pusch_t ul_grant;
|
||||||
|
srslte_ra_pdsch_t dl_grant;
|
||||||
|
};
|
||||||
|
direction_t dir;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* Uplink scheduling assignment. The MAC instructs the PHY to prepare an UL packet (PUSCH or PUCCH)
|
||||||
|
* for transmission. The MAC must call generate_pusch() to set the packet ready for transmission
|
||||||
|
*/
|
||||||
|
class ul_buffer : public queue::element {
|
||||||
|
public:
|
||||||
|
ul_buffer(srslte_cell_t cell);
|
||||||
|
void generate_pusch(sched_grant pusch_grant, uint8_t *payload, srslte_uci_data_t uci_data);
|
||||||
|
void generate_pucch(srslte_uci_data_t uci_data);
|
||||||
|
private:
|
||||||
|
srslte_ue_ul_t ue_ul;
|
||||||
|
bool signal_generated = false;
|
||||||
|
cf_t* signal_buffer = NULL;
|
||||||
|
uint32_t tti = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Class for the processing of Downlink buffers. The MAC obtains a buffer for a given TTI and then
|
||||||
|
* gets ul/dl scheduling grants and/or processes phich/pdsch channels
|
||||||
|
*/
|
||||||
|
class dl_buffer : public queue::element {
|
||||||
|
public:
|
||||||
|
dl_buffer(srslte_cell_t cell);
|
||||||
|
sched_grant get_ul_grant(pdcch_ul_search_t mode, uint32_t rnti);
|
||||||
|
sched_grant get_dl_grant(pdcch_dl_search_t mode, uint32_t rnti);
|
||||||
|
bool decode_phich(srslte_phich_alloc_t assignment);
|
||||||
|
bool decode_pdsch(sched_grant pdsch_grant, uint8_t *payload); // returns true or false for CRC OK/KO
|
||||||
|
private:
|
||||||
|
srslte_ue_dl_t ue_dl;
|
||||||
|
srslte_phich_t phich;
|
||||||
|
cf_t *signal_buffer = NULL;
|
||||||
|
bool sf_symbols_and_ce_done = false;
|
||||||
|
bool pdcch_llr_extracted = false;
|
||||||
|
uint32_t tti = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#if SYNC_MODE==SYNC_MODE_CALLBACK
|
||||||
|
typedef (*ue_phy_tti_clock_fcn_t) (void);
|
||||||
|
ue_phy(ue_phy_tti_clock_fcn_t tti_clock_callback);
|
||||||
|
#else
|
||||||
|
ue_phy();
|
||||||
|
#endif
|
||||||
|
~ue_phy();
|
||||||
|
|
||||||
|
void measure(); // TBD
|
||||||
|
void dl_bch();
|
||||||
|
void start_rxtx();
|
||||||
|
void stop_rxtx();
|
||||||
|
void init_prach();
|
||||||
|
void send_prach(/* prach_cfg_t in prach.h with power, seq idx, etc */);
|
||||||
|
void set_param();
|
||||||
|
|
||||||
|
uint32_t get_tti();
|
||||||
|
#if SYNC_MODE==SYNC_MODE_CV
|
||||||
|
std::condition_variable tti_cv;
|
||||||
|
std::mutex tti_mutex;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ul_buffer get_ul_buffer(uint32_t tti);
|
||||||
|
dl_buffer get_dl_buffer(uint32_t tti);
|
||||||
|
|
||||||
|
private:
|
||||||
|
enum {
|
||||||
|
IDLE, MEASURE, RX_BCH, RXTX
|
||||||
|
} phy_state;
|
||||||
|
|
||||||
|
bool prach_initiated = false;
|
||||||
|
bool prach_ready_to_send = false;
|
||||||
|
srslte_prach_t prach;
|
||||||
|
|
||||||
|
queue ul_buffer_queue;
|
||||||
|
queue dl_buffer_queue;
|
||||||
|
|
||||||
|
pthread_t radio_thread;
|
||||||
|
void *radio_handler;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue