Skip to content

boschglobal/dse.ncodec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dynamic Simulation Environment - Network Codec Library

CI Super Linter GitHub

Introduction

Network Codec Library (NCodec) of the Dynamic Simulation Environment (DSE) Core Platform.

NCodec Simple Arch

Codecs: AB Codec
Integrations: DSE ModelC (trace code) / DSE FMI (esp. FMI 2) / DSE Network

Project Structure

dse.ncodec
└── doc/content             <-- Content for documentation systems
└── dse/ncodec
    └── codec/ab            <-- Automotive-Bus (AB) Codec implementation
        └── flexray/        <-- FlexRay Bus Model implementation
        └── flexray_pop/    <-- FlexRay Point-of-Presence Bus Model implementation
    └── interface
        └── frame.h         <-- Frame based message interface
        └── pdu.h           <-- PDU based message interface
    └── stream
        └── buffer.h        <-- Buffer stream implementation
    └── codec.c             <-- NCodec API implementation
    └── codec.h             <-- NCodec API headers
└── extra                   <-- Build infrastructure
└── licenses                <-- Third Party Licenses
└── tests                   <-- Unit and E2E tests

Usage

Code Sample

#include <dse/ncodec/codec.h>
#include <dse/ncodec/interface/pdu.h>
#define greeting "hello world"

void network_rxtx(NCODEC* nc) {
    /* Message RX. */
    while (1) {
        NCodecPdu pdu = {};
        if (ncodec_read(nc, &pdu) < 0) break;
        printf("(%u) message: %s", pdu.id, pdu.payload);
    }
    ncodec_truncate(nc); /* Clear the stream. */

    /* Message TX. */
    ncodec_write(nc, &(struct NCodecPdu){
        .id = 42,
        .payload = (uint8_t*)greeting,
        .payload_len = strlen(greeting) + 1,
        .transport_type = NCodecPduTransportTypeCan,
    });
    ncodec_flush(nc); /* Flush messages to the stream. */
}

More information about the NCodec API, including a complete example, is available in the Network Codec API Reference. Useful developer documentation relating to the DSE ModelC integration is available in the Developer Documentation.

CMake Build Integration

CMakeLists.txt

# Fetch the NCodec code.
include(FetchContent)
FetchContent_Declare(dse_ncodec
    URL                 $ENV{DSE_NCODEC_URL}
    SOURCE_SUBDIR       dse/ncodec
)
FetchContent_MakeAvailable(dse_ncodec)

# Define a build target using the AB Codec (from the DSE NCodec library).
add_library(some_lib)
target_include_directories(some_lib
    PRIVATE
        ${dse_ncodec_SOURCE_DIR}
)
target_link_libraries(some_lib
    PUBLIC
        ab-codec
)

Makefile

DSE_NCODEC_REPO ?= https://github.com/boschglobal/dse.ncodec
DSE_NCODEC_VERSION ?= 1.1.0
export DSE_NCODEC_URL ?= $(DSE_NCODEC_REPO)/archive/refs/tags/v$(DSE_NCODEC_VERSION).zip

.PHONY: build
build:
  $(MAKE) build-some_lib

Codecs

AB Codec

MIME type: application/x-automotive-bus; interface=stream;

Feature Matrix

PDU Interface Frame Interface
Header interface/pdu.h interface/frame.h
Stream stream/buffer.c1 stream/buffer.c1
Schema pdu.fbs frame.fbs
Bus Models supported -
MIME type type=pdu; schema=fbs type=frame; schema=fbs
Language Support C/C++
Go
Python
C/C++
Intergrations DSE ModelC
DSE FMI
DSE ModelC
DSE FMI
DSE Network

Network Support

Bus / Network PDU Interface Frame Interface
CAN
FlexRay -
IP (SomeIP/DoIP) -
LIN *2 -
PDU (Autosar Adaptive) -
Struct (C-Structs) -

MIME type - Frame Interface

Field Type Value (default) CAN
bus_id uint8_t 1.. ✓✓
node_id uint8_t 1.. ✓✓3
interface_id uint8_t 0..

Note

✓✓ indicates a required field. Other fields default to 0 or NULL.

MIME type - PDU Interface

Field Type Value CAN FlexRay IP PDU Struct
ecu_id uint8_t 04, 1.. ✓✓ ✓✓ ✓✓ ✓✓ ✓✓
cc_id uint8_t 0 |1 - - - -
swc_id uint8_t 0 .. 5 5 5 5
name string - - - -
model string flexray - ✓✓ - - -
mode string pop - - - -
pwr string on(default)|off|nc - - - -
vcn uint8_t 0,1,2 - - - -
poca uint8_t 1..96 - - - -
pocb uint8_t 1..96 - - - -

Note

✓✓ indicates a required field. Other fields default to 0 or NULL.

Build

# Get the repo.
$ git clone https://github.com/boschglobal/dse.ncodec.git
$ cd dse.ncodec

# Optionally set builder images.
$ export GCC_BUILDER_IMAGE=ghcr.io/boschglobal/dse-gcc-builder:main

# Build.
$ make

# Run tests.
$ make test

# Update source files (pull in changes).
$ make update

# Generate documentation.
$ make generate

# Remove (clean) temporary build artifacts.
$ make clean
$ make cleanall

Contribute

Please refer to the CONTRIBUTING.md file.

License

Dynamic Simulation Environment Network Codec Library is open-sourced under the Apache-2.0 license.

See the LICENSE and NOTICE files for details.

Third Party Licenses

Third Party Licenses

Footnotes

  1. Via FMI 2 String Variables using ASCII85 encoding (ascii85.c). 2

  2. LIN Support planned.

  3. Message filtering on node_id (i.e. filter if Tx Node = Rx Node) is only enabled when this parameter is set.

  4. A value of 0 may only configured for a Point of Presence (PoP) node (i.e. a Gateway model connecting a NCodec network to an external Virtual Bus).

  5. Message filtering on swc_id (i.e. filter if Tx Node = Rx Node) is only enabled when this parameter is set. 2 3 4

  6. Sets the initial POC State, e.g. 5 = NormalActive (see NCodecPduFlexrayPocState in interface/pdu.h for all POC states). Otherwise POC State is set by the FlexRay model according to its mode-of-operation. 2

About

Network Codec Library of the Dynamic Simulation Environment (DSE) Core Platform.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages