mirror of https://github.com/pvnis/srsRAN_4G.git
Merging next into op_vs_opc and resolving conflicts.
commit
f301bb6373
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,52 @@
|
||||
/**
|
||||
*
|
||||
* \section COPYRIGHT
|
||||
*
|
||||
* Copyright 2013-2015 Software Radio Systems Limited
|
||||
*
|
||||
* \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 Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* A copy of the GNU Affero 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/.
|
||||
*
|
||||
*/
|
||||
|
||||
// A bunch of helper functions to process device arguments
|
||||
|
||||
|
||||
#define REMOVE_SUBSTRING_WITHCOMAS(S, TOREMOVE) \
|
||||
remove_substring(S, TOREMOVE ",");\
|
||||
remove_substring(S, TOREMOVE ", ");\
|
||||
remove_substring(S, "," TOREMOVE);\
|
||||
remove_substring(S, ", " TOREMOVE);\
|
||||
remove_substring(S, TOREMOVE)
|
||||
|
||||
static void remove_substring(char *s,const char *toremove) {
|
||||
while((s=strstr(s,toremove))) {
|
||||
memmove(s,s+strlen(toremove),1+strlen(s+strlen(toremove)));
|
||||
}
|
||||
}
|
||||
|
||||
static void copy_subdev_string(char *dst, char *src) {
|
||||
int n = 0;
|
||||
size_t len = strlen(src);
|
||||
/* Copy until end of string or comma */
|
||||
while (n < len && src[n] != '\0' && src[n] != ',') {
|
||||
dst[n] = src[n];
|
||||
n++;
|
||||
}
|
||||
dst[n] = '\0';
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
#
|
||||
# Copyright 2013-2017 Software Radio Systems Limited
|
||||
#
|
||||
# This file is part of srsLTE
|
||||
#
|
||||
# srsLTE is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
#
|
||||
# A copy of the GNU Affero 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/.
|
||||
#
|
||||
|
||||
if(RF_FOUND)
|
||||
add_executable(benchmark_radio benchmark_radio.cc)
|
||||
target_link_libraries(benchmark_radio srslte_radio)
|
||||
endif(RF_FOUND)
|
||||
|
||||
|
@ -0,0 +1,182 @@
|
||||
/**
|
||||
*
|
||||
* \section COPYRIGHT
|
||||
*
|
||||
* Copyright 2013-2015 Software Radio Systems Limited
|
||||
*
|
||||
* \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 Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* A copy of the GNU Affero 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 <unistd.h>
|
||||
#include "srslte/srslte.h"
|
||||
#include "srslte/radio/radio_multi.h"
|
||||
|
||||
using namespace srslte;
|
||||
|
||||
std::string device_args = "auto";
|
||||
|
||||
double freq = 2630e6;
|
||||
uint32_t nof_ports = 1;
|
||||
double srate = 1.92e6; /* Hz */
|
||||
double duration = 0.01; /* in seconds, 10 ms by default */
|
||||
cf_t *buffers[SRSLTE_MAX_PORTS];
|
||||
bool tx_enable = false;
|
||||
|
||||
|
||||
void usage(char *prog) {
|
||||
printf("Usage: %s [rpstvh]\n", prog);
|
||||
printf("\t-f Carrier frequency in Hz [Default %f]\n", freq);
|
||||
printf("\t-a Arguments for first radio [Default %s]\n", device_args.c_str());
|
||||
printf("\t-p number of ports 1-%d [Default %d]\n", SRSLTE_MAX_PORTS, nof_ports);
|
||||
printf("\t-s sampling rate [Default %.0f]\n", srate);
|
||||
printf("\t-t duration in seconds [Default %.3f]\n", duration);
|
||||
printf("\t-x enable transmit [Default %s]\n", (tx_enable) ? "enabled" : "disabled");
|
||||
printf("\t-v Set srslte_verbose to info (v) or debug (vv) [Default none]\n");
|
||||
printf("\t-h show this message\n");
|
||||
}
|
||||
|
||||
void parse_args(int argc, char **argv) {
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, "foabcderpstvhmxw")) != -1) {
|
||||
switch (opt) {
|
||||
case 'f':
|
||||
freq = atof(argv[optind]);
|
||||
break;
|
||||
case 'a':
|
||||
device_args = std::string(argv[optind]);
|
||||
break;
|
||||
case 'p':
|
||||
nof_ports = (uint32_t) atoi(argv[optind]);
|
||||
break;
|
||||
case 's':
|
||||
srate = atof(argv[optind]);
|
||||
break;
|
||||
case 't':
|
||||
duration = atof(argv[optind]);
|
||||
break;
|
||||
case 'x':
|
||||
tx_enable ^= true;
|
||||
break;
|
||||
case 'v':
|
||||
srslte_verbose++;
|
||||
break;
|
||||
case 'h':
|
||||
default:
|
||||
usage(argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ret = SRSLTE_ERROR;
|
||||
srslte::radio_multi *radio_h = NULL;
|
||||
srslte_timestamp_t ts_rx = {}, ts_tx = {};
|
||||
|
||||
/* Parse args */
|
||||
parse_args(argc, argv);
|
||||
|
||||
uint32_t nof_samples = (uint32_t) (duration * srate);
|
||||
uint32_t frame_size = (uint32_t) (srate / 1000.0); /* 1 ms at srate */
|
||||
uint32_t nof_frames = (uint32_t) ceil(nof_samples / frame_size);
|
||||
|
||||
radio_h = new radio_multi();
|
||||
if (!radio_h) {
|
||||
fprintf(stderr, "Error: Calling radio_multi constructor\n");
|
||||
goto clean_exit;
|
||||
}
|
||||
|
||||
for (uint32_t p = 0; p < SRSLTE_MAX_PORTS; p++) {
|
||||
buffers[p] = NULL;
|
||||
}
|
||||
|
||||
for (uint32_t p = 0; p < nof_ports; p++) {
|
||||
buffers[p] = (cf_t *) srslte_vec_malloc(sizeof(cf_t) * frame_size);
|
||||
if (!buffers[p]) {
|
||||
fprintf(stderr, "Error: Allocating buffer (%d)\n", p);
|
||||
goto clean_exit;
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialise instances */
|
||||
printf("Initialising instances...\n");
|
||||
if (!radio_h->init((char*)device_args.c_str(), NULL, nof_ports)) {
|
||||
fprintf(stderr, "Error: Calling radio_multi constructor\n");
|
||||
goto clean_exit;
|
||||
}
|
||||
|
||||
radio_h->set_rx_freq(freq);
|
||||
|
||||
/* Set radio */
|
||||
printf("Setting radio...\n");
|
||||
if (srate < 10e6) {
|
||||
radio_h->set_master_clock_rate(4 * srate);
|
||||
} else {
|
||||
radio_h->set_master_clock_rate(srate);
|
||||
}
|
||||
|
||||
radio_h->set_rx_srate(srate);
|
||||
if (tx_enable) {
|
||||
radio_h->set_tx_srate(srate);
|
||||
}
|
||||
|
||||
/* Receive */
|
||||
printf("Initial receive for aligning radios...\n");
|
||||
radio_h->rx_now(buffers, frame_size, &ts_rx);
|
||||
|
||||
printf("Start capturing %d frames of %d samples...\n", nof_frames, frame_size);
|
||||
|
||||
for (uint32_t i = 0; i < nof_frames; i++) {
|
||||
frame_size = SRSLTE_MIN(frame_size, nof_samples);
|
||||
radio_h->rx_now(buffers, frame_size, &ts_rx);
|
||||
|
||||
if (tx_enable) {
|
||||
srslte_timestamp_copy(&ts_tx, &ts_rx);
|
||||
srslte_timestamp_add(&ts_tx, 0, 0.004);
|
||||
radio_h->tx_single(buffers[0], frame_size, ts_tx);
|
||||
}
|
||||
|
||||
nof_samples -= frame_size;
|
||||
}
|
||||
|
||||
printf("Finished streaming ...\n");
|
||||
|
||||
ret = SRSLTE_SUCCESS;
|
||||
|
||||
clean_exit:
|
||||
printf("Tearing down...\n");
|
||||
|
||||
radio_h->stop();
|
||||
|
||||
for (uint32_t p = 0; p < nof_ports; p++) {
|
||||
if (buffers[p]) {
|
||||
free(buffers[p]);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret) {
|
||||
printf("Failed!\n");
|
||||
} else {
|
||||
printf("Ok!\n");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
Loading…
Reference in New Issue