Solved unitialised values in UE (up to prach) and free

master
Xavier Arteaga 6 years ago committed by Andre Puschmann
parent 2e1b8240e6
commit c782ef2aa5

@ -39,6 +39,7 @@ typedef struct {
void *dev;
// The following variables are for threaded RX gain control
bool thread_gain_run;
pthread_t thread_gain;
pthread_cond_t cond;
pthread_mutex_t mutex;

@ -35,7 +35,7 @@
namespace srslte{
log_filter::log_filter()
log_filter::log_filter() : log()
{
do_tti = false;
time_src = NULL;
@ -43,12 +43,12 @@ log_filter::log_filter()
logger_h = NULL;
}
log_filter::log_filter(std::string layer)
log_filter::log_filter(std::string layer) : log()
{
do_tti = false;
time_src = NULL;
time_format = TIME;
init(layer, &def_logger_stdout, tti);
init(layer, &def_logger_stdout, do_tti);
}
log_filter::log_filter(std::string layer, logger *logger_, bool tti)

@ -45,7 +45,7 @@
#define FFTW_TYPE 0
#endif
pthread_mutex_t fft_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t fft_mutex = PTHREAD_MUTEX_INITIALIZER;
void srslte_dft_load() {
#ifdef FFTW_WISDOM_FILE
@ -347,7 +347,6 @@ void srslte_dft_plan_free(srslte_dft_plan_t *plan) {
}
if (plan->p) fftwf_destroy_plan(plan->p);
pthread_mutex_unlock(&fft_mutex);
bzero(plan, sizeof(srslte_dft_plan_t));
}

@ -58,7 +58,7 @@ void srslte_rf_set_tx_rx_gain_offset(srslte_rf_t *rf, double offset) {
static void* thread_gain_fcn(void *h) {
srslte_rf_t* rf = (srslte_rf_t*) h;
while(1) {
while(rf->thread_gain_run) {
pthread_mutex_lock(&rf->mutex);
while(rf->cur_rx_gain == rf->new_rx_gain)
{
@ -89,8 +89,10 @@ int srslte_rf_start_gain_thread(srslte_rf_t *rf, bool tx_gain_same_rx) {
if (pthread_cond_init(&rf->cond, NULL)) {
return -1;
}
rf->thread_gain_run = true;
if (pthread_create(&rf->thread_gain, NULL, thread_gain_fcn, rf)) {
perror("pthread_create");
rf->thread_gain_run = false;
return -1;
}
return 0;
@ -185,6 +187,12 @@ int srslte_rf_open_multi(srslte_rf_t *h, char *args, uint32_t nof_channels)
int srslte_rf_close(srslte_rf_t *rf)
{
// Stop gain thread
if (rf->thread_gain_run) {
pthread_cancel(rf->thread_gain);
pthread_join(rf->thread_gain, NULL);
}
return ((rf_dev_t*) rf->dev)->srslte_rf_close(rf->handler);
}

@ -35,11 +35,14 @@ void srslte_ringbuffer_free(srslte_ringbuffer_t *q)
void srslte_ringbuffer_reset(srslte_ringbuffer_t *q)
{
pthread_mutex_lock(&q->mutex);
q->count = 0;
q->wpm = 0;
q->rpm = 0;
pthread_mutex_unlock(&q->mutex);
// Check first if it is initiated
if (q->capacity != 0) {
pthread_mutex_lock(&q->mutex);
q->count = 0;
q->wpm = 0;
q->rpm = 0;
pthread_mutex_unlock(&q->mutex);
}
}
int srslte_ringbuffer_status(srslte_ringbuffer_t *q)

@ -199,6 +199,7 @@ private:
// Class to perform intra-frequency measurements
class intra_measure : public thread {
public:
intra_measure();
~intra_measure();
void init(phch_common *common, rrc_interface_phy *rrc, srslte::log *log_h);
void stop();

@ -115,6 +115,7 @@ class cell_t
cell_t() {
phy_interface_rrc::phy_cell_t tmp;
ZERO_OBJECT(tmp);
ZERO_OBJECT(phy_cell);
cell_t(tmp, 0);
}
cell_t(phy_interface_rrc::phy_cell_t phy_cell, float rsrp) {

@ -47,8 +47,10 @@ mac::mac() : timers(64),
pdu_process_thread(&demux_unit),
mch_msg(10)
{
tti = 0;
pcap = NULL;
bzero(&metrics, sizeof(mac_metrics_t));
bzero(&config, sizeof(mac_cfg_t));
}
bool mac::init(phy_interface_mac *phy, rlc_interface_mac *rlc, rrc_interface_mac *rrc, srslte::log *log_h_)

@ -38,6 +38,7 @@
bsr_proc::bsr_proc()
{
log_h = NULL;
initiated = false;
last_print = 0;
next_tx_tti = 0;

@ -587,6 +587,7 @@ int main(int argc, char* argv[])
}
ue->switch_off();
pthread_cancel(input);
pthread_join(input, NULL);
metricshub.stop();
ue->stop();
ue->cleanup();

@ -53,6 +53,7 @@ phch_common::phch_common(uint32_t max_workers) : tx_sem(max_workers)
rx_gain_offset = 0;
last_ri = 0;
last_pmi = 0;
avg_noise = NAN;
//have_mtch_stop = false;
bzero(&dl_metrics, sizeof(dl_metrics_t));

@ -49,6 +49,7 @@ double callback_set_rx_gain(void *h, double gain) {
phch_recv::phch_recv() {
tti = 0;
dl_freq = -1;
ul_freq = -1;
bzero(&cell, sizeof(srslte_cell_t));
@ -56,6 +57,12 @@ phch_recv::phch_recv() {
cellsearch_earfcn_index = 0;
running = false;
worker_com = NULL;
current_sflen = 0;
next_offset = 0;
nof_rx_antennas = 1;
current_srate = 0.0f;
time_adv_sec = 0;
next_time_adv_sec = 0;
}
void phch_recv::init(srslte::radio_multi *_radio_handler, mac_interface_phy *_mac, rrc_interface_phy *_rrc,
@ -1533,6 +1540,28 @@ int phch_recv::meas_stop(uint32_t earfcn, int pci) {
return -1;
}
phch_recv::intra_measure::intra_measure()
: scell() {
rrc = NULL;
common = NULL;
search_buffer = NULL;
log_h = NULL;
current_earfcn = 0;
current_sflen = 0;
measure_tti = 0;
receive_cnt = 0;
running = false;
receive_enabled = false;
receiving = false;
ZERO_OBJECT(info);
ZERO_OBJECT(ring_buffer);
ZERO_OBJECT(primary_cell);
}
phch_recv::intra_measure::~intra_measure() {
srslte_ringbuffer_free(&ring_buffer);
scell.deinit();

@ -67,6 +67,9 @@ phch_worker::phch_worker() : tr_exec(10240)
cell_initiated = false;
pregen_enabled = false;
trace_enabled = false;
pthread_mutex_init(&mutex, NULL);
reset();
}
@ -83,6 +86,8 @@ phch_worker::~phch_worker()
srslte_ue_ul_free(&ue_ul);
mem_initiated = false;
}
pthread_mutex_destroy(&mutex);
}
void phch_worker::reset()
@ -154,7 +159,6 @@ bool phch_worker::init(uint32_t max_prb, srslte::log *log_h, srslte::log *log_ph
mem_initiated = true;
pthread_mutex_init(&mutex, NULL);
return true;
}

@ -52,6 +52,8 @@ phy::phy() : workers_pool(MAX_WORKERS),
workers(MAX_WORKERS),
workers_common(MAX_WORKERS),nof_coworkers(0)
{
ZERO_OBJECT(config);
ZERO_OBJECT(cell);
}
static void srslte_phy_handler(phy_logger_level_t log_level, void *ctx, char *str) {

@ -39,8 +39,11 @@ using namespace srslte;
namespace srsue{
ue::ue()
:started(false)
:started(false), mac_log()
{
usim = NULL;
logger = NULL;
args = NULL;
}
ue::~ue()

@ -52,7 +52,6 @@ rrc::rrc() :
state(RRC_STATE_IDLE),
last_state(RRC_STATE_CONNECTED),
drb_up(false),
serving_cell(NULL),
rlc_flush_timeout(2000),
rlc_flush_counter(0)
{

Loading…
Cancel
Save