Skip to content

NDLCom/representations

Repository files navigation

representations

When electronic devices are communicating with each other, they need a common data representation to serialize and deserialize data. This libraray defines a set of messages as c-structs in a number of header files. Each distinct message is identified by the id contained in the first byte of a received binary blob, which is choosen before compile-time in names.c.

The provided information is used to generate three files:

  • A vhdl-mapping for PacketId -> Symbol, put into the folder "vhdl", located inside this repository
  • A header for mapping packet id to symbol, put inside the build-tree. Use pkg-config to retrieve the needed compiler-flags for in-source builds.
  • A common yaml-file containing all information from names.c in an easily readable format

Limit usage of advanced C language feature. Unions and bitfields are not a good idea.

Adding new types

Iff you really need a new package format.

  • Declare your new struct in a header here

    #ifndef REPRESENTATIONS_MYTYPE_H
    #define REPRESENTATIONS_MYTYPE_H
    
    #include "include/Representation.h"
    
    struct MyType {
        /** inheritance the c-way: */
        struct Representation mBase;
        /** your actual payload */
        float value;
    } __attribute__((packed));
    
    #ifdef __cplusplus
    namespace representations {
        struct Acceleration : public ::Acceleration {} __attribute__((packed));
    }
    #endif
    
    #endif
  • modify names.c to augment the database for later stages:

    diff --git a/src/names.c b/src/names.c
    index 931568b..d9c0d59 100644
    --- a/src/names.c
    +++ b/src/names.c
    @@ -145,6 +145,8 @@ static const struct RepresentationsNamesEntry representationsDatabase[] =
         
         {202, "ForwardDynamicsMessage", FIXED_PACKET_SIZE, "ForwardDynamicsMessage.h"},
         {203, "BackwardDynamicsMessage", FIXED_PACKET_SIZE, "BackwardDynamicsMessage.h"},
    +
    +    {230, "MyType", FIXED_PACKET_SIZE, "MyType.h"},
         
         // end-of-list
         {0,0,0,0}

represupport

Some packet types have common behaviour associated, so a set of helper functions can be provided to handle these. This is rather advanced, and intended to be combined with the "ndlcom" communication library. The packages in questions:

  • Ping
  • DebugMessage
  • RegisterValueWrite, RegisterValueQuery, RegisterDescriptionQuery
  • STOP, RESUME, RESET
  • RoutingTable (Note: no FPGA implementation yet)

History

DFKI

Developed at DKFI RIC Bremen during the iStruct and SeeGrip projects

About

Payload definitions for NDLCom (Registers, Ping, etc.)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors