Using flux trace in an embedded environment

With flux trace you can easily send any kind of trace/signal information from an embedded target to host to get analyzed. This examples shows the usage together with FreeRtos and an infineon development board with J-Link adapter.

Screen Cast: Using flux in
an embedded environment

This screen cast will help you to
  • setup flux trace in an embedded environment,
  • to configure a port to transmit the trace data,
  • to start the port/viewer from the debug launcher,
  • and to view the output.

flux Example code

#define MAX_ITEM_ID 16 // maximum id of scope/signal
#define MAX_ENTRY_SIZE 1024
flxTrace trace;
unsigned char _memoryBuffer[FLX_BUFFER_BYTES(MAX_ENTRY_SIZE)];
static unsigned char _memoryTrace[FLX_TRACE_BYTES(0, MAX_ITEM_ID)];

flxBuffer buffer;

flxresult rttHandler(flxbyte command, void* buffer, flxbint* len,
		flxbyte* bytes, void*user) {

	// just write the data to a file
	SEGGER_RTT_Write(0, bytes, *len);
	return FLX_OK;
}

void main(){
....

	// buffer
	buffer = flxCreateLinearBuffer(_memoryBuffer,
			sizeof(_memoryBuffer), rttHandler, 0);

	trace = flxCreateTrace(0, MAX_ITEM_ID, MAX_ENTRY_SIZE, _memoryTrace,
			sizeof(_memoryTrace), buffer);

	// head
	flxAddHead(trace, "example", "flux example");

	// add signals
	// parent 0 is root
	flxAddSignal(trace, 1, 0, "activation1", "an integer", FLX_TYPE_INTEGER, 0);
	flxAddSignal(trace, 2, 0, "activation2", "an integer", FLX_TYPE_INTEGER, 0);
	flxAddSignal(trace, 3, 0, "signal1", "a float", FLX_TYPE_FLOAT, 0);
	flxAddSignal(trace, 4, 0, "signal2", "a float", FLX_TYPE_FLOAT, 0);

	// open
	flxOpen(trace, 0, "ms", 0, 0);
....
}

void task(){
...
	static int activation=0;
	activation++;
	flxWriteIntAt(trace, 2, 0, xTaskGetTickCount(), 0, &activation, sizeof(activation), 0);
	float signal = sin(activation/30.0);
	flxWriteFloatAt(trace, 4, 0, xTaskGetTickCount(), 0, &signal, sizeof(signal));
	flxFlush(trace);
...
}

Screen Cast: Using flux in
an embedded environment Part2

This 2nd screen cast will give you hints to
  • use Signal Script to analyze the trace data,
  • using the script editor,
  • and to update the production results to the output view.

Signal Script Example code

// input: an array of all input signals
// in0: primary input of type ISamplePointer,IReadableSamples
// in1..: additional inputs of type ISamplePointer,IReadableSamples
// out: output signal of type IFloatSamplesWriter
// console: console output of type MessageConsoleStream
// iter: iterator of type ISamplesIterator
// progress: progess control of type  IScriptProgress


progress.cont();

var status;
if(status ==null)
status = 0;

while ( iter.hasNext()) {
    var current <:Long:> = iter.next(out);
    
    if (in0.val() > 1.0 && status == 0){
        out.write(current,false,1);
        status = 1;
    }else if (in0.val() <= 1.0 && status == 1){
        out.write(current,false,0);
        status = 0;
    }

}

Print

User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive