|
|
@ -21,7 +21,7 @@ class dummy_radio
|
|
|
|
private:
|
|
|
|
private:
|
|
|
|
static const int radio_delay_us = 200;
|
|
|
|
static const int radio_delay_us = 200;
|
|
|
|
|
|
|
|
|
|
|
|
srslte::log_filter* log_h = nullptr;
|
|
|
|
srslog::basic_logger& logger;
|
|
|
|
std::mutex mutex;
|
|
|
|
std::mutex mutex;
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t last_tti = 0;
|
|
|
|
uint32_t last_tti = 0;
|
|
|
@ -29,13 +29,13 @@ private:
|
|
|
|
bool late = false;
|
|
|
|
bool late = false;
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
dummy_radio(srslte::log_filter& log_h_) : log_h(&log_h_) { log_h->info("Dummy radio created\n"); }
|
|
|
|
explicit dummy_radio(srslog::basic_logger& logger) : logger(logger) { logger.info("Dummy radio created"); }
|
|
|
|
|
|
|
|
|
|
|
|
void tx(uint32_t tti)
|
|
|
|
void tx(uint32_t tti)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::lock_guard<std::mutex> lock(mutex);
|
|
|
|
std::lock_guard<std::mutex> lock(mutex);
|
|
|
|
|
|
|
|
|
|
|
|
log_h->info("Transmitting TTI %d\n", tti);
|
|
|
|
logger.info("Transmitting TTI %d", tti);
|
|
|
|
|
|
|
|
|
|
|
|
// Exit if TTI was advanced
|
|
|
|
// Exit if TTI was advanced
|
|
|
|
if (!first && tti <= last_tti) {
|
|
|
|
if (!first && tti <= last_tti) {
|
|
|
@ -59,8 +59,8 @@ private:
|
|
|
|
static const int sleep_time_min_us = 50;
|
|
|
|
static const int sleep_time_min_us = 50;
|
|
|
|
static const int sleep_time_max_us = 2000;
|
|
|
|
static const int sleep_time_max_us = 2000;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
srslog::basic_logger& logger;
|
|
|
|
srslte::tti_semaphore<uint32_t>* tti_semaphore = nullptr;
|
|
|
|
srslte::tti_semaphore<uint32_t>* tti_semaphore = nullptr;
|
|
|
|
srslte::log_filter* log_h = nullptr;
|
|
|
|
|
|
|
|
dummy_radio* radio = nullptr;
|
|
|
|
dummy_radio* radio = nullptr;
|
|
|
|
srslte_random_t random_gen = nullptr;
|
|
|
|
srslte_random_t random_gen = nullptr;
|
|
|
|
uint32_t tti = 0;
|
|
|
|
uint32_t tti = 0;
|
|
|
@ -68,14 +68,14 @@ private:
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
dummy_worker(uint32_t id,
|
|
|
|
dummy_worker(uint32_t id,
|
|
|
|
srslte::tti_semaphore<uint32_t>* tti_semaphore_,
|
|
|
|
srslte::tti_semaphore<uint32_t>* tti_semaphore_,
|
|
|
|
srslte::log_filter* log_h_,
|
|
|
|
srslog::basic_logger& logger,
|
|
|
|
dummy_radio* radio_)
|
|
|
|
dummy_radio* radio_) :
|
|
|
|
|
|
|
|
logger(logger)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tti_semaphore = tti_semaphore_;
|
|
|
|
tti_semaphore = tti_semaphore_;
|
|
|
|
log_h = log_h_;
|
|
|
|
|
|
|
|
radio = radio_;
|
|
|
|
radio = radio_;
|
|
|
|
random_gen = srslte_random_init(id);
|
|
|
|
random_gen = srslte_random_init(id);
|
|
|
|
log_h->info("Dummy worker created\n");
|
|
|
|
logger.info("Dummy worker created");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
~dummy_worker() { srslte_random_free(random_gen); }
|
|
|
|
~dummy_worker() { srslte_random_free(random_gen); }
|
|
|
@ -91,9 +91,9 @@ protected:
|
|
|
|
// Inform
|
|
|
|
// Inform
|
|
|
|
|
|
|
|
|
|
|
|
// Actual work ;)
|
|
|
|
// Actual work ;)
|
|
|
|
log_h->info("Start working for %d us.\n", sleep_time_us);
|
|
|
|
logger.info("Start working for %d us.", sleep_time_us);
|
|
|
|
usleep(sleep_time_us);
|
|
|
|
usleep(sleep_time_us);
|
|
|
|
log_h->info("Stopped working\n");
|
|
|
|
logger.info("Stopped working");
|
|
|
|
|
|
|
|
|
|
|
|
// Wait for green light
|
|
|
|
// Wait for green light
|
|
|
|
tti_semaphore->wait(tti);
|
|
|
|
tti_semaphore->wait(tti);
|
|
|
@ -121,28 +121,15 @@ int main(int argc, char** argv)
|
|
|
|
std::vector<std::unique_ptr<dummy_worker> > workers;
|
|
|
|
std::vector<std::unique_ptr<dummy_worker> > workers;
|
|
|
|
srslte::tti_semaphore<uint32_t> tti_semaphore;
|
|
|
|
srslte::tti_semaphore<uint32_t> tti_semaphore;
|
|
|
|
|
|
|
|
|
|
|
|
// Setup logging.
|
|
|
|
// Loggers.
|
|
|
|
srslog::sink* s = srslog::create_stdout_sink();
|
|
|
|
auto& radio_logger = srslog::fetch_basic_logger("radio", false);
|
|
|
|
if (!s) {
|
|
|
|
radio_logger.set_level(srslog::basic_levels::none);
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
srslog::log_channel* chan = srslog::create_log_channel("main_channel", *s);
|
|
|
|
|
|
|
|
if (!chan) {
|
|
|
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
srslte::srslog_wrapper logger(*chan);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Start the log backend.
|
|
|
|
// Start the log backend.
|
|
|
|
srslog::init();
|
|
|
|
srslog::init();
|
|
|
|
|
|
|
|
|
|
|
|
// Loggers
|
|
|
|
|
|
|
|
srslte::log_filter radio_log("radio", &logger);
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<srslte::log_filter> > worker_logs;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
radio_log.set_level("none");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Radio
|
|
|
|
// Radio
|
|
|
|
dummy_radio radio(radio_log);
|
|
|
|
dummy_radio radio(radio_logger);
|
|
|
|
|
|
|
|
|
|
|
|
// Create workers
|
|
|
|
// Create workers
|
|
|
|
for (uint32_t i = 0; i < nof_workers; i++) {
|
|
|
|
for (uint32_t i = 0; i < nof_workers; i++) {
|
|
|
@ -150,15 +137,13 @@ int main(int argc, char** argv)
|
|
|
|
char log_name[32] = {};
|
|
|
|
char log_name[32] = {};
|
|
|
|
snprintf(log_name, sizeof(log_name), "PHY%d", i);
|
|
|
|
snprintf(log_name, sizeof(log_name), "PHY%d", i);
|
|
|
|
|
|
|
|
|
|
|
|
// Create log filter
|
|
|
|
auto& logger = srslog::fetch_basic_logger(log_name, false);
|
|
|
|
srslte::log_filter* log_filter = new srslte::log_filter(log_name, &logger);
|
|
|
|
logger.set_level(srslog::basic_levels::none);
|
|
|
|
log_filter->set_level("none");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create worker
|
|
|
|
// Create worker
|
|
|
|
auto* worker = new dummy_worker(i, &tti_semaphore, log_filter, &radio);
|
|
|
|
auto* worker = new dummy_worker(i, &tti_semaphore, logger, &radio);
|
|
|
|
|
|
|
|
|
|
|
|
// Push back objects
|
|
|
|
// Push back objects
|
|
|
|
worker_logs.push_back(std::unique_ptr<srslte::log_filter>(log_filter));
|
|
|
|
|
|
|
|
workers.push_back(std::unique_ptr<dummy_worker>(worker));
|
|
|
|
workers.push_back(std::unique_ptr<dummy_worker>(worker));
|
|
|
|
|
|
|
|
|
|
|
|
// Init worker in pool
|
|
|
|
// Init worker in pool
|
|
|
|