ecl_converters_lite Documentation

ecl_converters_lite

These are a very simple version of some of the functions in ecl_converters suitable for firmware development. That is, there is no use of new, templates or exceptions.

Introduction

Lightweight converter functions suitable for control firmware develompent.

Compiling & Linking

    Include the following at the top of any translation unit which
    requires this library:

    @code
    #include <ecl/converters_lite.hpp>

    // The converter functions
    using ecl::from_byte_array;
    @endcode

Since it is solely comprised of inline header functions, no linking is required if you are only using this class.

Usage

Byte Array Converters

These convert between integral types and character arrays. This is quite a common operation for control systems which are reading/writing to and from i/o character devices (e.g. serial port).

These functions do need some care as you're passing pointers which must be pointing to memory with at least the required number of bytes to do the conversion

ecl::int32 value;
char three_six_three[4] = { 0x6b, 0x01, 0x00, 0x00 };
ecl::from_byte_array(value,three_six_three);
std::cout << value << std::endl; // prints 363.
// ...also unsigned int/char variants.

Current List of Converters

The following are listed with the 'to' type on the left and 'from' types on the right.

  • int32 : byte array (char*, uchar*)
  • uint32 : byte array (char*, uchar*)

Unit Tests

    - src/test/byte_array.cpp

ChangeLog

    - <b>Nar 11</b> : added from_byte_array functions.
ecl::from_byte_array
void from_byte_array(int32 &value, const char *byte_array)
Converts an array of four char into a 32 bit integer.
Definition: byte_array.hpp:49


ecl_converters_lite
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:13:54