LibMISB/LibMISB Introduction/ Functionalities supported: Difference between revisions

From RidgeRun Developer Wiki
No edit summary
No edit summary
Line 27: Line 27:
</syntaxhighlight>
</syntaxhighlight>


'''Example''':
'''Use case''':
<syntaxhighlight lang=C>
<syntaxhighlight lang=C>
   misb.SetDebuggerLever(MISB_DEBUG);
   misb.SetDebuggerLever(MISB_DEBUG);
Line 35: Line 35:
Sets the Formatter object to convert between format and metadata object. In other words, the user chooses which file format to use for both encoding and decoding actions.
Sets the Formatter object to convert between format and metadata object. In other words, the user chooses which file format to use for both encoding and decoding actions.


* Composition input format: To encode the input file, it must follow the following structure (an example will be shown using the JSON format).
* Composition input format: To encode the input file, it must follow the following structure (an use case will be shown using the JSON format).
<syntaxhighlight lang=json>
<syntaxhighlight lang=json>
{  
{  
Line 64: Line 64:
In which the formatter_number is dependent on formatter supported.  
In which the formatter_number is dependent on formatter supported.  


'''Example''':
'''Use case''':
<syntaxhighlight lang=C>
<syntaxhighlight lang=C>
   misb.SetFormatter(misb::formatter::JSON_FORMAT);
   misb.SetFormatter(misb::formatter::JSON_FORMAT);

Revision as of 15:19, 22 June 2022




Previous: LibMISB_Introduction/What_does_the_library_do Index Next: Getting_Started





LibMISB/Getting_Started

General

The functionalities of the library, regardless of the standard used, are as follows

Set Debugger Level

Sets the level at which messages will be logged. The method header is:

/**
   * @brief Sets the level for which the messages will be logged
   * The orders from less to most verbose modes are:
   *  MISB_NONE
   *  MISB_ERROR
   *  MISB_WARN
   *  MISB_INFO
   *  MISB_DEBUG
   *
   * @param level Level for messages to be logged
   */
  void SetDebuggerLever(LogLevel level);

Use case:

  misb.SetDebuggerLever(MISB_DEBUG);

Set Formatter

Sets the Formatter object to convert between format and metadata object. In other words, the user chooses which file format to use for both encoding and decoding actions.

  • Composition input format: To encode the input file, it must follow the following structure (an use case will be shown using the JSON format).
{ 
  "key": "<MISB KEY>",
  "items": [
    {
      "tag": "<TAG NUMBER>",
      "value": "<TAG VALUE>"
    }
  ]
}

Note: some tags are mandatories depending on the standard.

The method header is:

/**
   * @brief Set the Formatter object to convert between format to metadata
   * object and viceversa
   *
   * @param formatter Enum formatter that manages the format type that codec
   * will use
   */
  void SetFormatter(int formatter_number);

In which the formatter_number is dependent on formatter supported.

Use case:

  misb.SetFormatter(misb::formatter::JSON_FORMAT);

The misb::formatter::JSON_FORMAT parameter corresponds to an enum indicating which format type is to be implemented. At the moment, the enum is as follows:

enum Formats { JSON_FORMAT };


Encode

Performs the encoding of the metadata that was parsed by the Formatter. Encoding will depend on the MISB standard key found in the input file. The method header is:

/**
   * @brief Receive string metadata that will convert to KLV
   * bytes in MISB
   *
   * @param data String metadata that is in the formatter format valid
   * @return std::vector<unsigned char> Return KLV bytes in MISB but if there is
   * any internal problem will return empty vector
   */
  std::vector<unsigned char> Encode(std::string data);

Decode

Performs decoding of the metadata found in a KLV byte packet. The decoding will depend on the MISB standard key found in the packet. Once decoded, it will return the data according to the configured format type.



Previous: LibMISB_Introduction/What_does_the_library_do Index Next: Getting_Started