This chapter covers the writing of text, binary and enumeration data.
While the handling of text (flux uses UTF-8) and binary data is simple, the handling of enumeration data additionally requires to send the text representation.
Event/Enumeration | Text | Binary | |
Java |
|
|
|
c |
|
+ size argument |
+ size argument |
Python |
|
|
|
TypeScript |
|
|
|
JavaScript |
|
|
|
Event/Enumeration signals are quite similar to integer signals. In both case, integer values are written in to trace object. The textual representation of the enumeration is added by using the flxWriteEnumDef/writeEnumDef methods. The parameters are:
FLX_ENUM_GLOBAL means global for a signal, not global for the trace or sequence.
The flxWriteEnumDef/writeEnumDef methods shall be used after opening the trace.
The parameters for flxWriteEventAt/writeEventAt) are:
// add signals trace.addScope( 1, 0, "Other", "Scope Description"); trace.addSignal( 3, 1, "an enumeration event", "Signal Description", Flx.TYPE_EVENT, null); // open // write enums for signal 3 (event) trace.writeEnumDef( 3, Flx.ENUM_GLOBAL, "Yes", 1); trace.writeEnumDef( 3, Flx.ENUM_GLOBAL, "No", 0); // values eVal = n & 1; // write an enum event yes/no trace.writeEventAt( 3, 0, 0, true, eVal);
// add signals flxAddScope(trace, 1, 0, "Other", "Scope Description"); flxAddSignal(trace, 3, 1, "an enumeration event", "Signal Description", FLX_TYPE_EVENT, 0); // open // write enums for signal 3 (event) flxWriteEnumDef(trace, 3, FLX_ENUM_GLOBAL, "Yes", 1); flxWriteEnumDef(trace, 3, FLX_ENUM_GLOBAL, "No", 0); // values eVal = n & 1; // write an enum event yes/no flxWriteEventAt(trace, 3, 0, 0, 1, eVal);
# add signals trace.addScope( 1, 0, "Other", "Scope Description"); trace.addSignal( 3, 1, "an enumeration event", "Signal Description", Flx.TYPE_EVENT, None); # open # write enums for signal 3 (event) trace.writeEnumDef( 3, Flx.ENUM_GLOBAL, "Yes", 1); trace.writeEnumDef( 3, Flx.ENUM_GLOBAL, "No", 0); # values eVal = n & 1; # write an enum event yes/no trace.writeEventAt( 3, 0, 0, True, eVal);
// add signals trace.addScope(1, 0, "Other", "Scope Description"); trace.addSignal(3, 1, "an enumeration event", "Signal Description", Flx.TYPE_EVENT, null); // open // write enums for signal 3 (event) trace.writeEnumDef(3, Flx.ENUM_GLOBAL, "Yes", 1); trace.writeEnumDef(3, Flx.ENUM_GLOBAL, "No", 0); // values eVal = n & 1; // write an enum event yes/no trace.writeEventAt(3, 0, 0, true, eVal);
// add signals trace.addScope(1, 0, "Other", "Scope Description"); trace.addSignal(3, 1, "an enumeration event", "Signal Description", Flx.TYPE_EVENT, null); // open // write enums for signal 3 (event) trace.writeEnumDef(3, Flx.ENUM_GLOBAL, "Yes", 1); trace.writeEnumDef(3, Flx.ENUM_GLOBAL, "No", 0); // values eVal = n & 1; // write an enum event yes/no trace.writeEventAt(3, 0, 0, true, eVal);
The writing of text and binary data is straightforward.
The parameters for flxWriteTextAt/writeTextAt and flxWriteBinaryAt/writeBinaryAt are:
// add signals trace.addScope( 1, 0, "Other", "Scope Description"); trace.addSignal( 2, 1, "a text", "Signal Description", Flx.TYPE_TEXT, null); trace.addSignal( 4, 1, "a binary", "Signal Description", Flx.TYPE_BINARY, null); // open // values tVal = "val: " + String.valueOf(n % 100); bVal[2] = (byte) (n & 0xff); // writes a text trace.writeTextAt( 2, 0, current , false, tVal); // write bytes trace.writeBinaryAt( 4, 0, 0, true, bVal);
// add signals flxAddScope(trace, 1, 0, "Other", "Scope Description"); flxAddSignal(trace, 2, 1, "a text", "Signal Description", FLX_TYPE_TEXT, 0); flxAddSignal(trace, 4, 1, "a binary", "Signal Description", FLX_TYPE_BINARY, 0); // open // values int iVal = (n % 100); sprintf(tVal, "val: %i", iVal); bVal[2] = n & 0xff; // writes a text flxWriteTextAt(trace, 2, 0, current, 0, tVal, strlen(tVal)); // write bytes flxWriteBinaryAt(trace, 4, 0, 0, 1, (flxbptr) bVal, 5);
# add signals trace.addScope( 1, 0, "Other", "Scope Description"); trace.addSignal( 2, 1, "a text", "Signal Description", Flx.TYPE_TEXT, None); trace.addSignal( 4, 1, "a binary", "Signal Description", Flx.TYPE_BINARY, None); # open # values tVal = "val: " + str(n % 100); bVal[2] = (n & 0xff); # writes a text trace.writeTextAt( 2, 0, current , False, tVal); # write bytes trace.writeBinaryAt( 4, 0, 0, True, bVal);
// add signals trace.addScope(1, 0, "Other", "Scope Description"); trace.addSignal(2, 1, "a text", "Signal Description", Flx.TYPE_TEXT, null); trace.addSignal(4, 1, "a binary", "Signal Description", Flx.TYPE_BINARY, null); // open // values tVal = "val: " + /* valueOf */new String(n % 100).toString(); bVal[2] = ((n & 255)|0); // writes a text trace.writeTextAt(2, 0, current, false, tVal); // write bytes trace.writeBinaryAt(4, 0, 0, true, bVal);
// add signals trace.addScope(1, 0, "Other", "Scope Description"); trace.addSignal(2, 1, "a text", "Signal Description", Flx.TYPE_TEXT, null); trace.addSignal(4, 1, "a binary", "Signal Description", Flx.TYPE_BINARY, null); // open // values tVal = "val: " + /* valueOf */ new String(n % 100).toString(); bVal[2] = ((n & 255) | 0); // writes a text trace.writeTextAt(2, 0, current, false, tVal); // write bytes trace.writeBinaryAt(4, 0, 0, true, bVal);