mirror of https://github.com/PentHertz/srsLTE.git
Merge branch 'master' into ul_power_control
Conflicts: mex/include/srslte/mex/mexutils.h
This commit is contained in:
commit
cc1623f1cd
|
@ -40,8 +40,6 @@
|
|||
#include "srslte/cuhd/cuhd.h"
|
||||
#include "srslte/cuhd/cuhd_utils.h"
|
||||
|
||||
#define B210_DEFAULT_GAIN_CORREC 100.0
|
||||
|
||||
cell_search_cfg_t cell_detect_config = {
|
||||
5000, // maximum number of frames to receive for MIB decoding
|
||||
50, // maximum number of frames to receive for PSS correlation
|
||||
|
@ -115,7 +113,16 @@ int parse_args(prog_args_t *args, int argc, char **argv) {
|
|||
/**********************************************************************/
|
||||
|
||||
/* TODO: Do something with the output data */
|
||||
uint8_t data[10000];
|
||||
uint8_t data[1000000];
|
||||
|
||||
bool go_exit = false;
|
||||
void sig_int_handler(int signo)
|
||||
{
|
||||
printf("SIGINT received. Exiting...\n");
|
||||
if (signo == SIGINT) {
|
||||
go_exit = true;
|
||||
}
|
||||
}
|
||||
|
||||
int cuhd_recv_wrapper(void *h, void *data, uint32_t nsamples, srslte_timestamp_t *q) {
|
||||
DEBUG(" ---- Receive %d samples ---- \n", nsamples);
|
||||
|
@ -168,31 +175,51 @@ int main(int argc, char **argv) {
|
|||
cuhd_set_rx_gain(uhd, 50);
|
||||
}
|
||||
|
||||
sigset_t sigset;
|
||||
sigemptyset(&sigset);
|
||||
sigaddset(&sigset, SIGINT);
|
||||
sigprocmask(SIG_UNBLOCK, &sigset, NULL);
|
||||
signal(SIGINT, sig_int_handler);
|
||||
|
||||
cuhd_set_master_clock_rate(uhd, 30.72e6);
|
||||
|
||||
/* set receiver frequency */
|
||||
cuhd_set_rx_freq(uhd, (double) prog_args.uhd_freq);
|
||||
cuhd_rx_wait_lo_locked(uhd);
|
||||
printf("Tunning receiver to %.3f MHz\n", (double ) prog_args.uhd_freq/1000000);
|
||||
|
||||
uint32_t ntrial=0;
|
||||
do {
|
||||
ret = cuhd_search_and_decode_mib(uhd, &cell_detect_config, prog_args.force_N_id_2, &cell);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error searching cell\n");
|
||||
return -1;
|
||||
} else if (ret == 0) {
|
||||
printf("Cell not found\n");
|
||||
fprintf(stderr, "Error searching for cell\n");
|
||||
exit(-1);
|
||||
} else if (ret == 0 && !go_exit) {
|
||||
printf("Cell not found after %d trials. Trying again (Press Ctrl+C to exit)\n", ntrial++);
|
||||
}
|
||||
} while (ret == 0 && !go_exit);
|
||||
|
||||
if (go_exit) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* set sampling frequency */
|
||||
int srate = srslte_sampling_freq_hz(cell.nof_prb);
|
||||
if (srate != -1) {
|
||||
/* Modify master clock rate for 15 Mhz */
|
||||
if (cell.nof_prb == 75) {
|
||||
cuhd_set_master_clock_rate(uhd, 23.04e6);
|
||||
if (srate < 10e6) {
|
||||
cuhd_set_master_clock_rate(uhd, 4*srate);
|
||||
} else {
|
||||
cuhd_set_master_clock_rate(uhd, srate);
|
||||
}
|
||||
printf("Setting sampling rate %.2f MHz\n", (float) srate/1000000);
|
||||
float srate_uhd = cuhd_set_rx_srate(uhd, (double) srate);
|
||||
if (srate_uhd != srate) {
|
||||
fprintf(stderr, "Could not set sampling rate\n");
|
||||
exit(-1);
|
||||
}
|
||||
cuhd_set_rx_srate(uhd, (double) srate);
|
||||
} else {
|
||||
fprintf(stderr, "Invalid number of PRB %d\n", cell.nof_prb);
|
||||
return SRSLTE_ERROR;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
INFO("Stopping UHD and flushing buffer...\n",0);
|
||||
|
@ -240,7 +267,7 @@ int main(int argc, char **argv) {
|
|||
float rx_gain_offset = 0;
|
||||
|
||||
/* Main loop */
|
||||
while (sf_cnt < prog_args.nof_subframes || prog_args.nof_subframes == -1) {
|
||||
while ((sf_cnt < prog_args.nof_subframes || prog_args.nof_subframes == -1) && !go_exit) {
|
||||
|
||||
ret = srslte_ue_sync_get_buffer(&ue_sync, &sf_buffer);
|
||||
if (ret < 0) {
|
||||
|
|
|
@ -133,6 +133,7 @@ bool go_exit = false;
|
|||
|
||||
void sig_int_handler(int signo)
|
||||
{
|
||||
printf("SIGINT received. Exiting...\n");
|
||||
if (signo == SIGINT) {
|
||||
go_exit = true;
|
||||
}
|
||||
|
@ -165,6 +166,9 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
cuhd_set_rx_gain(uhd, 50);
|
||||
}
|
||||
|
||||
cuhd_set_master_clock_rate(uhd, 30.72e6);
|
||||
|
||||
// Supress UHD messages
|
||||
cuhd_supress_stdout();
|
||||
|
||||
|
@ -174,6 +178,10 @@ int main(int argc, char **argv) {
|
|||
exit(-1);
|
||||
}
|
||||
|
||||
sigset_t sigset;
|
||||
sigemptyset(&sigset);
|
||||
sigaddset(&sigset, SIGINT);
|
||||
sigprocmask(SIG_UNBLOCK, &sigset, NULL);
|
||||
signal(SIGINT, sig_int_handler);
|
||||
|
||||
for (freq=0;freq<nof_freqs && !go_exit;freq++) {
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <sys/select.h>
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "srslte/srslte.h"
|
||||
|
||||
|
@ -98,6 +99,7 @@ srslte_netsink_t net_sink;
|
|||
int prbset_num = 1, last_prbset_num = 1;
|
||||
int prbset_orig = 0;
|
||||
|
||||
|
||||
void usage(char *prog) {
|
||||
printf("Usage: %s [agmfoncvpu]\n", prog);
|
||||
#ifndef DISABLE_UHD
|
||||
|
@ -297,6 +299,18 @@ void base_free() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
bool go_exit = false;
|
||||
void sig_int_handler(int signo)
|
||||
{
|
||||
printf("SIGINT received. Exiting...\n");
|
||||
if (signo == SIGINT) {
|
||||
go_exit = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsigned int
|
||||
reverse(register unsigned int x)
|
||||
{
|
||||
|
@ -490,6 +504,15 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
#ifndef DISABLE_UHD
|
||||
|
||||
|
||||
sigset_t sigset;
|
||||
sigemptyset(&sigset);
|
||||
sigaddset(&sigset, SIGINT);
|
||||
sigprocmask(SIG_UNBLOCK, &sigset, NULL);
|
||||
signal(SIGINT, sig_int_handler);
|
||||
cuhd_set_master_clock_rate(uhd, 30.72e6);
|
||||
|
||||
if (!output_file_name) {
|
||||
printf("Set TX rate: %.2f MHz\n",
|
||||
cuhd_set_tx_srate(uhd, srslte_sampling_freq_hz(cell.nof_prb)) / 1000000);
|
||||
|
@ -522,7 +545,7 @@ int main(int argc, char **argv) {
|
|||
bool start_of_burst = true;
|
||||
srslte_softbuffer_tx_reset(&softbuffer);
|
||||
|
||||
while (nf < nof_frames || nof_frames == -1) {
|
||||
while ((nf < nof_frames || nof_frames == -1) && !go_exit) {
|
||||
for (sf_idx = 0; sf_idx < SRSLTE_NSUBFRAMES_X_FRAME && (nf < nof_frames || nof_frames == -1); sf_idx++) {
|
||||
bzero(sf_buffer, sizeof(cf_t) * sf_n_re);
|
||||
|
||||
|
|
|
@ -227,9 +227,9 @@ void parse_args(prog_args_t *args, int argc, char **argv) {
|
|||
uint8_t data[20000];
|
||||
|
||||
bool go_exit = false;
|
||||
|
||||
void sig_int_handler(int signo)
|
||||
{
|
||||
printf("SIGINT received. Exiting...\n");
|
||||
if (signo == SIGINT) {
|
||||
go_exit = true;
|
||||
}
|
||||
|
@ -306,6 +306,14 @@ int main(int argc, char **argv) {
|
|||
cell_detect_config.init_agc = 50;
|
||||
}
|
||||
|
||||
sigset_t sigset;
|
||||
sigemptyset(&sigset);
|
||||
sigaddset(&sigset, SIGINT);
|
||||
sigprocmask(SIG_UNBLOCK, &sigset, NULL);
|
||||
signal(SIGINT, sig_int_handler);
|
||||
|
||||
cuhd_set_master_clock_rate(uhd, 30.72e6);
|
||||
|
||||
/* set receiver frequency */
|
||||
cuhd_set_rx_freq_offset(uhd, (double) prog_args.uhd_freq, prog_args.uhd_freq_offset);
|
||||
cuhd_rx_wait_lo_locked(uhd);
|
||||
|
@ -317,11 +325,14 @@ int main(int argc, char **argv) {
|
|||
if (ret < 0) {
|
||||
fprintf(stderr, "Error searching for cell\n");
|
||||
exit(-1);
|
||||
} else if (ret == 0) {
|
||||
} else if (ret == 0 && !go_exit) {
|
||||
printf("Cell not found after %d trials. Trying again (Press Ctrl+C to exit)\n", ntrial++);
|
||||
}
|
||||
} while (ret == 0);
|
||||
} while (ret == 0 && !go_exit);
|
||||
|
||||
if (go_exit) {
|
||||
exit(0);
|
||||
}
|
||||
/* set sampling frequency */
|
||||
int srate = srslte_sampling_freq_hz(cell.nof_prb);
|
||||
if (srate != -1) {
|
||||
|
@ -330,11 +341,15 @@ int main(int argc, char **argv) {
|
|||
} else {
|
||||
cuhd_set_master_clock_rate(uhd, srate);
|
||||
}
|
||||
printf("Setting Sampling frequency %.2f MHz\n", (float) srate/1000000);
|
||||
cuhd_set_rx_srate(uhd, (double) srate);
|
||||
printf("Setting sampling rate %.2f MHz\n", (float) srate/1000000);
|
||||
float srate_uhd = cuhd_set_rx_srate(uhd, (double) srate);
|
||||
if (srate_uhd != srate) {
|
||||
fprintf(stderr, "Could not set sampling rate\n");
|
||||
exit(-1);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Invalid number of PRB %d\n", cell.nof_prb);
|
||||
return SRSLTE_ERROR;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
INFO("Stopping UHD and flushing buffer...\r",0);
|
||||
|
@ -385,8 +400,6 @@ int main(int argc, char **argv) {
|
|||
/* Initialize subframe counter */
|
||||
sf_cnt = 0;
|
||||
|
||||
// Register Ctrl+C handler
|
||||
signal(SIGINT, sig_int_handler);
|
||||
|
||||
#ifndef DISABLE_GRAPHICS
|
||||
if (!prog_args.disable_plots) {
|
||||
|
|
|
@ -163,14 +163,6 @@ void parse_args(prog_args_t *args, int argc, char **argv) {
|
|||
/* TODO: Do something with the output data */
|
||||
uint8_t data_rx[20000];
|
||||
|
||||
bool go_exit = false;
|
||||
|
||||
void sig_int_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT) {
|
||||
go_exit = true;
|
||||
}
|
||||
}
|
||||
|
||||
int cuhd_recv_wrapper_timed(void *h, void *data, uint32_t nsamples, srslte_timestamp_t *uhd_time) {
|
||||
DEBUG(" ---- Receive %d samples ---- \n", nsamples);
|
||||
|
@ -252,6 +244,15 @@ void rar_msg_fprint(FILE *stream, rar_msg_t *msg)
|
|||
fprintf(stream, "BI: %d\n", msg->BI);
|
||||
}
|
||||
|
||||
bool go_exit = false;
|
||||
void sig_int_handler(int signo)
|
||||
{
|
||||
printf("SIGINT received. Exiting...\n");
|
||||
if (signo == SIGINT) {
|
||||
go_exit = true;
|
||||
}
|
||||
}
|
||||
|
||||
int rar_unpack(uint8_t *buffer, rar_msg_t *msg)
|
||||
{
|
||||
int ret = SRSLTE_ERROR;
|
||||
|
@ -312,6 +313,14 @@ int main(int argc, char **argv) {
|
|||
exit(-1);
|
||||
}
|
||||
|
||||
sigset_t sigset;
|
||||
sigemptyset(&sigset);
|
||||
sigaddset(&sigset, SIGINT);
|
||||
sigprocmask(SIG_UNBLOCK, &sigset, NULL);
|
||||
signal(SIGINT, sig_int_handler);
|
||||
|
||||
cuhd_set_master_clock_rate(uhd, 30.72e6);
|
||||
|
||||
/* Set receiver gain */
|
||||
float x = cuhd_set_rx_gain(uhd, prog_args.uhd_rx_gain);
|
||||
printf("Set RX gain to %.1f dB\n", x);
|
||||
|
@ -327,29 +336,35 @@ int main(int argc, char **argv) {
|
|||
printf("Tunning TX receiver to %.3f MHz\n", (double ) prog_args.uhd_tx_freq/1000000);
|
||||
|
||||
|
||||
#ifdef kk
|
||||
uint32_t ntrial=0;
|
||||
do {
|
||||
ret = cuhd_search_and_decode_mib(uhd, &cell_detect_config, prog_args.force_N_id_2, &cell);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error searching for cell\n");
|
||||
exit(-1);
|
||||
} else if (ret == 0) {
|
||||
printf("Cell not found\n");
|
||||
} else if (ret == 0 && !go_exit) {
|
||||
printf("Cell not found after %d trials. Trying again (Press Ctrl+C to exit)\n", ntrial++);
|
||||
}
|
||||
} while (ret == 0 && !go_exit);
|
||||
|
||||
if (go_exit) {
|
||||
exit(0);
|
||||
}
|
||||
#endif
|
||||
cell.nof_prb = 50;
|
||||
cell.id = 1;
|
||||
cell.nof_ports = 1;
|
||||
|
||||
/* set sampling frequency */
|
||||
int srate = srslte_sampling_freq_hz(cell.nof_prb);
|
||||
if (srate != -1) {
|
||||
/* Modify master clock rate for 15 Mhz */
|
||||
if (cell.nof_prb == 75) {
|
||||
cuhd_set_master_clock_rate(uhd, 23.04e6);
|
||||
if (srate < 10e6) {
|
||||
cuhd_set_master_clock_rate(uhd, 4*srate);
|
||||
} else {
|
||||
cuhd_set_master_clock_rate(uhd, srate);
|
||||
}
|
||||
printf("Setting sampling rate %.2f MHz\n", (float) srate/1000000);
|
||||
float srate_uhd = cuhd_set_rx_srate(uhd, (double) srate);
|
||||
if (srate_uhd != srate) {
|
||||
fprintf(stderr, "Could not set sampling rate\n");
|
||||
exit(-1);
|
||||
}
|
||||
cuhd_set_rx_srate(uhd, (double) srate);
|
||||
cuhd_set_tx_srate(uhd, (double) srate);
|
||||
} else {
|
||||
fprintf(stderr, "Invalid number of PRB %d\n", cell.nof_prb);
|
||||
exit(-1);
|
||||
|
@ -422,8 +437,7 @@ cell.nof_ports = 1;
|
|||
uint16_t ra_rnti;
|
||||
uint32_t conn_setup_trial = 0;
|
||||
uint32_t ul_sf_idx = 0;
|
||||
// Register Ctrl+C handler
|
||||
signal(SIGINT, sig_int_handler);
|
||||
|
||||
state = DECODE_MIB;
|
||||
|
||||
/* Main loop */
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
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;
|
||||
float uhd_gain=40.0, uhd_freq=-1.0, uhd_rate=0.96e6;
|
||||
int nof_samples = -1;
|
||||
|
||||
void int_handler(int dummy) {
|
||||
|
@ -54,7 +54,7 @@ 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-r UHD Rate [Default %.6f Hz]\n", uhd_rate);
|
||||
printf("\t-n nof_samples [Default %d]\n", nof_samples);
|
||||
printf("\t-v srslte_verbose\n");
|
||||
}
|
||||
|
@ -122,9 +122,30 @@ int main(int argc, char **argv) {
|
|||
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_set_master_clock_rate(uhd, 30.72e6);
|
||||
|
||||
sigset_t sigset;
|
||||
sigemptyset(&sigset);
|
||||
sigaddset(&sigset, SIGINT);
|
||||
sigprocmask(SIG_UNBLOCK, &sigset, NULL);
|
||||
|
||||
printf("Set RX freq: %.2f MHz\n", cuhd_set_rx_freq(uhd, uhd_freq) / 1000000);
|
||||
printf("Set RX gain: %.2f dB\n", cuhd_set_rx_gain(uhd, uhd_gain));
|
||||
float srate = cuhd_set_rx_srate(uhd, uhd_rate);
|
||||
if (srate != uhd_rate) {
|
||||
if (srate < 10e6) {
|
||||
cuhd_set_master_clock_rate(uhd, 4*uhd_rate);
|
||||
} else {
|
||||
cuhd_set_master_clock_rate(uhd, uhd_rate);
|
||||
}
|
||||
srate = cuhd_set_rx_srate(uhd, uhd_rate);
|
||||
if (srate != uhd_rate) {
|
||||
fprintf(stderr, "Errror setting samplign frequency %.2f MHz\n", uhd_rate*1e-6);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
printf("Correctly RX rate: %.2f MHz\n", srate*1e-6);
|
||||
cuhd_rx_wait_lo_locked(uhd);
|
||||
cuhd_start_rx_stream(uhd);
|
||||
|
||||
|
|
|
@ -123,9 +123,32 @@ int main(int argc, char **argv) {
|
|||
fprintf(stderr, "Error opening uhd\n");
|
||||
exit(-1);
|
||||
}
|
||||
cuhd_set_master_clock_rate(uhd, 30.72e6);
|
||||
|
||||
sigset_t sigset;
|
||||
sigemptyset(&sigset);
|
||||
sigaddset(&sigset, SIGINT);
|
||||
sigprocmask(SIG_UNBLOCK, &sigset, NULL);
|
||||
|
||||
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, srslte_sampling_freq_hz(nof_prb)) / 1000000);
|
||||
int srate = srslte_sampling_freq_hz(nof_prb);
|
||||
if (srate != -1) {
|
||||
if (srate < 10e6) {
|
||||
cuhd_set_master_clock_rate(uhd, 4*srate);
|
||||
} else {
|
||||
cuhd_set_master_clock_rate(uhd, srate);
|
||||
}
|
||||
printf("Setting sampling rate %.2f MHz\n", (float) srate/1000000);
|
||||
float srate_uhd = cuhd_set_rx_srate(uhd, (double) srate);
|
||||
if (srate_uhd != srate) {
|
||||
fprintf(stderr, "Could not set sampling rate\n");
|
||||
exit(-1);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Invalid number of PRB %d\n", nof_prb);
|
||||
exit(-1);
|
||||
}
|
||||
cuhd_rx_wait_lo_locked(uhd);
|
||||
cuhd_start_rx_stream(uhd);
|
||||
|
||||
|
|
|
@ -126,6 +126,8 @@ int main(int argc, char **argv) {
|
|||
fprintf(stderr, "Error opening uhd\n");
|
||||
exit(-1);
|
||||
}
|
||||
cuhd_set_master_clock_rate(uhd, 30.72e6);
|
||||
|
||||
printf("Subframe len: %d samples\n", flen);
|
||||
printf("Set TX/RX rate: %.2f MHz\n", cuhd_set_rx_srate(uhd, srslte_sampling_freq_hz(nof_prb)) / 1000000);
|
||||
printf("Set RX gain: %.1f dB\n", cuhd_set_rx_gain(uhd, uhd_rx_gain));
|
||||
|
|
|
@ -208,7 +208,7 @@ int cuhd_open_(char *args, void **h, bool create_thread_gain, bool tx_gain_same_
|
|||
uhd::set_thread_priority_safe();
|
||||
cuhd_handler *handler = new cuhd_handler();
|
||||
std::string _args = std::string(args);
|
||||
handler->usrp = uhd::usrp::multi_usrp::make(_args + ", master_clock_rate=30720000, recv_frame_size=7696,num_recv_frames=64,send_frame_size=7696,num_send_frames=64");
|
||||
handler->usrp = uhd::usrp::multi_usrp::make(_args + ", recv_frame_size=7696,num_recv_frames=64,send_frame_size=7696,num_send_frames=64");
|
||||
handler->usrp->set_clock_source("internal");
|
||||
|
||||
std::string otw, cpu;
|
||||
|
@ -271,7 +271,7 @@ double cuhd_set_rx_srate(void *h, double freq)
|
|||
{
|
||||
cuhd_handler *handler = static_cast < cuhd_handler * >(h);
|
||||
handler->usrp->set_rx_rate(freq);
|
||||
return freq;
|
||||
return handler->usrp->get_rx_rate();
|
||||
}
|
||||
|
||||
double cuhd_set_rx_gain(void *h, double gain)
|
||||
|
|
Loading…
Reference in New Issue