Added extra dump info to radio file process. Added radiotest conf sample.

git-svn-id: http://voip.null.ro/svn/yate@6002 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
marian 2015-07-15 10:10:33 +00:00
parent 43a13af328
commit 1d14b47856
2 changed files with 82 additions and 17 deletions

View File

@ -0,0 +1,41 @@
; This file holds configuration for radiotest module
[radiodatafile]
; This section configures radio data file processing
; fmt-float: string: Format for float samples
;fmt-float=%+g%+gj
; fmt-int: string: Format for int samples
;fmt-int=%+d%+dj
; separator: string: Samples separator
; Defaults to space if missing
; Set it to empty string if no separator is required
;separator=
; input: string: File to process
; This parameter is required
;input=
; output: string: Optional file to write data
; If missing processing result will be displayed in console/log
;output=
; recformat: string: Optional format for file record dump
; E.g.: ${timestamp} delta=${ts-delta} samples=${samples}: ${data}${newline}
;recformat=${data}
; dumpdata: boolean: Dump record contents
; This parameter is ignored if data is written to file (e.g. only records
; data is dumped to file)
;dumpdata=true
; recstart: integer: Optional record index to start processing
;recstart=1
; reccount: integer: Optional number of records to process (0: all)
;reccount=0
; recsamples: integer: Optional number of samples to dump from each record (0: all)
;recsamples=0

View File

@ -618,7 +618,7 @@ void RadioTestModule::processRadioDataFile(NamedList& params)
"Can't handle radio data file process: no section '%s' in config",s);
return;
}
const char* file = p->getValue("file");
const char* file = p->getValue("input");
if (!file) {
Debug(this,DebugNote,"Radio data file process sect='%s': missing file",s);
return;
@ -640,7 +640,6 @@ void RadioTestModule::processRadioDataFile(NamedList& params)
if (desc.m_ports != 1)
RADIO_FILE_ERROR("unhandled ports",desc.m_ports);
const char* fmt = 0;
const char* sep = " ";
unsigned int sz = 0;
switch (desc.m_elementType) {
case RadioDataDesc::Float:
@ -665,6 +664,13 @@ void RadioTestModule::processRadioDataFile(NamedList& params)
output.c_str(),fOut.error(),tmp.c_str());
break;
}
const String* sepParam = p->getParam(YSTRING("separator"));
const char* sep = sepParam ? sepParam->c_str() : " ";
bool dumpData = fOut.valid() ? true : p->getBoolValue(YSTRING("dumpdata"),true);
unsigned int dumpStart = p->getIntValue(YSTRING("recstart"),1,1);
unsigned int dumpCount = p->getIntValue(YSTRING("reccount"),0,0);
unsigned int dumpMax = p->getIntValue(YSTRING("recsamples"),0,0);
const String& recFmt = (*p)[YSTRING("recformat")];
Debug(this,DebugAll,"Processing radio data file '%s'",file);
uint64_t ts = 0;
DataBlock buf;
@ -672,17 +678,18 @@ void RadioTestModule::processRadioDataFile(NamedList& params)
String fmt4;
for (unsigned int i = 0; i < 4; i++)
fmt4.append(fmt,sep);
bool dumpData = fOut.valid() ? true : p->getBoolValue(YSTRING("dumpdata"),true);
unsigned int dumpMax = p->getIntValue(YSTRING("dumpmax"),0,0);
uint64_t oldTs = 0;
bool first = true;
unsigned int sampleBytes = sz * 2;
while (!Thread::check(false) && d.read(ts,buf,this) && buf.length()) {
n++;
if ((buf.length() % sz) != 0) {
error.printf("record=%u len=%u - length is not a multiple of element size",
if ((buf.length() % sampleBytes) != 0) {
error.printf("record=%u len=%u - length is not a multiple of samples",
n,buf.length());
break;
}
if (n < dumpStart)
continue;
String str;
if (dumpData) {
if (!d.sameEndian() && !d.fixEndian(buf,sz))
@ -700,10 +707,29 @@ void RadioTestModule::processRadioDataFile(NamedList& params)
if (error)
break;
}
int64_t delta = 0;
if (first)
first = false;
else
delta = ts - oldTs;
oldTs = ts;
unsigned int samples = buf.length() / sampleBytes;
if (fOut.valid()) {
if (str) {
str += sep;
int wr = fOut.writeData(str.c_str(),str.length());
if (recFmt) {
NamedList nl("");
nl.addParam("timestamp",String(ts));
nl.addParam("data",str);
nl.addParam("ts-delta",String(delta));
nl.addParam("samples",String(samples));
nl.addParam("newline","\r\n");
nl.addParam("separator",sep);
str = recFmt;
nl.replaceParams(str);
}
else
str += sep;
int wr = str ? fOut.writeData(str.c_str(),str.length()) : str.length();
if (wr != (int)str.length()) {
String tmp;
Thread::errorString(tmp,fOut.error());
@ -712,17 +738,15 @@ void RadioTestModule::processRadioDataFile(NamedList& params)
break;
}
}
continue;
}
int64_t delta = 0;
if (first)
first = false;
else
delta = ts - oldTs;
oldTs = ts;
Output("%u: TS=" FMT64U " bytes=%u samples=%u delta=" FMT64 "%s",
n,ts,buf.length(),buf.length() / sz,delta,encloseDashes(str,true));
buf.clear();
Output("%u: TS=" FMT64U " bytes=%u samples=%u delta=" FMT64 "%s",
n,ts,buf.length(),samples,delta,encloseDashes(str,true));
if (dumpCount) {
dumpCount--;
if (!dumpCount)
break;
}
}
break;
}