Code Monkey home page Code Monkey logo

libmisb0601's Introduction

MISB0601 library

C library to encode and decode MISB STD 0601.

Encode

Usage :

#include "packet.h"

// Initialize packet (add mandatories KLVs)
struct Packet *packet = initialize_packet();

// Instantiate values with union
char *name = "MISSION01";
struct GenericValue mission_value = {CHAR_P, .charp_value = name};
float slant_range = 823.20;
struct GenericValue range_value = {FLOAT, .float_value = slant_range};

// Add KLVs into packet
packet = add_klv(packet, FieldMap[MISSION], mission_value);
packet = add_klv(packet, FieldMap[SLANT_RANGE], range_value);

// Finalize packet by adding checksum and total length
finalize_packet(packet);

// We can then access data with `packet->content` and `packet->size`

Decode

Usage :

#include "unpack.h"

// Initialize the map that will hold the KLVs
struct KLVMap *klvmap = malloc(sizeof(struct KLVMap));

// Trying to unpack the misb, check header to see error code
if (unpack_misb(data, size, klvmap))
  fprintf(stderr, "Error unpacking the packet : %d\n", res);

// Iterating over the map to retrieve KLVs
for (int i = 0; i < 94; i++)
{
  if (klvmap->KLVs[i])
    printf("Tag %d - Size %ld\n", klvmap->KLVs[i]->tag, klvmap->KLVs[i]->size);
}

// Or access wanted klv directly
struct KLV timestamp_klv = klvmap[UNIX_TIME_STAMP];

// Don't forget to free klvs when you are done
free(klvmap);

Standard Documentation

libmisb0601's People

Contributors

n1tsu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.