Network Codec Library (NCodec) of the Dynamic Simulation Environment (DSE) Core Platform.
Codecs: AB Codec
Integrations:
DSE ModelC (trace code)
/ DSE FMI (esp. FMI 2)
/ DSE Network
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
#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.
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
MIME type: application/x-automotive-bus; interface=stream;
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 |
Bus / Network | PDU Interface | Frame Interface |
---|---|---|
CAN | ✓ | ✓ |
FlexRay | ✓ | - |
IP (SomeIP/DoIP) | ✓ | - |
LIN | *2 | - |
PDU (Autosar Adaptive) | ✓ | - |
Struct (C-Structs) | ✓ | - |
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
.
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
.
# 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
Please refer to the CONTRIBUTING.md file.
Dynamic Simulation Environment Network Codec Library is open-sourced under the Apache-2.0 license.
See the LICENSE and NOTICE files for details.
Footnotes
-
Via FMI 2 String Variables using ASCII85 encoding (ascii85.c). ↩ ↩2
-
LIN Support planned. ↩
-
Message filtering on
node_id
(i.e. filter if Tx Node = Rx Node) is only enabled when this parameter is set. ↩ -
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). ↩
-
Message filtering on
swc_id
(i.e. filter if Tx Node = Rx Node) is only enabled when this parameter is set. ↩ ↩2 ↩3 ↩4 -
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