Fixed some segfaults in tests

master
ismagom 10 years ago
parent 64493f9644
commit 4652fe6bfe

@ -0,0 +1,80 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2015 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 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 <pthread.h>
#include "srsapps/common/tti_sync_cv.h"
namespace srslte {
namespace ue {
tti_sync_cv::tti_sync_cv(uint32_t modulus): tti_sync(modulus)
{
pthread_mutex_init(&mutex, NULL);
pthread_cond_init(&cond, NULL);
}
tti_sync_cv::~tti_sync_cv()
{
pthread_cond_destroy(&cond);
pthread_mutex_destroy(&mutex);
}
uint32_t tti_sync_cv::wait()
{
pthread_mutex_lock(&mutex);
while(wait_condition()) {
pthread_cond_wait(&cond, &mutex);
}
uint32_t x = consumer_cntr;
increase_consumer();
pthread_mutex_unlock(&mutex);
return x;
}
void tti_sync_cv::resync()
{
consumer_cntr = producer_cntr;
}
void tti_sync_cv::set_producer_cntr(uint32_t producer_cntr)
{
pthread_mutex_lock(&mutex);
init_counters(producer_cntr);
pthread_cond_signal(&cond);
pthread_mutex_unlock(&mutex);
}
void tti_sync_cv::increase()
{
pthread_mutex_lock(&mutex);
increase_producer();
pthread_cond_signal(&cond);
pthread_mutex_unlock(&mutex);
}
}
}

@ -33,4 +33,4 @@ SRSLTE_SET_PIC(srsapps_ue_mac)
FILE(GLOB HEADERS_ALL "include/srsapps/ue/mac/*.h")
ADD_CUSTOM_TARGET (add_ue_mac_headers SOURCES ${HEADERS_ALL})
#ADD_SUBDIRECTORY(test)
ADD_SUBDIRECTORY(test)

@ -49,7 +49,7 @@
namespace srslte {
namespace ue {
class mac : public thread, timer_callback, mac_interface_phy, mac_interface_rlc, mac_interface_params
class mac : public mac_interface_phy, mac_interface_rlc, thread, timer_callback, mac_interface_params
{
public:
mac();

@ -151,7 +151,6 @@ void setup_mac_phy_sib2(LIBLTE_RRC_SYS_INFO_BLOCK_TYPE_2_STRUCT *sib2, srslte::u
sib2->rr_config_common_sib.pdsch_cnfg.p_b);
// PUSCH ConfigCommon
phy->set_param(srslte::ue::phy_interface_params::PUSCH_BETA, 10);
phy->set_param(srslte::ue::phy_interface_params::PUSCH_EN_64QAM,
sib2->rr_config_common_sib.pusch_cnfg.enable_64_qam);
phy->set_param(srslte::ue::phy_interface_params::PUSCH_HOPPING_OFFSET,
@ -176,7 +175,6 @@ void setup_mac_phy_sib2(LIBLTE_RRC_SYS_INFO_BLOCK_TYPE_2_STRUCT *sib2, srslte::u
sib2->rr_config_common_sib.pusch_cnfg.n_sb);
// PUCCH ConfigCommon
phy->set_param(srslte::ue::phy_interface_params::PUCCH_BETA, 10);
phy->set_param(srslte::ue::phy_interface_params::PUCCH_DELTA_SHIFT,
liblte_rrc_delta_pucch_shift_num[sib2->rr_config_common_sib.pucch_cnfg.delta_pucch_shift]);
phy->set_param(srslte::ue::phy_interface_params::PUCCH_CYCLIC_SHIFT,
@ -332,7 +330,7 @@ void sig_int_handler(int signo)
exit(0);
}
class my_rlc : public srslte::ue::rlc_interface_mac {
class rlctest : public srslte::ue::rlc_interface_mac {
public:
bool mib_decoded;
bool sib1_decoded;
@ -341,7 +339,7 @@ public:
int nsegm_dcch;
uint8_t si_window_len, sib2_period;
my_rlc() {
rlctest() {
mib_decoded = false;
sib1_decoded = false;
sib2_decoded = false;
@ -388,7 +386,7 @@ public:
// Send ConnectionRequest Packet
printf("Send ConnectionRequest %d/%d bytes\n", nbytes, nof_bytes);
memcpy(payload, nbytes, nbytes*sizeof(uint8_t));
srslte_bit_pack_vector(bit_msg.msg, payload, nbytes*8);
bzero(&payload[nbytes], (nof_bytes-nbytes)*sizeof(uint8_t));
} else if (lcid == 1) {
if (nsegm_dcch < 2) {
@ -466,7 +464,7 @@ private:
int main(int argc, char *argv[])
{
srslte::log_stdout mac_log("MAC"), phy_log("PHY");
rlctest my_rlc;
parse_args(&prog_args, argc, argv);
switch (prog_args.verbose) {

@ -168,6 +168,7 @@ int srslte_dci_msg_to_ul_grant(srslte_dci_msg_t *msg, uint32_t nof_prb,
int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (msg != NULL &&
ul_dci != NULL &&
grant != NULL)
{
ret = SRSLTE_ERROR;
@ -186,7 +187,7 @@ int srslte_dci_msg_to_ul_grant(srslte_dci_msg_t *msg, uint32_t nof_prb,
if (SRSLTE_VERBOSE_ISINFO()) {
srslte_ra_pusch_fprint(stdout, ul_dci, nof_prb);
srslte_ra_ul_grant_fprint(stdout, grant);
srslte_ra_ul_grant_fprint(stdout, grant);
}
ret = SRSLTE_SUCCESS;

@ -122,7 +122,7 @@ int base_init() {
fmatlab = NULL;
}
flen = SRSLTE_SLOT_LEN(srslte_symbol_sz(cell.nof_prb));
flen = SRSLTE_SF_LEN(srslte_symbol_sz(cell.nof_prb));
input_buffer = malloc(flen * sizeof(cf_t));
if (!input_buffer) {

@ -145,7 +145,7 @@ int base_init() {
fmatlab = NULL;
}
flen = SRSLTE_SLOT_LEN(srslte_symbol_sz(cell.nof_prb));
flen = SRSLTE_SF_LEN(srslte_symbol_sz(cell.nof_prb));
input_buffer = malloc(flen * sizeof(cf_t));
if (!input_buffer) {

@ -136,7 +136,7 @@ int main(int argc, char **argv) {
srslte_dci_msg_pack_pusch(&dci, &dci_msg, cell.nof_prb);
srslte_ra_ul_grant_t grant;
if (srslte_dci_msg_to_ul_grant(&dci_msg, cell.nof_prb, 0, NULL, &grant)) {
if (srslte_dci_msg_to_ul_grant(&dci_msg, cell.nof_prb, 0, &dci, &grant)) {
return false;
}

Loading…
Cancel
Save