-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from timrulebosch/main
Add example for the new Stream Interface.
- Loading branch information
Showing
8 changed files
with
378 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<!--- | ||
Copyright (c) 2022 for information on the respective copyright owner | ||
see the NOTICE file and/or the repository https://github.com/boschglobal/automotive-bus-schema | ||
SPDX-License-Identifier: Apache-2.0 | ||
--> | ||
|
||
|
||
# Example: Stream Interface - Frame Schema (with FlatBuffers) | ||
|
||
## Build the Toolchain Container Images | ||
|
||
> Note: This may take some time. | ||
|
||
```bash | ||
$ git clone https://github.com/boschglobal/automotive-bus-schema.git | ||
$ cd automotive-bus-schema | ||
$ make builders | ||
... | ||
$ docker images | ||
REPOSITORY TAG IMAGE ID CREATED SIZE | ||
python-builder latest a5ef73ea66dc 16 minutes ago 858MB | ||
flatc-builder latest f4bb83e2c0c9 18 minutes ago 324MB | ||
gcc-builder latest 7f15adf64b0a 5 seconds ago 620MB | ||
``` | ||
|
||
|
||
## Build and package the schemas | ||
|
||
```bash | ||
$ make | ||
... | ||
$ make dist | ||
Distribution package files: | ||
-------------------------- | ||
204K /vagrant/git/oss/automotive-bus-schema/dist/automotive-bus-schema.tar.gz | ||
36K /vagrant/git/oss/automotive-bus-schema/dist/python/dist/automotive_bus_schema-devel-py3-none-any.whl | ||
12K /vagrant/git/oss/automotive-bus-schema/dist/python/dist/automotive-bus-schema-devel.tar.gz | ||
``` | ||
|
||
|
||
## Build and run the example | ||
|
||
```bash | ||
$ cd examples/streams | ||
$ make | ||
... | ||
Sandbox files: - /tmp/repo/examples/streams/build/_out | ||
-------------- | ||
312K build/_out/bin/frames | ||
|
||
# Run the target executable. | ||
$ make run | ||
Process stream (length = 136) | ||
Sending Node UID is: 49 | ||
CAN Frame: | ||
frame_id = 42 | ||
payload = 66 6f 6f | ||
length = 3 | ||
frame_type = 0 | ||
bus_id = 1 | ||
node_id = 0 | ||
interface_id = 0 | ||
CAN Frame: | ||
frame_id = 24 | ||
payload = 62 61 72 | ||
length = 3 | ||
frame_type = 0 | ||
bus_id = 1 | ||
node_id = 0 | ||
interface_id = 0 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
FROM debian:bullseye-slim AS base | ||
|
||
|
||
# Setup basic GCC and CMAKE toolchains | ||
# ==================================== | ||
RUN apt-get -y update; \ | ||
apt-get -y upgrade; \ | ||
apt-get -y install --no-install-recommends \ | ||
autoconf \ | ||
automake \ | ||
binutils \ | ||
build-essential \ | ||
ca-certificates \ | ||
extra-cmake-modules \ | ||
curl \ | ||
gcc \ | ||
gcc-multilib \ | ||
g++ \ | ||
g++-multilib \ | ||
git \ | ||
jq \ | ||
less \ | ||
libtool \ | ||
make \ | ||
zip \ | ||
&& \ | ||
apt-get clean; \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
RUN curl -fSL https://github.com/Kitware/CMake/releases/download/v3.22.2/cmake-3.22.2-linux-x86_64.sh \ | ||
-o /tmp/cmake-install.sh \ | ||
&& chmod u+x /tmp/cmake-install.sh \ | ||
&& /tmp/cmake-install.sh --skip-license --prefix=/usr/local \ | ||
&& rm /tmp/cmake-install.sh | ||
|
||
|
||
|
||
# ========================= | ||
# Construct the final image | ||
# ========================= | ||
FROM base AS final | ||
|
||
# CMD ["/bin/bash", "-c", "tail /dev/null -f"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
cmake_minimum_required(VERSION 3.21) | ||
|
||
project(stream-frames-example) | ||
|
||
include(GNUInstallDirs) | ||
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/_out) | ||
|
||
set(CMAKE_C_STANDARD 99) | ||
set(CMAKE_C_STANDARD_REQUIRED TRUE) | ||
set(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||
set(CMAKE_BUILD_TYPE Debug) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -ggdb") | ||
list(APPEND C_CXX_WARNING_FLAGS | ||
-Wall | ||
-W | ||
-Wwrite-strings | ||
-Wno-missing-field-initializers | ||
-Wno-misleading-indentation | ||
) | ||
add_compile_options(${C_CXX_WARNING_FLAGS}) | ||
|
||
set(SCHEMAS_SOURCE_DIR ../../dist/automotive-bus-schema/flatbuffers/c) | ||
set(FLATCC_SOURCE_DIR ${SCHEMAS_SOURCE_DIR}/automotive_bus_schema/flatcc/src) | ||
set(FLATCC_INCLUDE_DIR ${SCHEMAS_SOURCE_DIR}/automotive_bus_schema/flatcc/include) | ||
|
||
|
||
add_executable(frames | ||
frames.c | ||
${FLATCC_SOURCE_DIR}/builder.c | ||
${FLATCC_SOURCE_DIR}/emitter.c | ||
${FLATCC_SOURCE_DIR}/refmap.c | ||
) | ||
target_include_directories(frames | ||
PRIVATE | ||
${SCHEMAS_SOURCE_DIR} | ||
${FLATCC_INCLUDE_DIR} | ||
) | ||
install(TARGETS frames) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright (C) 2022 Robert Bosch GmbH | ||
|
||
GCC_BUILDER_IMAGE ?= gcc-builder:latest | ||
|
||
ifneq ($(CI), true) | ||
DOCKER_BUILDER_CMD := docker run -it --rm \ | ||
--volume $$(pwd)/../..:/tmp/repo \ | ||
--workdir /tmp/repo/examples/streams \ | ||
$(GCC_BUILDER_IMAGE) | ||
endif | ||
|
||
.PHONY: build clean do-build run | ||
|
||
default: build | ||
|
||
build: | ||
@${DOCKER_BUILDER_CMD} $(MAKE) do-build | ||
|
||
do-build: | ||
# Build from scratch if no build dir. | ||
@if [ ! -d "build" ]; then \ | ||
mkdir -p build; \ | ||
cd build; \ | ||
cmake .. ; \ | ||
fi | ||
# Build incremental. | ||
cd build; make | ||
cd build; make install | ||
@echo "" | ||
@echo "Sandbox files: - $$(pwd)/build/_out" | ||
@echo "--------------" | ||
@find build/_out/ -type f -name '*' -exec ls -sh --color=auto {} \; | ||
|
||
run: | ||
@build/_out/bin/frames | ||
|
||
clean: | ||
rm -rf build |
Oops, something went wrong.