mirror of https://github.com/pvnis/srsRAN_4G.git
Added timing traces for phy/mac/radio classes.
parent
f9b7b7827b
commit
033d50978b
@ -0,0 +1,19 @@
|
||||
function [ tti, values ] = read_trace_uint( filename, count )
|
||||
|
||||
[tidin msg]=fopen(filename,'r');
|
||||
if (tidin==-1)
|
||||
fprintf('error opening %s: %s\n',filename, msg);
|
||||
out=[];
|
||||
return
|
||||
end
|
||||
|
||||
if (nargin==1)
|
||||
count=inf;
|
||||
end
|
||||
|
||||
x=fread(tidin,2*count,'uint');
|
||||
i=1:2:length(x);
|
||||
tti=x(i);
|
||||
values=x(i+1);
|
||||
end
|
||||
|
@ -0,0 +1,98 @@
|
||||
/**
|
||||
*
|
||||
* \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 <stdio.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#ifndef TRACE_H
|
||||
#define TRACE_H
|
||||
|
||||
namespace srslte {
|
||||
|
||||
template<class elemType>
|
||||
class trace
|
||||
{
|
||||
public:
|
||||
|
||||
trace(uint32_t nof_elems_) : tti(nof_elems_), data(nof_elems_) {
|
||||
rpm=0;
|
||||
nof_elems=nof_elems_;
|
||||
wrapped = false;
|
||||
};
|
||||
void push_cur_time_us(uint32_t cur_tti) {
|
||||
struct timeval t;
|
||||
gettimeofday(&t, NULL);
|
||||
elemType us = t.tv_sec*1e6+t.tv_usec;
|
||||
push(cur_tti, us);
|
||||
}
|
||||
void push(uint32_t value_tti, elemType value) {
|
||||
tti[rpm] = value_tti;
|
||||
data[rpm] = value;
|
||||
rpm++;
|
||||
if (rpm >= nof_elems) {
|
||||
rpm = 0;
|
||||
wrapped = true;
|
||||
}
|
||||
}
|
||||
bool writeToBinary(std::string filename) {
|
||||
FILE *f = fopen(filename.c_str(), "w");
|
||||
if (f != NULL) {
|
||||
uint32_t st=wrapped?(rpm+1):0;
|
||||
do {
|
||||
writeToBinaryValue(f, st++);
|
||||
if (st >= nof_elems) {
|
||||
st=0;
|
||||
}
|
||||
} while(st<rpm);
|
||||
fclose(f);
|
||||
return true;
|
||||
} else {
|
||||
perror("fopen");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<uint32_t> tti;
|
||||
std::vector<elemType> data;
|
||||
uint32_t rpm;
|
||||
uint32_t nof_elems;
|
||||
bool wrapped;
|
||||
|
||||
void writeToBinaryValue(FILE *f, uint32_t idx) {
|
||||
fwrite(&tti[idx], 1, sizeof(uint32_t), f);
|
||||
fwrite(&data[idx], 1, sizeof(elemType), f);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue