06 Text, enums and binary data


Text, enumeration and binary data

Text and binary signal handling is similar to the handling of integer signals. You just need a pointer and a size.
 

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

	// add integer signals
	flxAddScope(trace, 1, 0, "Other", "Scope Description");
	flxAddSignal(trace, 2, 1, "a text", "Signal Description", FLX_TYPE_TEXT, 0);
	flxAddSignal(trace, 3, 1, "an enumeration event", "Signal Description", FLX_TYPE_EVENT, 0);
	flxAddSignal(trace, 4, 1, "a binary", "Signal Description", FLX_TYPE_BINARY, 0);

	// open
	flxOpen(trace, 0, "ns", 0, 0);

	// write enums for signal 3 (event)
	flxWriteEnumDef(trace, 3, FLX_ENUM_GLOBAL, "Yes", 1);
	flxWriteEnumDef(trace, 3, FLX_ENUM_GLOBAL, "No", 0);

Events are different. When you write am event, you always use an unsigned int (flxuint). The textual representation of the enumeration is added using the flxWriteEnumDef function. The parameters are:

  • the trace object,
  • itemId for the signal,
  • the enumeration scope, here FLX_ENUM_GLOBAL for global scope,
  • the text representation,
  • and the enumeration value
FLX_ENUM_GLOBAL means global for a signal, not global for the trace or sequence. 
// iterate over n

	// values
	int eVal = n & 1;
	char tVal[32];
	double fVal = cos(n / 100.);
	sprintf(tVal, "val: %f", fVal);

	// writes a text
	flxWriteTextAt(trace, 2, 0, n * 10, 0, tVal, strlen(tVal));

	// write an enum event yes/no
	flxWriteEventAt(trace, 3, 0, 0, 1, eVal);

	// write the bytes of a double value
	flxWriteBinaryAt(trace, 4, 0, 0, 1, (flxbptr) &fVal, 8);


toem

technical software and tooling

Company

Contact Us

This email address is being protected from spambots. You need JavaScript enabled to view it.