Skip to content

atolab/cscdr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NuGet License License

CSCDR

A DDS-CDR encoder/decoder library in C#.

CDR stands for the O.M.G.'s Common Data Representation that is used in DDS (Data Distributed Service) implementations. It's specified by https://www.omg.org/spec/DDSI-RTPS/2.3/PDF (chapter 10) and https://www.omg.org/cgi-bin/doc?formal/02-06-51.

In the current version, this library only handles the basic types. It doesn't include an IDL compiler generating C# encoder/decoder for complex types.

Usage

Assuming a DDS type is defined with the following IDL:

module HelloWorldData
{
  struct Msg
  {
    long userID;
    string message;
  };
  #pragma keylist Msg userID
};

The code to encode such type will be:

HelloWorldData.Msg m = new HelloWorldData.Msg();
m.userId = 1;
m.message = "Hello World!";

CDRWriter writer = new CDRWriter();
writer.WriteInt32(m.userId);
writer.WriteString(m.message);

byte[] encodedBuffer = writer.GetBuffer().ToArray();

The code to decode such type will be:

byte[] encodedBuffer = ...;

CDRReader reader = new CDRReader(encodedBuffer);
HelloWorldData.Msg m = new HelloWorldData.Msg();
m.userId = reader.ReadInt32();
m.message = reader.ReadString();

About

A C# DDS-CDR serializer/deserializer

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages