F005 Text, enums and binary data

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.

Data types

  Event/Enumeration Text  Binary
Java
  • int
  • String
  •  byte[]
c
  • int
  • char*

+ size argument

  •  unsigned char*

+ size argument

Python
  • int
  • string
  •  bytearray
TypeScript
  • number
  • string
  •  array
JavaScript
  • number
  • string
  •  array

 

Writing enumeration data

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:

  • the trace object (c-language only),
  • 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.

The flxWriteEnumDef/writeEnumDef  methods shall be used after opening the trace.

The parameters for flxWriteEventAt/writeEventAt) are:

  • the trace object (c-language only),
  • itemId of the signal,
  • the tag flag (samples can have a tag, e.g. error),
  • domain position,
  • isRelative flag (1: relative, 0:absolute),
  • the integer value.
  • Java

            // 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);
    
    
  • C/C++

    		// 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);
    
  • Python

            # 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);
    
  • TypeScript

            // 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);
        
  • JavaScript

            // 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);
        

Writing textual and binary data

The writing of text and binary data is straightforward.

The parameters for flxWriteTextAt/writeTextAt and flxWriteBinaryAt/writeBinaryAt are:

  • the trace object (c-language only),
  • itemId of the signal,
  • the tag flag (samples can have a tag, e.g. error),
  • domain position,
  • isRelative flag (1: relative, 0:absolute),
  • the text or binary value,
  • the size (c-language only).
  • Java

            // 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);
    
  • C/C++

    		// 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);
    
  • Python

            # 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);
    
  • TypeScript

     		// 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);
        
  • JavaScript

         	// 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);
        
toem

technical software and tooling

Company

Contact Us

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