diff --git a/.github/actions/post-container-location/action.yml b/.github/actions/post-container-location/action.yml deleted file mode 100644 index 44436d73..00000000 --- a/.github/actions/post-container-location/action.yml +++ /dev/null @@ -1,44 +0,0 @@ -# /******************************************************************************** -# * Copyright (c) 2023 Contributors to the Eclipse Foundation -# * -# * See the NOTICE file(s) distributed with this work for additional -# * information regarding copyright ownership. -# * -# * This program and the accompanying materials are made available under the -# * terms of the Apache License 2.0 which is available at -# * http://www.apache.org/licenses/LICENSE-2.0 -# * -# * SPDX-License-Identifier: Apache-2.0 -# ********************************************************************************/ - -name: Post container location -description: Post snippet to pull and run test container - -inputs: - image: - required: true - type: string - description: The OCI image - - docker-run-args: - required: false - type: string - description: Optional docker run arguments - - message: - required: false - type: string - description: Optional message to log - -runs: - using: "composite" - steps: - - shell: bash - run: | - echo "## :rocket: New image is pushed" >> $GITHUB_STEP_SUMMARY - echo -e "\nImage for testing temporarily available at \`${{ inputs.image }}\`" >> $GITHUB_STEP_SUMMARY - echo -e "\n\`\`\`\ndocker pull ${{ inputs.image }}\n\`\`\`" >> $GITHUB_STEP_SUMMARY - echo -e "\n\`\`\`\ndocker run ${{ inputs.docker-run-args }} ${{ inputs.image }}\n\`\`\`" >> $GITHUB_STEP_SUMMARY - if [ -n "${{ inputs.message }}" ]; then - echo -e "\n${{ inputs.message }}" >> $GITHUB_STEP_SUMMARY - fi \ No newline at end of file diff --git a/.github/workflows/kuksa_csv_provider.yml b/.github/workflows/kuksa_csv_provider.yml deleted file mode 100644 index 68e24fda..00000000 --- a/.github/workflows/kuksa_csv_provider.yml +++ /dev/null @@ -1,124 +0,0 @@ -# /******************************************************************************** -# * Copyright (c) 2022,2023 Contributors to the Eclipse Foundation -# * -# * See the NOTICE file(s) distributed with this work for additional -# * information regarding copyright ownership. -# * -# * This program and the accompanying materials are made available under the -# * terms of the Apache License 2.0 which is available at -# * http://www.apache.org/licenses/LICENSE-2.0 -# * -# * SPDX-License-Identifier: Apache-2.0 -# ********************************************************************************/ - -name: kuksa_csv_provider - -on: - push: - branches: [ main ] - pull_request: - paths: - - ".github/workflows/kuksa_csv_provider.yml" - - ".github/actions/post-container-location/action.yml" - - "csv_provider/**" - workflow_dispatch: - -concurrency: - group: ${{ github.ref }}-${{ github.workflow }} - cancel-in-progress: true - -jobs: - check_ghcr_push: - uses: eclipse-kuksa/kuksa-actions/.github/workflows/check_ghcr_push.yml@2 - secrets: inherit - - run-csv-provider-tests: - name: "Run csv provider linter" - runs-on: ubuntu-latest - - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - - name: Run pylint (but accept errors for now) - run: | - cd csv_provider - pip3 install --no-cache-dir -r requirements.txt - pip3 install --no-cache-dir pylint - # First just show, never fail - pylint --exit-zero provider.py - # Fail on errors and above - pylint -E provider.py - - build-csv-provider-image: - name: "Build csv provider image" - runs-on: ubuntu-latest - needs: check_ghcr_push - - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - # list of Docker images to use as base name for tags - images: | - ghcr.io/eclipse/kuksa.val.feeders/csv-provider - # generate Docker tags based on the following events/attributes - tags: | - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Log in to the Container registry - if: needs.check_ghcr_push.outputs.push == 'true' - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build CSV provider container and push to ghcr.io (and ttl.sh) - id: ghcr-build - if: needs.check_ghcr_push.outputs.push == 'true' - uses: docker/build-push-action@v3 - with: - platforms: | - linux/amd64 - linux/arm64 - file: ./csv_provider/Dockerfile - context: ./csv_provider/ - push: true - tags: | - ${{ steps.meta.outputs.tags }} - ttl.sh/kuksa.val/kuksa-csvprovider-${{github.sha}} - labels: ${{ steps.meta.outputs.labels }} - - - name: Build ephemeral CSV provider container and push to ttl.sh - if: needs.check_ghcr_push.outputs.push == 'false' - id: tmp-build - uses: docker/build-push-action@v3 - with: - platforms: | - linux/amd64 - linux/arm64 - file: ./csv_provider/Dockerfile - context: ./csv_provider/ - push: true - tags: "ttl.sh/kuksa.val/kuksa-csvprovider-${{github.sha}}" - labels: ${{ steps.meta.outputs.labels }} - - - name: Posting message - uses: ./.github/actions/post-container-location - with: - image: ttl.sh/kuksa.val/kuksa-csvprovider-${{github.sha}} diff --git a/.github/workflows/someip2val_build.yml b/.github/workflows/someip2val_build.yml deleted file mode 100644 index c7013957..00000000 --- a/.github/workflows/someip2val_build.yml +++ /dev/null @@ -1,161 +0,0 @@ -# /******************************************************************************** -# * Copyright (c) 2022 Contributors to the Eclipse Foundation -# * -# * See the NOTICE file(s) distributed with this work for additional -# * information regarding copyright ownership. -# * -# * This program and the accompanying materials are made available under the -# * terms of the Apache License 2.0 which is available at -# * http://www.apache.org/licenses/LICENSE-2.0 -# * -# * SPDX-License-Identifier: Apache-2.0 -# ********************************************************************************/ - -name: someip2val-build - -on: - push: - branches: [ main ] - pull_request: - paths: - - ".github/workflows/someip2val_build.yml" - - "someip2val/**" - workflow_dispatch: - inputs: - build_binaries: - description: 'Build Binaries' - required: false - default: 'false' - -concurrency: - group: ${{ github.ref }}-${{ github.workflow }} - cancel-in-progress: true - -jobs: - - check_ghcr_push: - uses: eclipse-kuksa/kuksa-actions/.github/workflows/check_ghcr_push.yml@2 - secrets: inherit - - build: - name: Build Binaries - # build if explicitly requested or merging to main - if: ${{ github.event.inputs.build_binaries == 'true' || (needs.check_ghcr_push.outputs.push == 'true') }} - # reduce runtime requirements from ubuntu, ubuntu-18.04 fails for aarch64 - runs-on: ubuntu-20.04 - needs: check_ghcr_push - strategy: - matrix: - target-arch: [x86_64, aarch64] - fail-fast: true - - steps: - - name: Install Pre-requisities - run: | - sudo apt-get update -qqy && \ - sudo apt-get install -qqy --no-install-recommends \ - cmake g++ build-essential \ - g++-aarch64-linux-gnu binutils-aarch64-linux-gnu \ - jq python3 python3-pip python3-setuptools && - pip3 install conan==1.55.0 - - - name: Checkout - uses: actions/checkout@v3 - - - name: Run build - working-directory: ${{github.workspace}}/someip2val - run: ./build-release.sh ${{ matrix.target-arch }} - - - name: Upload Binaries - uses: actions/upload-artifact@v3 - with: - name: someip2val_${{ matrix.target-arch }}_release - path: | - ${{github.workspace}}/someip2val/target/${{ matrix.target-arch }}/release/install/bin - ${{github.workspace}}/someip2val/target/${{ matrix.target-arch }}/release/install/lib/libvsomeip*.so.3 - if-no-files-found: error - - build_docker: - # reduce runtime requirements from ubuntu, ubuntu-18.04 fails for aarch64 - runs-on: ubuntu-20.04 - name: Build Docker - needs: check_ghcr_push - - steps: - - - name: Check Setup - env: - OUT_GHCR_PUSH: ${{ needs.check_ghcr_push.outputs.push }} - OUT_USER_NAME: ${{ github.repository_owner }} - OUT_EVENT_NAME: ${{ github.event_name }} - run: | - echo - echo "### ghcr_push : $OUT_GHCR_PUSH" - echo "### username : $OUT_USER_NAME" - echo "### event_name : $OUT_EVENT_NAME" - echo - - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Log in to the Container registry - uses: docker/login-action@v2 - if: needs.check_ghcr_push.outputs.push == 'true' - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: | - ghcr.io/${{ github.repository }}/someip-feeder - tags: | - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - - - name: "Build someip2val container and push to ghcr.io" - if: needs.check_ghcr_push.outputs.push == 'true' - id: image_build_ghcr - uses: docker/build-push-action@v4 - with: - pull: false - push: true - file: ./someip2val/Dockerfile - context: "./someip2val" - platforms: linux/amd64, linux/arm64 - tags: | - ${{ steps.meta.outputs.tags }} - ttl.sh/kuksa.val.feeders/someip-feeder-${{github.sha}} - labels: ${{ steps.meta.outputs.labels }} - # Provenance to solve that an unknown/unkown image is shown on ghcr.io - # Same problem as described in https://github.com/orgs/community/discussions/45969 - provenance: false - - - name: "Build someip2val container and push to ttl.sh" - if: needs.check_ghcr_push.outputs.push == 'false' - id: image_build_ttl - uses: docker/build-push-action@v4 - with: - pull: false - push: true - file: ./someip2val/Dockerfile - context: "./someip2val" - platforms: linux/amd64, linux/arm64 - tags: | - ttl.sh/kuksa.val.feeders/someip-feeder-${{github.sha}} - labels: ${{ steps.meta.outputs.labels }} - # Provenance to solve that an unknown/unkown image is shown on ghcr.io - # Same problem as described in https://github.com/orgs/community/discussions/45969 - provenance: false diff --git a/README.md b/README.md index 32dc1d97..5dda039b 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,21 @@ -# Kuksa Feeders +# Kuksa Feeders and Providers ![kuksa.val Logo](./doc/img/logo.png) -This are data feeders for VSS based systems. The feeders here work with [KUKSA.val](https://github.com/eclipse/kuksa.val) +*Note: This is a legacy repository. Most providers has been moved to new repositories!* + Name | Description ---- | ----------- -[GPS Provider](https://github.com/eclipse-kuksa/kuksa-gps-provider) | GPS data source for KUKSA.val Server and KUKSA.val Databroker *- NOTE: Moved to new repo!* -[CAN Provider (DBC feeder)](https://github.com/eclipse-kuksa/kuksa-can-provider) | DBC feeder for for KUKSA.val Server and KUKSA.val Databroker *- NOTE: Moved to new repo!* -[SOME/IP feeder](./someip2val) | SOME/IP feeder for KUKSA.val Databroker -[DDS Provider](https://github.com/eclipse-kuksa/kuksa-dds-provider) | DDS provider for KUKSA.val Databroker *- NOTE: Moved to new repo!* -[Replay](./replay) | KUKSA.val Server replay script for previously recorded files, created by providing KUKSA.val Server with `--record` argument -[CSV provider](./csv_provider) | Script to replay VSS signals to KUKSA.val Databroker as defined in a CSV-file +[Replay](./replay) |[KUKSA Server](https://github.com/eclipse/kuksa.val/tree/master/kuksa-val-server) replay script for previously recorded files, created by running KUKSA Server with `--record` argument + +## Providers moved to new repositories + + +* [GPS Provider](https://github.com/eclipse-kuksa/kuksa-gps-provider) +* [CAN Provider (DBC feeder)](https://github.com/eclipse-kuksa/kuksa-can-provider) +* [SOME/IP Provider](https://github.com/eclipse-kuksa/kuksa-someip-provider) +* [DDS Provider](https://github.com/eclipse-kuksa/kuksa-dds-provider) +* [CSV Provider](https://github.com/eclipse-kuksa/kuksa-csv-provider) ## Pre-commit set up This repository is set up to use [pre-commit](https://pre-commit.com/) hooks. diff --git a/csv_provider/Dockerfile b/csv_provider/Dockerfile deleted file mode 100644 index f3c25d1c..00000000 --- a/csv_provider/Dockerfile +++ /dev/null @@ -1,65 +0,0 @@ -# /******************************************************************************** -# * Copyright (c) 2023 Contributors to the Eclipse Foundation -# * -# * See the NOTICE file(s) distributed with this work for additional -# * information regarding copyright ownership. -# * -# * This program and the accompanying materials are made available under the -# * terms of the Apache License 2.0 which is available at -# * http://www.apache.org/licenses/LICENSE-2.0 -# * -# * SPDX-License-Identifier: Apache-2.0 -# ********************************************************************************/ - - -# Build stage, to create a Virtual Environent -FROM --platform=$TARGETPLATFORM python:3.10-slim-bookworm as builder - -ARG TARGETPLATFORM -ARG BUILDPLATFORM - -RUN echo "-- Running on $BUILDPLATFORM, building for $TARGETPLATFORM" - -RUN apt update && apt -yy install binutils git - -RUN pip install --upgrade --no-cache-dir pip build pyinstaller - -COPY requirements.txt / - -RUN pip3 install --no-cache-dir -r requirements.txt - -# Copy "all" files first when dependencies have been installed to reuse -# cached layers as much as possible - -COPY . / - -RUN pyinstaller --clean -F -s provider.py - -WORKDIR /dist - -WORKDIR /data -COPY ./signals.csv ./signals.csv - -# Runner stage, to copy in the virtual environment and the app -# Debian 12 is bookworm, so the glibc version matches. Distroless is a lot smaller than -# Debian slim versions -# For development add :debug like this -# FROM gcr.io/distroless/base-debian12:debug to get a busybox shell as well -FROM gcr.io/distroless/base-debian12 - -WORKDIR /dist - -COPY --from=builder /dist/* . -COPY --from=builder /data/ ./ - -# pyinstaller doesn't pick up transient libz dependency, so copying it manually -COPY --from=builder /usr/lib/*-linux-gnu/libz.so.1 /lib/ - -ENV PATH="/dist:$PATH" - -# useful dumps about feeding values -ENV LOG_LEVEL="info" - -ENV PYTHONUNBUFFERED=yes - -ENTRYPOINT ["./provider"] diff --git a/csv_provider/README.md b/csv_provider/README.md deleted file mode 100644 index 3fd02f82..00000000 --- a/csv_provider/README.md +++ /dev/null @@ -1,82 +0,0 @@ -# VSS Provider -The aim of this script is to provide and replay VSS data into a `KUKSA.val` databroker. -Therefore, it takes a CSV-file, containting pre-defined sequences of VSS signals including timing delays, and provides it to the `KUKSA.val` databroker. - -## Usage -The provider requires an installation of Python in version 3 and can be executed with the following commands: - -``` -pip install -r requirements.txt -python3 provider.py -``` - -This assumes a running `KUKSA.val` databroker at `127.0.0.1:55555` and a file named `signals.csv` containing the signals to apply. See the section [Arguments](#arguments) for more details on possible arguments and default values. - -The provider uses the [kuksa_client]() Python implementation which you need to install on your system, e.g., by applying the [requirement.txt](requirements.txt) with pip. - -## Arguments -You can start the provider with the following arguments on a command line: - -| short argument | long argument | environment variable | description | default value | -|---- | ---- | ---- |----- | ----| -|-f| --file | PROVIDER_SIGNALS_FILE | This indicates the CSV-file containing the signals to update in the `KUKSA.val` databroker. | signals.csv | -| -a | --address | KUKSA_DATA_BROKER_ADDR | This indicates the address of `KUKSA.val` databroker to connect to. | 127.0.0.1 | -| -p | --port | KUKSA_DATA_BROKER_PORT | This indicates the port of the `KUKSA.val` databroker to connect to. | 55555 | -| -i | --infinite | PROVIDER_INFINITE | If the flag is set, the provider loops over the file until stopped, otherwise the file gets processed once. | not present/False -| -l | --log | PROVIDER_LOG_LEVEL | This sets the logging level. Possible values are: DEBUG, INFO, DEBUG, WARNING, ERROR, CRITICAL | WARNING -| | --cacertificate | - | Path to root CA. If defined the client will attempt to use a secure connection and identify the server using this certificate. | None -| | --tls-server-name | - | TLS server name, may be needed if addressing a server by IP-name. | None - -## CSV File -An example CSV-files is available in [signals.csv](signals.csv) where an example line is: - -``` -current,Vehicle.Speed,48,1 -``` - -The delimiter for the CSV-file is the ',' sign. The first line is interpreted as header and not as data. - -Each line in the csv file consists of the following elements: - -| header | description | example | -| -- | -----------| --| -| field | indicates whether to update the current value (`current`) or the target value (`target`) for the signal. | current | -| signal | the name of the signal to update | Vehicle.Speed -| value | the new value | 48 | -| delay | Indicates the time in seconds which the provider shall wait after processing this signal. This way one can emulate the change of signals over time. | 0 | - -## TLS - -If connecting to a KUKSA.val Databroker that require a secure connection you must specify which root certificate to -use to identify the Server by the `--cacertificate` argument. If your (test) setup use the KUKSA.val example -certificates you must give [CA.pem](https://github.com/eclipse/kuksa.val/blob/master/kuksa_certificates/CA.pem) -as root CA. The server name must match the name in the certificate provided by KUKSA.val databroker. -Due to a limitation in the gRPC client, if connecting by IP-address you may need to give a name listed in the certificate -by the `--tls-server-name` argument. The example server certificate lists the names `Server` and `localhost`, -so one of those names needs to be specified if connecting to `127.0.0.1`. An example is shown below: - -``` -python provider.py --cacertificate /home/user/kuksa.val/kuksa_certificates/CA.pem --tls-server-name Server -``` - -## Limitations - -* CSV Provider does not support authentication, i.e. it is impossible to communicate with a Databroker that require authentication! -## Recorder -One way to generate a CSV-file for the CSV-provider is to record it from an KUKSA.val databroker. This way one can reproduce an interaction of different providers with the KUKSA.val databroker. The script in `csv_provider/recorder.py` allows this recording. -An example call, only recording the vehicle speed and width would be: - -``` -pip install -r requirements.txt -python3 recorder.py -s Vehicle.Speed Vehicle.Width -``` - -The recorder supports the following paramters: - -| short argument | long argument | description | default value | -|---- | ---- | ----- | ----| -|-f| --file | This indicates the filename to which to write the VSS-signals. | signalsOut.csv | -|-s| --signals | A list of signals to record. | There is no default value, but the argument is required.| | -| -a | --address | This indicates the address of `KUKSA.val` databroker to connect to. | 127.0.0.1 | -| -p | --port | This indicates the port of the `KUKSA.val` databroker to connect to. | 55555 | -| -l | --log | This sets the logging level. Possible values are: DEBUG, INFO, WARNING, ERROR, CRITICAL | INFO diff --git a/csv_provider/provider.py b/csv_provider/provider.py deleted file mode 100755 index 9536d12d..00000000 --- a/csv_provider/provider.py +++ /dev/null @@ -1,136 +0,0 @@ -#! /usr/bin/env python3 - -######################################################################## -# Copyright (c) 2023 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -######################################################################## -'''A provider accepting VSS-signals from a CSV-file - to write these signals into an Kuksa.val data broker''' - -import asyncio -import csv -import argparse -import logging -import os -from pathlib import Path - -from kuksa_client.grpc import Datapoint -from kuksa_client.grpc import DataEntry -from kuksa_client.grpc import EntryUpdate -from kuksa_client.grpc import Field -from kuksa_client.grpc import VSSClientError -from kuksa_client.grpc.aio import VSSClient - - -def init_argparse() -> argparse.ArgumentParser: - '''This inits the argument parser for the CSV-provider.''' - parser = argparse.ArgumentParser( - usage="-a [BROKER ADDRESS] -p [BROKER PORT] -f [FILE]", - description="This provider writes the content of a csv file to a kuksa.val databroker", - ) - environment = os.environ - parser.add_argument("-a", "--address", default=environment.get("KUKSA_DATA_BROKER_ADDR", - "127.0.0.1"), - help="This indicates the address of the kuksa.val databroker to connect to." - " The default value is 127.0.0.1") - parser.add_argument("-p", "--port", default=environment.get('KUKSA_DATA_BROKER_PORT', "55555"), - help="This indicates the port of the kuksa.val databroker to connect to." - " The default value is 55555", type=int) - parser.add_argument("-f", "--file", default=environment.get("PROVIDER_SIGNALS_FILE", - "signals.csv"), - help="This indicates the csv file containing the signals to update in" - " the kuksa.val databroker. The default value is signals.csv.") - parser.add_argument("-i", "--infinite", default=environment.get("PROVIDER_INFINITE"), - action=argparse.BooleanOptionalAction, - help="If the flag is set, the provider loops" - "the file until stopped, otherwise the file gets processed once.") - parser.add_argument("-l", "--log", default=environment.get("PROVIDER_LOG_LEVEL", "INFO"), - help="This sets the logging level. The default value is WARNING.", - choices={"INFO", "DEBUG", "WARNING", "ERROR", "CRITICAL"}) - parser.add_argument("--cacertificate", - help="Specify the path to your CA.pem. If used provider will connect using TLS", - nargs='?', default=None) - parser.add_argument("--tls-server-name", - help="TLS server name, may be needed if addressing a server by IP-name", - nargs='?', default=None) - return parser - - -async def main(): - '''the main function as entry point for the CSV-provider''' - parser = init_argparse() - args = parser.parse_args() - numeric_value = getattr(logging, args.log.upper(), None) - if args.cacertificate: - root_path = Path(args.cacertificate) - else: - root_path = None - if isinstance(numeric_value, int): - logging.basicConfig(encoding='utf-8', level=numeric_value) - - logging.warning("CSV Provider has migrated to a new repository") - logging.info("Consider using CSV provider in https://github.com/eclipse-kuksa/kuksa-csv-provider instead") - - try: - async with VSSClient(args.address, args.port, root_certificates=root_path, - tls_server_name=args.tls_server_name) as client: - csvfile = open(args.file, newline='', encoding="utf-8") - signal_reader = csv.DictReader(csvfile, - delimiter=',', - quotechar='|', - skipinitialspace=True) - logging.info("Starting to apply the signals read from %s.", str(csvfile.name)) - if args.infinite: - backup = list(signal_reader) - while True: - rows = backup - backup = list(rows) - await process_rows(client, rows) - else: - await process_rows(client, signal_reader) - except VSSClientError: - logging.error("Could not connect to the kuksa.val databroker at %s:%s." - " Make sure to set the correct connection details using --address and --port" - " and that the kuksa.val databroker is running.", args.address, args.port) - - -async def process_rows(client, rows): - '''Processes a single row from the CSV-file and write the - recorded signal to the data broker through the client.''' - for row in rows: - if row['field'] == "current": - entry = DataEntry( - row['signal'], - value=Datapoint(value=row['value']), - ) - updates = (EntryUpdate(entry, (Field.VALUE,)),) - logging.info("Update current value of %s to %s", row['signal'], row['value']) - elif row['field'] == "target": - entry = DataEntry( - row['signal'], - actuator_target=Datapoint(value=row['value']) - ) - updates = (EntryUpdate(entry, (Field.ACTUATOR_TARGET,)),) - logging.info("Update target value of %s to %s", row['signal'], row['value']) - else: - updates = [] - try: - await client.set(updates=updates) - except VSSClientError as ex: - logging.error("Error while updating %s\n%s", row['signal'], ex) - try: - await asyncio.sleep(delay=float(row['delay'])) - except ValueError: - logging.error("Error while waiting for %s seconds after updating %s to %s." - " Make sure to only use numbers for the delay value.", - row['delay'], row['signal'], row['value']) - -asyncio.run(main()) diff --git a/csv_provider/recorder.py b/csv_provider/recorder.py deleted file mode 100644 index 826139b2..00000000 --- a/csv_provider/recorder.py +++ /dev/null @@ -1,96 +0,0 @@ -#! /usr/bin/env python3 - -######################################################################## -# Copyright (c) 2023 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -######################################################################## -'''A recording writing signals from an instance of the KUKSA.val databroker - to a CSV-file''' -import argparse -import asyncio -import csv -import logging -import time - -from kuksa_client.grpc.aio import VSSClient -from kuksa_client.grpc import VSSClientError -from kuksa_client.grpc import View -from kuksa_client.grpc import SubscribeEntry - -from kuksa_client.grpc import Field - - -def init_argparse() -> argparse.ArgumentParser: - '''This inits the argument parser for the CSV-recorder.''' - parser = argparse.ArgumentParser( - usage="-a [BROKER ADDRESS] -p [BROKER PORT] -f [FILE] -s [SIGNALS] -l [LOGGING LEVEL]", - description="This provider writes the content of a csv file to a KUKSA.val databroker") - parser.add_argument("-a", "--address", default="127.0.0.1", help="This indicates the address" - " of the KUKSA.val databroker to connect to." - " The default value is 127.0.0.1") - parser.add_argument("-p", "--port", default="55555", help="This indicates the port" - " of the KUKSA.val databroker to connect to." - " The default value is 55555", type=int) - parser.add_argument("-f", "--file", default="signalsOut.csv", help="This indicates the csv file" - " to write the signals to." - " The default value is signals.csv.") - parser.add_argument("-s", "--signals", help="A list of signals to" - " record", nargs='+', required=True) - parser.add_argument("-l", "--log", default="INFO", help="This sets the logging level." - " The default value is WARNING.", - choices={"INFO", "DEBUG", "WARNING", "ERROR", "CRITICAL"}) - return parser - - -async def main(): - '''entrypoint to the CSV-recorder''' - args = init_argparse().parse_args() - numeric_value = getattr(logging, args.log.upper(), None) - if isinstance(numeric_value, int): - logging.basicConfig(encoding='utf-8', level=numeric_value) - try: - async with VSSClient(args.address, args.port) as client: - csvfile = open(args.file, 'w', newline='', encoding="utf-8") - signalwriter = csv.DictWriter(csvfile, ['field', 'signal', 'value', 'delay']) - signalwriter.writeheader() - previous_time = time.time() - initial_value = True - entries = [] - for signal in args.signals: - entries.append(SubscribeEntry(signal, - View.FIELDS, - (Field.VALUE, Field.ACTUATOR_TARGET))) - async for updates in client.subscribe(entries=entries): - if initial_value: - time_gap = 0.0 - initial_value = False - else: - current_time = time.time() - time_gap = current_time - previous_time - previous_time = current_time - for update in updates: - entry = update.entry - if entry.value is not None: - signalwriter.writerow({'field': 'current', - 'signal': entry.path, - 'value': entry.value.value, - 'delay': time_gap}) - if entry.actuator_target is not None: - signalwriter.writerow({'field': 'target', - 'signal': entry.path, - 'value': entry.actuator_target.value, - 'delay': time_gap}) - except VSSClientError as error: - logging.error("There was a problem in the interaction" - " with the KUKSA.val databroker at %s:%s: %s ", - args.address, args.port, str(error)) - -asyncio.run(main()) diff --git a/csv_provider/requirements.txt b/csv_provider/requirements.txt deleted file mode 100644 index c834e3f8..00000000 --- a/csv_provider/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -# If pre-releases (e.g. X.YaN) are specified you must use --pre when installing -kuksa-client ~= 0.4.1 diff --git a/csv_provider/signals.csv b/csv_provider/signals.csv deleted file mode 100644 index e5e2a27c..00000000 --- a/csv_provider/signals.csv +++ /dev/null @@ -1,6 +0,0 @@ -field,signal,value,delay -target,Vehicle.Chassis.ParkingBrake.IsEngaged,false,0 -current,Vehicle.Chassis.ParkingBrake.IsEngaged,true,0 -current,Vehicle.Speed,27,1.5 -current,Vehicle.Speed,48,0.5 -current,Vehicle.Speed,24,0.5 diff --git a/someip2val/.dockerignore b/someip2val/.dockerignore deleted file mode 100644 index 21d4b220..00000000 --- a/someip2val/.dockerignore +++ /dev/null @@ -1,9 +0,0 @@ -build -target -k3d -docker -**/*.a -**/*.cmake -**/*.pc -*.tar -*.tar.gz \ No newline at end of file diff --git a/someip2val/.gitignore b/someip2val/.gitignore deleted file mode 100644 index d8f1c123..00000000 --- a/someip2val/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -build/ -assets/ -target/ -.vscode -*.tar.gz \ No newline at end of file diff --git a/someip2val/CMakeLists.txt b/someip2val/CMakeLists.txt deleted file mode 100644 index cfb43438..00000000 --- a/someip2val/CMakeLists.txt +++ /dev/null @@ -1,108 +0,0 @@ -#******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -#*******************************************************************************/ -cmake_minimum_required(VERSION 3.11) - -# Project -project(SomeIp2Val CXX) - -set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "If enabled, generates a compile_commands.json file") - -# use conan as dependency management -include(${CMAKE_BINARY_DIR}/conan_paths.cmake) - -########################################### -### vsomeip support as cmake dependency ### -########################################### - -# workaround for outdated cmake code in vsomeip handling Boost_VERSION -# include (FindBoost) -find_package(Boost 1.55 COMPONENTS system thread filesystem REQUIRED) -if(Boost_FOUND) - MESSAGE(NOTICE "Boost_VERSION: ${Boost_VERSION}") - if (NOT DEFINED Boost_VERSION_MACRO) - string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+)" BOOST_VERSION_MATCH ${Boost_VERSION}) - MATH(EXPR detected_boost_ver "${CMAKE_MATCH_1} * 100000 + ${CMAKE_MATCH_2} * 100 + ${CMAKE_MATCH_3}" ) - # set(Boost_VERSION_MACRO 107200) - set(Boost_VERSION_MACRO ${detected_boost_ver}) - MESSAGE(STATUS "Boost_VERSION_MACRO set to: ${Boost_VERSION_MACRO}") - endif() -else() - MESSAGE(WARNING "Boost was not found!") -endif() - -set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") - -# build vsomeip from sources, no connan support -include(FetchContent) - -# we want signal handling enabled for vsomeip... -# add_definitions(-DVSOMEIP_ENABLE_SIGNAL_HANDLING=1) - -set(FETCHCONTENT_QUIET "OFF") -MESSAGE(STATUS "FetchContent: patching from ${CMAKE_SOURCE_DIR}/patches/ ...") -FetchContent_Declare( - vsomeip3 - GIT_REPOSITORY https://github.com/COVESA/vsomeip.git - # GIT_TAG master - GIT_TAG 3.1.20.3 - PATCH_COMMAND git apply --reject --ignore-whitespace --verbose --stat --apply - "${CMAKE_SOURCE_DIR}/patches/000-cmake-reduce-gcc-warnings.patch" - "${CMAKE_SOURCE_DIR}/patches/001-vsomeip-logger-fixes.patch" - "${CMAKE_SOURCE_DIR}/patches/002-vsomeip-default-major-change.patch" || true - # don't fail if already patched... - GIT_SHALLOW ON - GIT_PROGRESS OFF -) -MESSAGE(STATUS "FetchContent: MakeAvailable(vsomeip3)...") -FetchContent_MakeAvailable(vsomeip3) - -# add sources after vsomeip3 is populated -add_subdirectory(src) - -### copy scripts from current source dir to current bin dir (useful for debuging from build dir) -if (SDV2VAL_COPY_RESOURCES) - configure_file(./bin/setup-someip2val.sh ${CMAKE_CURRENT_BINARY_DIR}/ COPYONLY) - configure_file(./bin/setup-someip2val-proxy.sh ${CMAKE_CURRENT_BINARY_DIR}/ COPYONLY) - configure_file(./bin/someip2val-docker.sh ${CMAKE_CURRENT_BINARY_DIR}/ COPYONLY) - configure_file(./bin/setup-wiper-service.sh ${CMAKE_CURRENT_BINARY_DIR}/ COPYONLY) - configure_file(./bin/setup-wiper-client.sh ${CMAKE_CURRENT_BINARY_DIR}/ COPYONLY) - configure_file(./bin/setup-wiper-client-proxy.sh ${CMAKE_CURRENT_BINARY_DIR}/ COPYONLY) - configure_file(./config/someip_wiper_service.json ${CMAKE_CURRENT_BINARY_DIR}/config/ COPYONLY) - configure_file(./config/someip_wiper_client.json ${CMAKE_CURRENT_BINARY_DIR}/config/ COPYONLY) - configure_file(./config/someip_wiper_client-proxy.json ${CMAKE_CURRENT_BINARY_DIR}/config/ COPYONLY) - configure_file(./config/someip_feeder.json ${CMAKE_CURRENT_BINARY_DIR}/config/ COPYONLY) - configure_file(./config/someip_feeder-proxy.json ${CMAKE_CURRENT_BINARY_DIR}/config/ COPYONLY) -endif() - -### -### install scripts and config -### -install(PROGRAMS - ./bin/someip2val-docker.sh - ./bin/setup-someip2val-proxy.sh - ./bin/setup-someip2val.sh - ./bin/setup-wiper-service.sh - ./bin/setup-wiper-client.sh - ./bin/setup-wiper-client-proxy.sh - ./bin/setup-wiper-service.sh - DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" -) - -install(FILES - ./config/someip_wiper_client.json - ./config/someip_wiper_client-proxy.json - ./config/someip_wiper_service.json - ./config/someip_feeder-proxy.json - ./config/someip_feeder.json - DESTINATION "${CMAKE_INSTALL_PREFIX}/bin/config" -) diff --git a/someip2val/Dockerfile b/someip2val/Dockerfile deleted file mode 100644 index a5bc1c5a..00000000 --- a/someip2val/Dockerfile +++ /dev/null @@ -1,54 +0,0 @@ -# /******************************************************************************** -# * Copyright (c) 2022 Contributors to the Eclipse Foundation -# * -# * See the NOTICE file(s) distributed with this work for additional -# * information regarding copyright ownership. -# * -# * This program and the accompanying materials are made available under the -# * terms of the Apache License 2.0 which is available at -# * http://www.apache.org/licenses/LICENSE-2.0 -# * -# * SPDX-License-Identifier: Apache-2.0 -# ********************************************************************************/ - -FROM --platform=$BUILDPLATFORM ubuntu:20.04 as builder - -ENV DEBIAN_FRONTEND="noninteractive" -RUN DEBIAN_FRONTEND=noninteractive apt-get update -y && \ - apt-get install -y git \ - cmake g++ build-essential g++-aarch64-linux-gnu \ - binutils-aarch64-linux-gnu jq python3 python3-pip - -RUN pip3 install conan==1.55.0 - -COPY . /src -WORKDIR /src - -ARG TARGETPLATFORM -RUN echo "Building for ${TARGETPLATFORM}" - -RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ - ./build-release.sh amd64; \ - elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ - ./build-release.sh aarch64; \ - else \ - echo "Unsupported platform: $TARGETPLATFORM"; exit 1; \ - fi -# RUN ./build-release.sh $TARGETPLATFORM - -FROM --platform=$TARGETPLATFORM ubuntu:20.04 as final -ARG TARGETARCH - -RUN DEBIAN_FRONTEND=noninteractive apt-get update -y && \ - apt-get install -y jq && \ - rm -rf /var/lib/apt/lists/* - -WORKDIR "/app/lib" -COPY --from=builder "/src/target/*/release/install/lib/*" "/app/lib" - -WORKDIR "/app/bin" -COPY --from=builder "/src/target/*/release/install/bin" "/app/bin" - -RUN find /app 1>&2 - -CMD [ "/app/bin/someip2val-docker.sh" ] diff --git a/someip2val/README.md b/someip2val/README.md deleted file mode 100644 index ff1b3ccb..00000000 --- a/someip2val/README.md +++ /dev/null @@ -1,182 +0,0 @@ -- [SOME/IP integration in Docker containers](#someip-integration-in-docker-containers) -- [SOME/IP to Kuksa.VAL Feeder](#someip-to-kuksaval-feeder) - - [Overview](#overview) - - [Module summary](#module-summary) - - [Setup Development environment](#setup-development-environment) - - [Prerequisites](#prerequisites) - - [Building someip2val](#building-someip2val) - - [Configuration](#configuration) - - [vsomeip specific Configuration](#vsomeip-specific-configuration) - - [Environment variables for vsomeip](#environment-variables-for-vsomeip) - - [Wiper configuration files](#wiper-configuration-files) - - [Config file modifications](#config-file-modifications) - - [Runing someip example and someip2val feeder](#runing-someip-example-and-someip2val-feeder) - - [Local mode (single host)](#local-mode-single-host) - - [UDP mode (2 hosts)](#udp-mode-2-hosts) - - [Extending someip2val feeder](#extending-someip2val-feeder) - - [Running someip2val with Authorization](#running-someip2val-with-authorization) - -# SOME/IP integration in Docker containers - -Running default vsomeip examples in containers is described in details [here](docker/README.md) - -# SOME/IP to Kuksa.VAL Feeder - -## Overview - -[SOME/IP](https://www.autosar.org/fileadmin/standards/R22-11/FO/AUTOSAR_PRS_SOMEIPProtocol.pdf) is an automotive communication protocol which supports remote procedure calls, event notifications, service discovery. SOME/IP messages are sent as TCP/UDP unicast/multicast packets, but it is also possible to use local (Unix) endpoints. - -SOME/IP feeder is [COVESA / vsomeip](https://github.com/COVESA/vsomeip/) application, that subscribes for specific "Wiper" SOME/IP Events, parses the payload and feeds values to KUKSA.VAL Databroker. It also provides an example "Wiper" SOME/IP request handling for setting wiper parameters. - -## Module summary -- [src/someip_feeder/](./src/someip_feeder/) is the main SOME/IP to KUKSA.VAL Databroker adapter. -- [src/lib/broker_feeder/](./src/lib/broker_feeder/) is provinding KUKSA.VAL Databroker integration. -- [src/lib/someip_client/](./src/lib/someip_client/) is provinding generic SOME/IP Client implementation (generic implementation, does not depend on wiper). -- [src/lib/wiper_poc/](./src/lib/wiper_poc/) is provinding wiper specific implementation (someip config, serialization, deserialization of events and data structures).\ -**NOTE**: Check [wiper_poc.h](src/lib/wiper_poc/wiper_poc.h) for SOME/IP Event definitions (`struct t_Event`), and SOME/IP Request (`struct t_WiperRequest`) -- [src/examples/wiper_service/wiper_server.cc](./src/examples/wiper_service/wiper_server.cc): an example SOME/IP Wiper Service for sending some serialized example Wiper events. -- [src/examples/wiper_service/wiper_client.cc](./src/examples/wiper_service/wiper_client.cc): an example SOME/IP Wiper Client for subscribing and parsing Wiper event payload and example Request/Response client for Wiper VSS service. -- [src/examples/wiper_service/wiper_sim.cc](./src/examples/wiper_service/wiper_sim.cc): an example simulation of a Wiper service. -- [patches/](./patches/): Contains vsomeip patches (master branch), that have not been pushed to upstream yet. - -## Setup Development environment - -### Prerequisites - -1. Install cmake and build requirements - ``` bash - sudo apt-get install -y cmake g++ build-essential g++-aarch64-linux-gnu binutils-aarch64-linux-gnu jq - ``` -1. Install and configure conan (if needed) - ``` bash - sudo apt-get install -y python3 python3-pip - pip3 install "conan==1.55" - ``` - **NOTE:** Sometimes latest conan recipe revisions are broken, but the local build succeeds using cached older revision. If build fails on CI local conan cache could be cleared to reproduce the error. Also latest recipes may require newer conan version. - ``` bash - rm -rf ~/.conan/data - pip3 install "conan==1.*" - ``` - Last known working revisions are hardcoded in [conanfile.txt](./conanfile.txt) [requires]. -1. Install [VS Code](https://code.visualstudio.com/download). To setup proper conan environment in vs code, launch vscode using: - ``` bash - ./vscode-conan.sh - ``` -1. Install and start recent KUKSA Databroker: - ``` bash - docker run --rm -it -p 55555:55555/tcp --name databroker ghcr.io/eclipse/kuksa.val/databroker:master - ``` - -### Building someip2val - -There are scripts for building release and debug versions of someip2val feeder, supporting `x86_64`, `aarch64` or `rpi` architectures: - -``` bash -cd someip2val -./build-release.sh -``` -**NOTE:** Use `rpi` when building on a Raspberry Pi. -Scripts generate `someip2val--.tar` archives. - -There is also a script for exporting OCI container images (or import them locally for testing): -``` -./docker-build.sh [OPTIONS] TARGETS - -Standalone build helper for someip-feeder container. - -OPTIONS: - -l, --local local docker import (does not export tar) - -v, --verbose enable plain docker output and disable cache - --help show help - -TARGETS: - x86_64|amd64, aarch64|amd64 Target arch to build for, if not set - defaults to multiarch -``` -**NOTE:** This script can't handle multi-arch images! - -## Configuration - -vsomeip requires a combination of json config file + environment variables - -### vsomeip specific Configuration - -vsomeip library uses a combination of environment variables and config json files that must be set correctly or binaries won't work. -You can test vsomeip services in a "local" mode (running on a single Linux host, using Unix sockets for communication) or in "normal" mode, where 2 different hosts are required (e.g. wiper service running on the 1st host and someip2val feeder running on the 2nd host). - -**NOTE:** Multicast config (`service-discovery`) for both services must be matching and multicast packages between the hosts must be enabled, also unicast messages between hosts must be possible (both hosts in the same network). - -#### Environment variables for vsomeip -- `VSOMEIP_CONFIGURATION`: path to vsomeip config json file. -- `VSOMEIP_APPLICATION_NAME`: vsomeip application name, must be consistent with json config file `.applications[].name` - -**NOTE**: Those variables are already set (and validated) in provided `./bin/setup-*.sh` scripts. - -#### Wiper configuration files -- Wiper Service Config: [config/someip_wiper_service.json](./config/someip_wiper_service.json) -- Wiper Client Config: [config/someip_wiper_client.json](./config/someip_wiper_client.json) -- Wiper Client Config (Proxy) [config/someip_wiper_client-proxy.json](./config/someip_wiper_client-proxy.json) -- Someip Feeder Config: [config/someip_feeder.json](./config/someip_feeder.json) -- Someip Feeder Config (Proxy): [config/someip_feeder-proxy.json](./config/someip_feeder-proxy.json) - -**NOTE**: With vsomeip it is not possible to have multiple routing applications running on the same host, so in Proxy setup, Wiper service is configured as routing app and Proxy clients are configured to route through Wiper Service. -In case two hosts (VMs) are available, Proxy configs are not needed, then one host should run the service and the other - client config. - -#### Config file modifications -In order to use non-proxy mode on 2 network hosts, you have to modify the `.unicast` address in vsomeip config file, unfortunately it does not support hostnames, so there are some helper scripts for setting up the environment and replacing hostnames with `jq` -- Environment setup for Wiper Service: [./bin/setup-wiper-service.sh](./bin/setup-wiper-service.sh) -- Environment setup for Wiper Client: [./bin/setup-someip2val.sh](./bin/setup-someip2val.sh) -- Environment setup for Wiper Client (Proxy): [./bin/setup-someip2val-proxy.sh](./bin/setup-someip2val-proxy.sh) - - -## Runing someip example and someip2val feeder - -Setup scripts in `./bin` are meant to run from install directory, e.g. -after executing `./build-debug.sh` it is: `target/x86_64/debug/install/bin`. - -If running from another location, make sure your `LD_LIBRARY_PATH` includes vsomeip3 binaries. -### Local mode (single host) -In this mode only Unix sockets are used, wiper service is acting as a someip router app and someip2val feeder is a proxy. - -- Launch wiper service from install directory: -``` bash -. ./setup-wiper-service.sh -./wiper_service --cycle 300 -``` -- Launch someip2val feeder in proxy mode: -``` bash -. ./setup-someip2val-proxy.sh -./someip_feeder -``` -### UDP mode (2 hosts) -In this mode you need another host in your network to run the service. - -- Launch wiper service from install directory on Host2: -``` bash -. ./setup-wiper-service.sh -./wiper_service --cycle 300 -``` -- Launch someip2val feeder in default mode: -``` bash -. ./setup-someip2val.sh -./someip_feeder -``` - -Make sure you have `jq` installed as it is rewriting config files to update unicast address. - -## Extending someip2val feeder - -Provided wiper example needs to be adjusted for another someip service events. - -- `SomeIPClient` class provides generic event subscription and passes someip payload to a custom callback: -``` c++ -typedef std::function < - int (vsomeip::service_t service, vsomeip::instance_t instance, vsomeip::method_t event, - const uint8_t *payload, size_t size) -> message_callback_t; -``` -- `SomeIPConfig` vsomeip service/instance/event_group/event values also have to be changed (e.g. via environment variables, or in code) -- `SomeipFeederAdapter::on_someip_message()` : Example for someip payload callback, deserializing payload and feeding to Databroker - -## Running someip2val with Authorization - -Authorization support and example setup is described [here](./cert/README.md). diff --git a/someip2val/bin/network-setup.sh b/someip2val/bin/network-setup.sh deleted file mode 100755 index 722b41bb..00000000 --- a/someip2val/bin/network-setup.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -#******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -#*******************************************************************************/ - -IF=$1 - -[ -z "$IF" ] && IF="eth0" - -sudo route add -net 224.0.0.0/4 dev "$IF" diff --git a/someip2val/bin/setup-someip2val-proxy.sh b/someip2val/bin/setup-someip2val-proxy.sh deleted file mode 100755 index 281c6389..00000000 --- a/someip2val/bin/setup-someip2val-proxy.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/bash - -#******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -#*******************************************************************************/ - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - -if [ -f "$SCRIPT_DIR/config/someip_feeder-proxy.json" ]; then - VSOMEIP_CONFIGURATION="$SCRIPT_DIR/config/someip_feeder-proxy.json" -else - GIT_ROOT=$(git rev-parse --show-toplevel) - if [ -n "$GIT_ROOT" ] && [ -f "$GIT_ROOT/someip2val/config/someip_feeder-proxy.json" ]; then - VSOMEIP_CONFIGURATION="$GIT_ROOT/someip2val/config/someip_feeder-proxy.json" - fi -fi -export VSOMEIP_CONFIGURATION - -export VSOMEIP_APPLICATION_NAME="someip_feeder" - -export SOMEIP_CLI_SERVICE="0x60D0" -export SOMEIP_CLI_INSTANCE="0x0001" -export SOMEIP_CLI_EVENTGROUP="0x0064" -export SOMEIP_CLI_EVENT="0x8001" -export SOMEIP_CLI_MAJOR=1 -export SOMEIP_CLI_MINOR=0 - -# request/response service -export SOMEIP_CLI_REQ=1 -export SOMEIP_CLI_REQ_SERVICE="0x6123" -export SOMEIP_CLI_REQ_INSTANCE="0x000b" -export SOMEIP_CLI_REQ_METHOD="0x0007" -export SOMEIP_CLI_REQ_MAJOR=1 -export SOMEIP_CLI_REQ_MINOR=0 - -# default debug levels -[ -z "$DBF_DEBUG" ] && export DBF_DEBUG=1 ### INFO -[ -z "$SOMEIP_CLI_DEBUG" ] && export SOMEIP_CLI_DEBUG=1 ### INFO - -echo - -if [ -z "$VSOMEIP_APPLICATION_NAME" ]; then - echo "WARNING! VSOMEIP_APPLICATION_NAME not set in environment!" -fi - -if [ ! -f "$VSOMEIP_CONFIGURATION" ]; then - echo "WARNING! Can't find VSOMEIP_CONFIGURATION: $VSOMEIP_CONFIGURATION" -else - echo "****************************" - echo "SOME/IP config: $VSOMEIP_CONFIGURATION" - ### Replace unicast address with Hostname -I (1st record) - if grep -q "unicast" "$VSOMEIP_CONFIGURATION"; then - MY_IP="$(hostname -I | cut -d ' ' -f 1)" - echo "### Replacing uinicast: $MY_IP in VSOMEIP_CONFIGURATION" - jq --arg ip "$MY_IP" '.unicast=$ip' "$VSOMEIP_CONFIGURATION" > "$VSOMEIP_CONFIGURATION.tmp" && mv "$VSOMEIP_CONFIGURATION.tmp" "$VSOMEIP_CONFIGURATION" - fi - ### Sanity checks for application name - CONFIG_APP=$(jq -r '.applications[0].name' "$VSOMEIP_CONFIGURATION") - ROUTING_APP=$(jq -r '.routing' "$VSOMEIP_CONFIGURATION") - UNICAST_APP=$(jq -r '.unicast' "$VSOMEIP_CONFIGURATION") - echo " json: { app_name: $CONFIG_APP, routinng: $ROUTING_APP, unicast: $UNICAST_APP }" - echo "****************************" - echo "" - - echo "****************************" - echo "SOME/IP Client enrironment" - echo "****************************" - env | grep SOMEIP_ | sort -r - echo "****************************" - - if [ "$CONFIG_APP" != "$VSOMEIP_APPLICATION_NAME" ]; then - echo "WARNING! $VSOMEIP_CONFIGURATION has application name: $CONFIG_APP, but VSOMEIP_APPLICATION_NAME is: $VSOMEIP_APPLICATION_NAME" - fi -fi - -# if running from install, export LD_LIBRARY_PATH to vsomeip libs. -[ -d "$SCRIPT_DIR/../lib" ] && export LD_LIBRARY_PATH="$SCRIPT_DIR/../lib:$LD_LIBRARY_PATH" - -echo -echo "Execute: ./someip_feeder" -echo diff --git a/someip2val/bin/setup-someip2val.sh b/someip2val/bin/setup-someip2val.sh deleted file mode 100755 index d00d1183..00000000 --- a/someip2val/bin/setup-someip2val.sh +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/bash - -#******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -#*******************************************************************************/ - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - -if [ -f "$SCRIPT_DIR/config/someip_feeder.json" ]; then - VSOMEIP_CONFIGURATION="$SCRIPT_DIR/config/someip_feeder.json" -else - GIT_ROOT=$(git rev-parse --show-toplevel) - if [ -n "$GIT_ROOT" ] && [ -f "$GIT_ROOT/someip2val/config/someip_feeder.json" ]; then - VSOMEIP_CONFIGURATION="$GIT_ROOT/someip2val/config/someip_feeder.json" - fi -fi -export VSOMEIP_CONFIGURATION - -export VSOMEIP_APPLICATION_NAME="someip_feeder" - -export SOMEIP_CLI_SERVICE="0x60D0" -export SOMEIP_CLI_INSTANCE="0x0001" -export SOMEIP_CLI_EVENTGROUP="0x0064" -export SOMEIP_CLI_EVENT="0x8001" -export SOMEIP_CLI_MAJOR=1 -export SOMEIP_CLI_MINOR=0 - -# request/response service -export SOMEIP_CLI_REQ=1 -export SOMEIP_CLI_REQ_SERVICE="0x6123" -export SOMEIP_CLI_REQ_INSTANCE="0x000b" -export SOMEIP_CLI_REQ_METHOD="0x0007" -export SOMEIP_CLI_REQ_MAJOR=1 -export SOMEIP_CLI_REQ_MINOR=0 - - -# default debug levels -[ -z "$DBF_DEBUG" ] && export DBF_DEBUG=1 ### INFO -[ -z "$SOMEIP_CLI_DEBUG" ] && export SOMEIP_CLI_DEBUG=1 ### INFO - -echo - -if [ -z "$VSOMEIP_APPLICATION_NAME" ]; then - echo "WARNING! VSOMEIP_APPLICATION_NAME not set in environment!" -fi - -if [ ! -f "$VSOMEIP_CONFIGURATION" ]; then - echo "WARNING! Can't find VSOMEIP_CONFIGURATION: $VSOMEIP_CONFIGURATION" -else - echo "****************************" - echo "SOME/IP config: $VSOMEIP_CONFIGURATION" - ### Replace unicast address with Hostname -I (1st record) - if grep -q "unicast" "$VSOMEIP_CONFIGURATION"; then - MY_IP="$(hostname -I | cut -d ' ' -f 1)" - echo "### Replacing uinicast: $MY_IP in VSOMEIP_CONFIGURATION" - jq --arg ip "$MY_IP" '.unicast=$ip' "$VSOMEIP_CONFIGURATION" > "$VSOMEIP_CONFIGURATION.tmp" && mv "$VSOMEIP_CONFIGURATION.tmp" "$VSOMEIP_CONFIGURATION" - fi - ### Sanity checks for application name - CONFIG_APP=$(jq -r '.applications[0].name' "$VSOMEIP_CONFIGURATION") - ROUTING_APP=$(jq -r '.routing' "$VSOMEIP_CONFIGURATION") - UNICAST_APP=$(jq -r '.unicast' "$VSOMEIP_CONFIGURATION") - echo " json: { app_name: $CONFIG_APP, routinng: $ROUTING_APP, unicast: $UNICAST_APP }" - echo "****************************" - echo "" - - echo "****************************" - echo "SOME/IP Client enrironment" - echo "****************************" - env | grep SOMEIP_ | sort -r - echo "****************************" - - if [ "$CONFIG_APP" != "$VSOMEIP_APPLICATION_NAME" ]; then - echo "WARNING! $VSOMEIP_CONFIGURATION has application name: $CONFIG_APP, but VSOMEIP_APPLICATION_NAME is: $VSOMEIP_APPLICATION_NAME" - fi -fi - -# if running from install, export LD_LIBRARY_PATH to vsomeip libs. -[ -d "$SCRIPT_DIR/../lib" ] && export LD_LIBRARY_PATH="$SCRIPT_DIR/../lib:$LD_LIBRARY_PATH" - -echo -echo "Execute: ./someip_feeder" -echo diff --git a/someip2val/bin/setup-wiper-client-proxy.sh b/someip2val/bin/setup-wiper-client-proxy.sh deleted file mode 100755 index ffb3ae14..00000000 --- a/someip2val/bin/setup-wiper-client-proxy.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash - -#******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -#*******************************************************************************/ - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - -export VSOMEIP_APPLICATION_NAME="wiper_client" - -CFG="someip_wiper_client-proxy.json" -if [ -f "$SCRIPT_DIR/config/$CFG" ]; then - VSOMEIP_CONFIGURATION="$SCRIPT_DIR/config/$CFG" -else - GIT_ROOT=$(git rev-parse --show-toplevel) - if [ -n "$GIT_ROOT" ] && [ -f "$GIT_ROOT/someip2val/config/$CFG" ]; then - VSOMEIP_CONFIGURATION="$GIT_ROOT/someip2val/config/$CFG" - fi -fi -export VSOMEIP_CONFIGURATION - -echo - -if [ -z "$VSOMEIP_APPLICATION_NAME" ]; then - echo "WARNING! VSOMEIP_APPLICATION_NAME not set in environment!" -fi - -if [ ! -f "$VSOMEIP_CONFIGURATION" ]; then - echo "WARNING! Can't find VSOMEIP_CONFIGURATION: $VSOMEIP_CONFIGURATION" -else - echo "****************************" - echo "SOME/IP config: $VSOMEIP_CONFIGURATION" - ### Replace unicast address with Hostname -I (1st record) - if grep -q "unicast" "$VSOMEIP_CONFIGURATION"; then - MY_IP="$(hostname -I | cut -d ' ' -f 1)" - echo "### Replacing uinicast: $MY_IP in VSOMEIP_CONFIGURATION" - jq --arg ip "$MY_IP" '.unicast=$ip' "$VSOMEIP_CONFIGURATION" > "$VSOMEIP_CONFIGURATION.tmp" && mv "$VSOMEIP_CONFIGURATION.tmp" "$VSOMEIP_CONFIGURATION" - fi - ### Sanity checks for application name - CONFIG_APP=$(jq -r '.applications[0].name' "$VSOMEIP_CONFIGURATION") - ROUTING_APP=$(jq -r '.routing' "$VSOMEIP_CONFIGURATION") - UNICAST_APP=$(jq -r '.unicast' "$VSOMEIP_CONFIGURATION") - echo " json: { app_name: $CONFIG_APP, routinng: $ROUTING_APP, unicast: $UNICAST_APP }" - echo "****************************" - echo "" - - echo "****************************" - echo "SOME/IP Client enrironment" - echo "****************************" - env | grep SOMEIP_ | sort -r - echo "****************************" - - if [ "$CONFIG_APP" != "$VSOMEIP_APPLICATION_NAME" ]; then - echo "WARNING! $VSOMEIP_CONFIGURATION has application name: $CONFIG_APP, but VSOMEIP_APPLICATION_NAME is: $VSOMEIP_APPLICATION_NAME" - fi -fi - -# if running from install, export LD_LIBRARY_PATH to vsomeip libs. -[ -d "$SCRIPT_DIR/../lib" ] && export LD_LIBRARY_PATH="$SCRIPT_DIR/../lib:$LD_LIBRARY_PATH" - -echo -echo "Execute: ./wiper_client --mode 2 --freq 40 --pos 110.0" -echo diff --git a/someip2val/bin/setup-wiper-client.sh b/someip2val/bin/setup-wiper-client.sh deleted file mode 100755 index 9f76f538..00000000 --- a/someip2val/bin/setup-wiper-client.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash - -#******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -#*******************************************************************************/ - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - -export VSOMEIP_APPLICATION_NAME="wiper_client" - -CFG="someip_wiper_client.json" -if [ -f "$SCRIPT_DIR/config/$CFG" ]; then - VSOMEIP_CONFIGURATION="$SCRIPT_DIR/config/$CFG" -else - GIT_ROOT=$(git rev-parse --show-toplevel) - if [ -n "$GIT_ROOT" ] && [ -f "$GIT_ROOT/someip2val/config/$CFG" ]; then - VSOMEIP_CONFIGURATION="$GIT_ROOT/someip2val/config/$CFG" - fi -fi -export VSOMEIP_CONFIGURATION - -echo - -if [ -z "$VSOMEIP_APPLICATION_NAME" ]; then - echo "WARNING! VSOMEIP_APPLICATION_NAME not set in environment!" -fi - -if [ ! -f "$VSOMEIP_CONFIGURATION" ]; then - echo "WARNING! Can't find VSOMEIP_CONFIGURATION: $VSOMEIP_CONFIGURATION" -else - echo "****************************" - echo "SOME/IP config: $VSOMEIP_CONFIGURATION" - ### Replace unicast address with Hostname -I (1st record) - if grep -q "unicast" "$VSOMEIP_CONFIGURATION"; then - MY_IP="$(hostname -I | cut -d ' ' -f 1)" - echo "### Replacing uinicast: $MY_IP in VSOMEIP_CONFIGURATION" - jq --arg ip "$MY_IP" '.unicast=$ip' "$VSOMEIP_CONFIGURATION" > "$VSOMEIP_CONFIGURATION.tmp" && mv "$VSOMEIP_CONFIGURATION.tmp" "$VSOMEIP_CONFIGURATION" - fi - ### Sanity checks for application name - CONFIG_APP=$(jq -r '.applications[0].name' "$VSOMEIP_CONFIGURATION") - ROUTING_APP=$(jq -r '.routing' "$VSOMEIP_CONFIGURATION") - UNICAST_APP=$(jq -r '.unicast' "$VSOMEIP_CONFIGURATION") - echo " json: { app_name: $CONFIG_APP, routinng: $ROUTING_APP, unicast: $UNICAST_APP }" - echo "****************************" - echo "" - - echo "****************************" - echo "SOME/IP Client enrironment" - echo "****************************" - env | grep SOMEIP_ | sort -r - echo "****************************" - - if [ "$CONFIG_APP" != "$VSOMEIP_APPLICATION_NAME" ]; then - echo "WARNING! $VSOMEIP_CONFIGURATION has application name: $CONFIG_APP, but VSOMEIP_APPLICATION_NAME is: $VSOMEIP_APPLICATION_NAME" - fi -fi - -# if running from install, export LD_LIBRARY_PATH to vsomeip libs. -[ -d "$SCRIPT_DIR/../lib" ] && export LD_LIBRARY_PATH="$SCRIPT_DIR/../lib:$LD_LIBRARY_PATH" - -echo -echo "Execute: ./wiper_client --mode 2 --freq 40 --pos 110.0" -echo diff --git a/someip2val/bin/setup-wiper-service.sh b/someip2val/bin/setup-wiper-service.sh deleted file mode 100755 index 8ad311a5..00000000 --- a/someip2val/bin/setup-wiper-service.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash - -#******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -#*******************************************************************************/ - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - -export VSOMEIP_APPLICATION_NAME="wiper_service" - -CFG="someip_wiper_service.json" -if [ -f "$SCRIPT_DIR/config/$CFG" ]; then - VSOMEIP_CONFIGURATION="$SCRIPT_DIR/config/$CFG" -else - GIT_ROOT=$(git rev-parse --show-toplevel) - if [ -n "$GIT_ROOT" ] && [ -f "$GIT_ROOT/someip2val/config/$CFG" ]; then - VSOMEIP_CONFIGURATION="$GIT_ROOT/someip2val/config/$CFG" - fi -fi -export VSOMEIP_CONFIGURATION - -if [ -z "$VSOMEIP_APPLICATION_NAME" ]; then - echo "WARNING! VSOMEIP_APPLICATION_NAME not set in environment!" -fi - -if [ ! -f "$VSOMEIP_CONFIGURATION" ]; then - echo "WARNING! Can't find VSOMEIP_CONFIGURATION: $VSOMEIP_CONFIGURATION" -else - echo "****************************" - echo "SOME/IP config: $VSOMEIP_CONFIGURATION" - ### Replace unicast address with Hostname -I (1st record) - if grep -q "unicast" "$VSOMEIP_CONFIGURATION"; then - MY_IP="$(hostname -I | cut -d ' ' -f 1)" - echo "### Replacing uinicast: $MY_IP in VSOMEIP_CONFIGURATION" - jq --arg ip "$MY_IP" '.unicast=$ip' "$VSOMEIP_CONFIGURATION" > "$VSOMEIP_CONFIGURATION.tmp" && mv "$VSOMEIP_CONFIGURATION.tmp" "$VSOMEIP_CONFIGURATION" - echo "****************************" - fi - ### Sanity checks for application name - CONFIG_APP=$(jq -r '.applications[0].name' "$VSOMEIP_CONFIGURATION") - ROUTING_APP=$(jq -r '.routing' "$VSOMEIP_CONFIGURATION") - UNICAST_APP=$(jq -r '.unicast' "$VSOMEIP_CONFIGURATION") - echo " json: { app_name: $CONFIG_APP, routinng: $ROUTING_APP, unicast: $UNICAST_APP }" - echo "****************************" - echo "" - - if [ "$CONFIG_APP" != "$VSOMEIP_APPLICATION_NAME" ]; then - echo "WARNING! $VSOMEIP_CONFIGURATION has application name: $CONFIG_APP, but VSOMEIP_APPLICATION_NAME is: $VSOMEIP_APPLICATION_NAME" - fi -fi - -# if running from install, export LD_LIBRARY_PATH to vsomeip libs. -[ -d "$SCRIPT_DIR/../lib" ] && export LD_LIBRARY_PATH="$SCRIPT_DIR/../lib:$LD_LIBRARY_PATH" - -echo -echo "Start SomeIP Service:" -echo " ./wiper_service" diff --git a/someip2val/bin/someip2val-docker.sh b/someip2val/bin/someip2val-docker.sh deleted file mode 100755 index 7f2a183a..00000000 --- a/someip2val/bin/someip2val-docker.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/bash - -#******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -#*******************************************************************************/ - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - -# allow customization of all environment variables from host - -if [ -z "$VSOMEIP_CONFIGURATION" ]; then - if [ -f "$SCRIPT_DIR/config/someip_feeder.json" ]; then - VSOMEIP_CONFIGURATION="$SCRIPT_DIR/config/someip_feeder.json" - else - if [ -f "/src/config/someip_feeder.json" ]; then - VSOMEIP_CONFIGURATION="/src/config/someip_feeder.json" - fi - fi - export VSOMEIP_CONFIGURATION -fi - -[ -z "$VSOMEIP_APPLICATION_NAME" ] && export VSOMEIP_APPLICATION_NAME="someip_feeder" - -[ -z "$SOMEIP_CLI_SERVICE" ] && export SOMEIP_CLI_SERVICE="0x60D0" -[ -z "$SOMEIP_CLI_INSTANCE" ] && export SOMEIP_CLI_INSTANCE="0x0001" -[ -z "$SOMEIP_CLI_EVENTGROUP" ] && export SOMEIP_CLI_EVENTGROUP="0x0064" -[ -z "$SOMEIP_CLI_EVENT" ] && export SOMEIP_CLI_EVENT="0x8001" -[ -z "$SOMEIP_CLI_MAJOR" ] && export SOMEIP_CLI_MAJOR=1 -[ -z "$SOMEIP_CLI_MINOR" ] && export SOMEIP_CLI_MINOR=0 - -# request/response service -[ -z "$SOMEIP_CLI_REQ" ] && export SOMEIP_CLI_REQ=1 -[ -z "$SOMEIP_CLI_REQ_SERVICE" ] && export SOMEIP_CLI_REQ_SERVICE="0x6123" -[ -z "$SOMEIP_CLI_REQ_INSTANCE" ] && export SOMEIP_CLI_REQ_INSTANCE="0x000b" -[ -z "$SOMEIP_CLI_REQ_METHOD" ] && export SOMEIP_CLI_REQ_METHOD="0x0007" -[ -z "$SOMEIP_CLI_REQ_MAJOR" ] && export SOMEIP_CLI_REQ_MAJOR=1 -[ -z "$SOMEIP_CLI_REQ_MINOR" ] && export SOMEIP_CLI_REQ_MINOR=0 - -if [ -z "$SOMEIP_CLI_UNICAST" ]; then - SOMEIP_CLI_UNICAST="$(hostname -I | cut -d ' ' -f 1)" -fi -echo "# Using unicast: $SOMEIP_CLI_UNICAST" - - -# default debug levels -[ -z "$DBF_DEBUG" ] && export DBF_DEBUG=1 ### INFO -[ -z "$SOMEIP_CLI_DEBUG" ] && export SOMEIP_CLI_DEBUG=1 ### INFO - -echo - -if [ -z "$VSOMEIP_APPLICATION_NAME" ]; then - echo "WARNING! VSOMEIP_APPLICATION_NAME not set in environment!" -fi - -if [ ! -f "$VSOMEIP_CONFIGURATION" ]; then - echo "WARNING! Can't find VSOMEIP_CONFIGURATION: $VSOMEIP_CONFIGURATION" -else - echo "****************************" - echo "SOME/IP config: $VSOMEIP_CONFIGURATION" - ### Replace unicast address with Hostname -I (1st record) - if grep -q "unicast" "$VSOMEIP_CONFIGURATION"; then - echo "### Replacing uinicast: $SOMEIP_CLI_UNICAST in VSOMEIP_CONFIGURATION" - jq --arg ip "$SOMEIP_CLI_UNICAST" '.unicast=$ip' "$VSOMEIP_CONFIGURATION" > "$VSOMEIP_CONFIGURATION.tmp" && mv "$VSOMEIP_CONFIGURATION.tmp" "$VSOMEIP_CONFIGURATION" - fi - ### Sanity checks for application name - CONFIG_APP=$(jq -r '.applications[0].name' "$VSOMEIP_CONFIGURATION") - ROUTING_APP=$(jq -r '.routing' "$VSOMEIP_CONFIGURATION") - UNICAST_APP=$(jq -r '.unicast' "$VSOMEIP_CONFIGURATION") - echo " json: { app_name: $CONFIG_APP, routinng: $ROUTING_APP, unicast: $UNICAST_APP }" - echo "****************************" - echo "" - - echo "****************************" - echo "SOME/IP Client enrironment" - echo "****************************" - env | grep SOMEIP_ | sort -r - echo "****************************" - - if [ "$CONFIG_APP" != "$VSOMEIP_APPLICATION_NAME" ]; then - echo "WARNING! $VSOMEIP_CONFIGURATION has application name: $CONFIG_APP, but VSOMEIP_APPLICATION_NAME is: $VSOMEIP_APPLICATION_NAME" - fi -fi - -# if running from install, export LD_LIBRARY_PATH to vsomeip libs. -[ -d "$SCRIPT_DIR/../lib" ] && export LD_LIBRARY_PATH="$SCRIPT_DIR/../lib:$LD_LIBRARY_PATH" - -./$VSOMEIP_APPLICATION_NAME diff --git a/someip2val/build-debug.sh b/someip2val/build-debug.sh deleted file mode 100755 index 62f58f11..00000000 --- a/someip2val/build-debug.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -#******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -#*******************************************************************************/ - -# Specify: -# first argument: TARGET_ARCH = "x86_64", "rpi" or "aarch64"; default: "x86_64". "rpi" is used for compiling on raspberry pi -# second argument: TARGET_ARCH = "; default: "$SCRIPT_DIR/target/$TARGET_ARCH/Debug" - -set -ex - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - -TARGET_ARCH="$1" -[ -z "$TARGET_ARCH" ] && TARGET_ARCH="x86_64" - -BUILD_DIR="$2" -[ -z "$BUILD_DIR" ] && BUILD_DIR="$SCRIPT_DIR"/target/"$TARGET_ARCH"/debug - -cmake -E make_directory "$BUILD_DIR" - -# install last known good boost version before conan v2 mess... -### experimental stuff -export CONAN_REVISIONS_ENABLED=1 - -echo "########## Conan Info #########" -conan --version -conan info . -echo "###############################" - -# build with dependencies of build_type Debug -conan install -if="$BUILD_DIR" --build=missing --profile:build=default --profile:host="${SCRIPT_DIR}/toolchains/target_${TARGET_ARCH}_Release" "$SCRIPT_DIR" -cd "$BUILD_DIR" || exit -# shellcheck disable=SC1091 -source activate.sh # Set environment variables for cross build - -if [ "$VERBOSE" = "1" ]; then - VERBOSE_OPT="-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCONAN_CMAKE_SILENT_OUTPUT=OFF -DFETCHCONTENT_QUIET=OFF" - VERBOSE_OPT="-LAH --debug-trace --debug-output $VERBOSE_OPT" -else - VERBOSE_OPT="-DCONAN_CMAKE_SILENT_OUTPUT=ON" -fi -cmake $VERBOSE_OPT "$SCRIPT_DIR" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="./install" - -sleep 1 -cmake --build . -j "$(nproc)" -cmake --install . - -DIST="$SCRIPT_DIR/someip2val_${TARGET_ARCH}_debug.tar.gz" -cd "$BUILD_DIR/install" || exit 1 -tar czvf "$DIST" bin/ lib/libvsomeip*.so* - -echo -echo "### Created dist: $DIST" -echo \ No newline at end of file diff --git a/someip2val/build-release.sh b/someip2val/build-release.sh deleted file mode 100755 index 218795f3..00000000 --- a/someip2val/build-release.sh +++ /dev/null @@ -1,109 +0,0 @@ -#!/bin/bash -#******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -#*******************************************************************************/ - -# Specify: -# first argument: TARGET_ARCH = "x86_64", "rpi" or "aarch64"; default: "x86_64". "rpi" is used for compiling on raspberry pi -# second argument: BUILD_DIR = "; default: "$SCRIPT_DIR/target/$TARGET_ARCH/release" - -# shellcheck disable=SC1091 -# shellcheck disable=SC2086 -# shellcheck disable=SC2046 -# shellcheck disable=SC2230 - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - -TARGET_ARCH="$1" -[ -z "$TARGET_ARCH" ] && TARGET_ARCH="x86_64" - -# handle "amd64" as alias for "x86_64" -[ "$TARGET_ARCH" == "amd64" ] && TARGET_ARCH="x86_64" - -BUILD_DIR="$2" -[ -z "$BUILD_DIR" ] && BUILD_DIR="$SCRIPT_DIR/target/$TARGET_ARCH/release" - -[ "$VERBOSE" = "1" ] && set -x -if [ "$FORCE" = "1" ]; then - export CONAN_OPT="$CONAN_OPT --build" -else - export CONAN_OPT="$CONAN_OPT --build=missing" -fi - -set -e -cmake -E make_directory "$BUILD_DIR" - -# install last known good boost version before conan v2 mess... -### experimental stuff -export CONAN_REVISIONS_ENABLED=1 - -echo "########## Conan Info #########" -conan --version -conan info . -echo "###############################" - -# conan install -r conancenter boost/1.72.0@#d9cf09c1be88fc9a3b8fbfef409e28e2 -pr:b=default -pr:h=default --update --build missing --build outdated - -conan install -if="$BUILD_DIR" $CONAN_OPT --profile:build=default --profile:host="${SCRIPT_DIR}/toolchains/target_${TARGET_ARCH}_Release" "$SCRIPT_DIR" -# conan install -if="$BUILD_DIR" --build=missing --profile:build=default --profile:host="${SCRIPT_DIR}/toolchains/target_${TARGET_ARCH}_Release" "$SCRIPT_DIR" - -cd "$BUILD_DIR" || exit 1 - -source ./activate.sh # Set environment variables for cross build - -#CMAKE_CXX_FLAGS_RELEASE="${CMAKE_CXX_FLAGS_RELEASE} -s" -if [ "$VERBOSE" = "1" ]; then - VERBOSE_OPT="-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCONAN_CMAKE_SILENT_OUTPUT=OFF -DFETCHCONTENT_QUIET=OFF" - VERBOSE_OPT="-LAH --debug-trace --debug-output $VERBOSE_OPT" -else - VERBOSE_OPT="-DCONAN_CMAKE_SILENT_OUTPUT=ON" -fi -cmake $VERBOSE_OPT -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="./install" "$SCRIPT_DIR" - -cmake --build . -j $(nproc) -cmake --install . -set +e +x - -# Ensure release is sripped -if [ "$TARGET_ARCH" = "aarch64" ]; then - STRIP="$(which aarch64-linux-gnu-strip)" -else - STRIP="strip" -fi - -echo -echo "### Check for stripped binaries" -BINARIES="./install/bin/someip_feeder ./install/bin/wiper_service ./install/bin/wiper_client ./install/lib/libvsome*.so*" -if [ -n "$STRIP" ]; then - echo "### Stripping binaries in: $(pwd)" - $STRIP -s --strip-unneeded $BINARIES - file $BINARIES - echo -fi - -echo "### library dependencies in: $(pwd)" -for f in $BINARIES; do - echo "\$ ldd $f" - if [ "$TARGET_ARCH" = "aarch64" ]; then - aarch64-linux-gnu-readelf -a "$f" | grep 'NEEDED\|RUNPATH' - else - ldd "$f" - fi -done - -DIST="$SCRIPT_DIR/someip2val_${TARGET_ARCH}_release.tar.gz" -cd "$BUILD_DIR/install" || exit 1 -tar czvf "$DIST" bin/ lib/libvsomeip*.so* - -echo -echo "### Created dist: $DIST" -echo diff --git a/someip2val/cert/.gitignore b/someip2val/cert/.gitignore deleted file mode 100644 index 98832aac..00000000 --- a/someip2val/cert/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -jwt.key -jwt.key.pub -createToken.py -requirements.txt diff --git a/someip2val/cert/README.md b/someip2val/cert/README.md deleted file mode 100644 index 9e40243a..00000000 --- a/someip2val/cert/README.md +++ /dev/null @@ -1,99 +0,0 @@ -# Authorization in KUKSA.val databroker - -More details on authorization in KUKSA.val can be found in [authorization.md](https://github.com/eclipse/kuksa.val/blob/master/doc/KUKSA.val_data_broker/authorization.md) - -## Get required keys/tools from KUKSA.val - -Some keys/tooling from KUKSA.val may be needed locally. -To get them, execute the following commands in someip2val/cert directory. - -```bash -# get KUKSA.val key: -curl -sOL https://github.com/eclipse/kuksa.val/raw/master/kuksa_certificates/jwt/jwt.key -curl -sOL https://github.com/eclipse/kuksa.val/raw/master/kuksa_certificates/jwt/jwt.key.pub -# get tooling for signing tokens (optional): -curl -sOL https://github.com/eclipse/kuksa.val/raw/master/kuksa_certificates/jwt/createToken.py -curl -sOL https://github.com/eclipse/kuksa.val/raw/master/kuksa_certificates/jwt/requirements.txt -curl -sOL https://github.com/eclipse/kuksa.val/raw/master/kuksa_certificates/jwt/recreateJWTkeyPair.sh -``` - -For more details check KUKSA.val JWT tooling [README](https://github.com/eclipse/kuksa.val/blob/master/kuksa_certificates/README.md#java-web-tokens-jwt) - -**NOTE:** Token examples there are not compatible with databroker, just check tools usage details. - -## Authorization support in someip2val - -someip2val authorizes to KUKSA.val using [someip2val.json](./someip2val.json). -It grants permission for registering datapoints, also provide and actuate datapoints on wiper relevant VSS paths. - -There is already signed [someip2val.token](./someip2val.token) by default KUKSA.val key. - -If you need to modify something in the payload, you can edit json file and then update the token with: - -```bash -./createToken.py someip2val.json -``` - -### Authorization example setup - -Described setup works with installed someip2val binaries, on a single host, using wiper-service example to simulate hardware wiper. - -- Run databroker (in new terminal) with mapped `/cert` volume containing KUKSA.val public key: - -```bash -docker run -it --rm --network host --name databroker \ - -v `$(git rev-parse --show-toplevel)/someip2val/cert`:/cert \ - ghcr.io/eclipse/kuksa.val/databroker:master --jwt-public-key /cert/jwt.key.pub -``` - -- Make sure someip2val is build and installed (`x86_64` arch is assumed): - -```bash -cd $(git rev-parse --show-toplevel)/someip2val -./build-release.sh -``` - -- Run SOME/IP wiper-service example (in new terminal): - -```bash -cd $(git rev-parse --show-toplevel)/someip2val/target/x86_64/release/install/bin -. setup-wiper-service.sh -./wiper-service --cycle 500 -``` - -- Run someip2val with its token (in new terminal): - -```bash -cd $(git rev-parse --show-toplevel)/someip2val/target/x86_64/release/install/bin -. setup-someip2val.sh -./someip_feeder --token $(git rev-parse --show-toplevel)/someip2val/cert/someip2val.token -``` - -**NOTE:** Wiper events can be verbose, to disable them `export WIPER_STATUS=0`, or use `export WIPER_STATUS=2` to make them on single line. - -- Test actuator subscriber with kuksa-client: - -```bash -# Use --pre if you rely on kuksa-client pre-releases -pip3 install -U kuksa-client - -GRPC_ENABLE_FORK_SUPPORT=true kuksa-client --ip 127.0.0.1 --port 55555 --protocol grpc --insecure --token_or_tokenfile $(git rev-parse --show-toplevel)/someip2val/cert/someip2val.token -``` - -- Set 3 required values to trigger someip request: - -```text -Test Client> setTargetValues Vehicle.Body.Windshield.Front.Wiping.System.Frequency=3 Vehicle.Body.Windshield.Front.Wiping.System.Mode=WIPE Vehicle.Body.Windshield.Front.Wiping.System.TargetPosition=100 -``` - -- Check someip_feeder dumps for the following lines: - -```text -# SomeipFeederAdapter::on_actuator_change: [info] updated target_values: 3 -# SomeipFeederAdapter::on_actuator_change: [info] Sending WiperReq: { mode:WIPE, freq:3, targetPos:100 } -... -# SomeIPClient::SendRequest: [info] ### Sending Request to [6123.000b.0007] with payload: 03 00 00 c8 42 02 -... -# SomeipFeederAdapter::on_someip_message: [info] Received Response from [6123.000b.0007], payload [00] - -``` diff --git a/someip2val/cert/someip2val.json b/someip2val/cert/someip2val.json deleted file mode 100644 index b0029cb0..00000000 --- a/someip2val/cert/someip2val.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "sub": "local dev", - "iss": "createToken.py", - "aud": [ - "kuksa.val" - ], - "iat": 1516239022, - "exp": 1767225599, - "scope": "create:Vehicle.Body.Windshield.Front.Wiping.System.* provide:Vehicle.Body.Windshield.Front.Wiping.System.* actuate:Vehicle.Body.Windshield.Front.Wiping.System.*" -} diff --git a/someip2val/cert/someip2val.token b/someip2val/cert/someip2val.token deleted file mode 100644 index 6b3d7b63..00000000 --- a/someip2val/cert/someip2val.token +++ /dev/null @@ -1 +0,0 @@ -eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJsb2NhbCBkZXYiLCJpc3MiOiJjcmVhdGVUb2tlbi5weSIsImF1ZCI6WyJrdWtzYS52YWwiXSwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE3NjcyMjU1OTksInNjb3BlIjoiY3JlYXRlOlZlaGljbGUuQm9keS5XaW5kc2hpZWxkLkZyb250LldpcGluZy5TeXN0ZW0uKiBwcm92aWRlOlZlaGljbGUuQm9keS5XaW5kc2hpZWxkLkZyb250LldpcGluZy5TeXN0ZW0uKiBhY3R1YXRlOlZlaGljbGUuQm9keS5XaW5kc2hpZWxkLkZyb250LldpcGluZy5TeXN0ZW0uKiJ9.5DyyBcS7lWropxsJVUD_CiD2IYSiXzBKFjwkBsqYPSrfS2kIRGbzeCo-8tFBA4a9DXm_R3u6gDqShV99LJA3kXJkYGDkA2rx9oGeI4riVaq1nDEsIQrgjekLuNHmvoMYX5g_GMtFGNuAWm9-bjLGlEPC0mGobPwbqIgrUTlSxGQy5dkFbKhzP6iTr1txZCqlyH2nusCxRHEkdN8R13ez5YC69buPVle4tbtwvlAe7FLu5H0cU4nKPVlIyVDOghkdqOd4dCiBX40Nni5q00Xs0sBAkJW2vzadorisFW5u6zj0oCk_QNlOLnlLDia2O6BRRz5pu9J0K4Kcsbk1mJt6mbT5ck3fLgB96KhxiIIxOrBYF6B63me2pyKRw_7uZ05n3yiM6U8e8GoyJtkvJ5UldeggcS8Z6d74uW5iyoxFybrWPYw9fZJmwgT0YrLyjzZnuBtQIDmSV2NCVtwJ_2_RFLRfaHnRWM2SBzE4jQrmSfCxJbfPU-wRbzap_G3r318hyo2NMca6-MT-piUXICQ4lztG08bkn0zSHFwCZYVKVXJQufUF_Zir0sHNBdQhKIMrzvsCOGorw1tlZmAPyl7dLLj4Wq0nseWO8Nl6y3QXOKNysq6Q7rZMHMGy1ymgvJ9ws90PfY16MfYIr5aejtPfWtKHKyuw2lC00-QergUkZ7I \ No newline at end of file diff --git a/someip2val/conanfile.txt b/someip2val/conanfile.txt deleted file mode 100644 index 3e1481e0..00000000 --- a/someip2val/conanfile.txt +++ /dev/null @@ -1,46 +0,0 @@ - -#******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -#*******************************************************************************/ - -[requires] -grpc/1.38.0@#a93eb68eaa39bd69ddb2c0d85e6eb490 -boost/1.72.0@#d9cf09c1be88fc9a3b8fbfef409e28e2 -zlib/1.2.13@#13c96f538b52e1600c40b88994de240f - -[build_requires] -grpc/1.38.0 # Is needed in the build context to run generate code from proto files -#zlib/1.2.12 - -[generators] -cmake_find_package -cmake_paths -virtualenv - -[options] -boost:shared=False - -grpc:fPIC=True -grpc:cpp_plugin=True -grpc:codegen=True - -# Follwing options do speed up cross build, but there is no prebuild package for this combination -#grpc:csharp_ext=False -#grpc:csharp_plugin=False -#grpc:node_plugin=False -#grpc:objective_c_plugin=False -#grpc:php_plugin=False -#grpc:python_plugin=False -#grpc:ruby_plugin=False - -[imports] -., license* -> ./licenses @ folder=True, ignore_case=True diff --git a/someip2val/config/someip_feeder-proxy.json b/someip2val/config/someip_feeder-proxy.json deleted file mode 100644 index 56c3729b..00000000 --- a/someip2val/config/someip_feeder-proxy.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "unicast": "127.0.0.1", - "netmask": "255.255.255.0", - "diagnosis": "0x1", - "logging": { - "level": "info", - "console": "true", - "file": { - "enable": "false", - "path": "/var/log/vsomeip.log" - }, - "dlt": "false", - "version": { - "enable": "false" - }, - "__status_log_interval": "30", - "__statistics": { - "interval": "30", - "min-frequency": "5", - "max-messages": "10" - } - }, - "applications": [ - { - "name": "someip_feeder", - "id": "0xC6F6" - } - ], - "clients": [ - { - "unreliable_client_ports": { - "first": "30491", - "last": "30491" - }, - "unreliable_remote_ports": { - "first": "30501", - "last": "30501" - } - }, - { - "service": "0x6123", - "instance": "0x000b", - "unreliable": "41234" - } - ], - "routing": "wiper_service", - "service-discovery": { - "enable": "true", - "multicast": "239.0.0.1", - "port": "30490", - "protocol": "udp" - } -} diff --git a/someip2val/config/someip_feeder.json b/someip2val/config/someip_feeder.json deleted file mode 100644 index 9241fed3..00000000 --- a/someip2val/config/someip_feeder.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "unicast": "127.0.0.1", - "netmask": "255.255.255.0", - "diagnosis": "0x1", - "logging": { - "level": "debug", - "console": "true", - "file": { - "enable": "false", - "path": "/var/log/vsomeip.log" - }, - "dlt": "false", - "version": { - "enable": "false" - }, - "__status_log_interval": "30", - "__statistics": { - "interval": "30", - "min-frequency": "5", - "max-messages": "10" - } - }, - "applications": [ - { - "name": "someip_feeder", - "id": "0xC6F6" - } - ], - "clients": [ - { - "unreliable_client_ports": { - "first": "30491", - "last": "30491" - }, - "unreliable_remote_ports": { - "first": "30501", - "last": "30501" - } - }, - { - "service": "0x6123", - "instance": "0x000b", - "unreliable": "41234" - } - ], - "routing": "someip_feeder", - "service-discovery": { - "enable": "true", - "multicast": "239.0.0.1", - "port": "30490", - "protocol": "udp" - } -} diff --git a/someip2val/config/someip_wiper_client-proxy.json b/someip2val/config/someip_wiper_client-proxy.json deleted file mode 100644 index dcfd304f..00000000 --- a/someip2val/config/someip_wiper_client-proxy.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "unicast": "127.0.0.1", - "netmask": "255.255.255.0", - "diagnosis": "0x1", - "logging": { - "level": "info", - "console": "true", - "file": { - "enable": "true", - "path": "./vsomeip.log" - }, - "dlt": "false", - "version": { - "enable": "false" - }, - "__status_log_interval": "30", - "__statistics": { - "interval": "30", - "min-frequency": "5", - "max-messages": "10" - } - }, - "applications": [ - { - "name": "wiper_client", - "id": "0xcfc7" - } - ], - "clients": [ - { - "unreliable_client_ports": { - "first": "30492", - "last": "30492" - }, - "unreliable_remote_ports": { - "first": "30501", - "last": "30501" - } - }, - { - "service": "0x6123", - "instance": "0x000b", - "unreliable": "41234" - } - ], - "routing": "wiper_service", - "service-discovery": { - "enable": "true", - "multicast": "239.0.0.1", - "port": "30490", - "protocol": "udp" - } -} diff --git a/someip2val/config/someip_wiper_client.json b/someip2val/config/someip_wiper_client.json deleted file mode 100644 index ef2c04f8..00000000 --- a/someip2val/config/someip_wiper_client.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "unicast": "127.0.0.1", - "netmask": "255.255.255.0", - "diagnosis": "0x1", - "logging": { - "level": "debug", - "console": "true", - "file": { "enable": "false", "path": "/var/log/vsomeip.log" }, - "dlt": "false", - "version": { "enable": "false" }, - "__status_log_interval": "30", - "__statistics": { - "interval": "30", - "min-frequency": "5", - "max-messages": "10" - } - }, - "applications": [ - { - "name": "wiper_client", - "id": "0xC6F6" - } - ], - "clients": [ - { - "unreliable_client_ports": { - "first": "30491", - "last": "30491" - }, - "unreliable_remote_ports": { - "first": "30501", - "last": "30501" - } - }, - { - "service": "0x6123", - "instance": "0x000b", - "unreliable": "41234" - } - ], - "routing": "wiper_client", - "service-discovery": { - "enable": "true", - "multicast": "239.0.0.1", - "port": "30490", - "protocol": "udp" - } -} diff --git a/someip2val/config/someip_wiper_service.json b/someip2val/config/someip_wiper_service.json deleted file mode 100644 index 2df1643c..00000000 --- a/someip2val/config/someip_wiper_service.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "unicast": "127.0.0.1", - "logging": { - "level": "debug", - "console": "true", - "file": { - "enable": "false", - "path": "/var/log/vsomeip.log" - }, - "dlt": "false", - "version": { - "enable": "false" - }, - "__status_log_interval": "30", - "__statistics": { - "interval": "60", - "min-frequency": "5", - "max-messages": "10" - } - }, - "applications": [ - { - "name": "wiper_service", - "id": "0x1278" - } - ], - "services": [ - { - "service": "0x60d0", - "instance": "0001", - "unreliable": "31000" - }, - { - "service": "0x6123", - "instance": "0x000b", - "unreliable": "31234" - } - ], - "routing": "wiper_service", - "service-discovery": { - "enable": "true", - "multicast": "239.0.0.1", - "port": "30490", - "protocol": "udp" - } -} diff --git a/someip2val/docker-build.sh b/someip2val/docker-build.sh deleted file mode 100755 index f03e51c4..00000000 --- a/someip2val/docker-build.sh +++ /dev/null @@ -1,146 +0,0 @@ -#!/bin/bash -#******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -#*******************************************************************************/ -# shellcheck disable=SC2181 -# shellcheck disable=SC2086 -# shellcheck disable=SC2230 - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -CONTEXT_DIR="$SCRIPT_DIR" -# name of docker image: ${DOCKER_ARCH)/${DOCKER_IMAGE} -DOCKER_IMAGE="someip-feeder" - - -print_usage() { - echo "USAGE: $0 [OPTIONS] TARGETS" - echo - echo "Standalone build helper for someip-feeder container." - echo - echo "OPTIONS:" - echo " -l, --local local docker import (does not export tar)" - echo " -v, --verbose enable plain docker output and disable cache" - echo " --help show help" - echo - echo "TARGETS:" - echo " x86_64|amd64, aarch64|amd64 Target arch to build for, if not set - defaults to multiarch" - echo -} - -LOCAL=0 -VERBOSE=0 -while [ $# -gt 0 ]; do - if [ "$1" = "--local" ] || [ "$1" = "-l" ]; then - LOCAL=1 - elif [ "$1" = "--verbose" ] || [ "$1" = "-v" ]; then - VERBOSE=1 - elif [ "$1" = "--help" ]; then - print_usage - exit 0 - else - TARGET="$1" - fi - shift -done - -target_arch() { - local target="$1" - case "$target" in - "x86_64" | "amd64" | "linux/amd64") - echo "amd64" - ;; - "arm64" | "aarch64" | "linux/arm64") - echo "arm64" - ;; - "armv6" | "arm" | "linux/arm") - echo "arm/v6" - ;; - "multiarch" | "") - echo "multiarch" - ;; - *) - return 1 - ;; - esac - return 0 -} - -build_release() { - local arch="$1" - - cd "$CONTEXT_DIR" || return 1 - echo "-- Building release for: $arch ..." - ./build-release.sh "$arch" - - echo "-- Building someip-feeder_${arch}_release.tar.gz ..." - - tar -czvf "someip-feeder_${arch}_release.tar.gz" \ - "target/${arch}/release/install/" \ - "target/${arch}/release/licenses/" \ - "proto/" - - echo "-- Checking [$arch] binaries: $(pwd)/target/${arch}/release/install/bin ..." - file "target/${arch}/release/install/bin/someip_feeder" \ - "target/${arch}/release/install/bin/wiper_service" \ - "target/${arch}/release/install/lib/libvsomeip3.so.3.1.20" -} - -if [ -z "$TARGET" ] && [ $LOCAL -eq 1 ]; then - echo "Multiarch archives are not supported for local builds, removing --local flag ..." - LOCAL=0 -fi - -set -e - -DOCKER_ARCH=$(target_arch "$TARGET") -DOCKER_EXPORT="./${DOCKER_ARCH//\//_}-${DOCKER_IMAGE}.tar" - -# NOTE: current Dockerfile is building from sources, could be optimized -if false; then - echo "-- Building ${DOCKER_IMAGE} container ..." - if [ "$DOCKER_ARCH" = "multiarch" ] || [ "$DOCKER_ARCH" = "amd64" ]; then - build_release x86_64 || exit 1 - fi - if [ "$DOCKER_ARCH" = "multiarch" ] || [ "$DOCKER_ARCH" = "arm64" ]; then - build_release aarch64 || exit 1 - fi -fi - -if [ "$DOCKER_ARCH" = "multiarch" ]; then - DOCKER_ARGS="--platform linux/amd64,linux/arm64 -t $DOCKER_ARCH/$DOCKER_IMAGE --output type=oci,dest=$DOCKER_EXPORT" -else - if [ $LOCAL -eq 1 ]; then - DOCKER_ARGS="--load -t $DOCKER_ARCH/$DOCKER_IMAGE" - DOCKER_EXPORT="($DOCKER_ARCH/$DOCKER_IMAGE ghcr.io/boschglobal/kuksa.val.feeders/$DOCKER_IMAGE:prerelease)" - else - DOCKER_ARGS="--platform linux/$DOCKER_ARCH -t $DOCKER_ARCH/$DOCKER_IMAGE --output type=oci,dest=$DOCKER_EXPORT" - fi -fi - -if [ "$VERBOSE" = "1" ]; then - DOCKER_ARGS="--no-cache --progress=plain $DOCKER_ARGS" -fi - -cd "$CONTEXT_DIR" || exit 1 -echo "# docker buildx build $DOCKER_ARGS -f ./Dockerfile $CONTEXT_DIR" -DOCKER_BUILDKIT=1 docker buildx build $DOCKER_ARGS -f ./Dockerfile "$CONTEXT_DIR" $DOCKER_EXT - -if [ $? -eq 0 ]; then - if [ $LOCAL -eq 1 ]; then - echo "docker image tag $DOCKER_ARCH/$DOCKER_IMAGE ghcr.io/eclipse/kuksa.val.services/$DOCKER_IMAGE:prerelease" - docker image tag $DOCKER_ARCH/$DOCKER_IMAGE ghcr.io/eclipse/kuksa.val.services/$DOCKER_IMAGE:prerelease - docker image ls | grep "/$DOCKER_IMAGE" - else - echo "# Exported $DOCKER_ARCH/$DOCKER_IMAGE in $DOCKER_EXPORT" - skopeo inspect --raw oci-archive:$DOCKER_EXPORT | jq . - fi -fi diff --git a/someip2val/docker/Dockerfile b/someip2val/docker/Dockerfile deleted file mode 100644 index 8275dcf3..00000000 --- a/someip2val/docker/Dockerfile +++ /dev/null @@ -1,93 +0,0 @@ -# /******************************************************************************** -# * Copyright (c) 2022 Contributors to the Eclipse Foundation -# * -# * See the NOTICE file(s) distributed with this work for additional -# * information regarding copyright ownership. -# * -# * This program and the accompanying materials are made available under the -# * terms of the Apache License 2.0 which is available at -# * http://www.apache.org/licenses/LICENSE-2.0 -# * -# * SPDX-License-Identifier: Apache-2.0 -# ********************************************************************************/ - -FROM --platform=$BUILDPLATFORM ubuntu:20.04 as builder - -ARG TARGETPLATFORM - -WORKDIR /workspace - -ENV DEBIAN_FRONTEND="noninteractive" -RUN DEBIAN_FRONTEND=noninteractive apt-get update -qqy && \ - apt-get --no-install-recommends install -qqy \ - build-essential pkg-config \ - git gcc g++ cmake \ - libboost-filesystem-dev libboost-thread-dev libboost-log-dev - -# checkout sources and dependencies -ENV GIT_SSL_NO_VERIFY=1 -RUN git clone https://github.com/COVESA/vsomeip.git - -# copy changes to vsomeip from current worktree -COPY vsomeip/. vsomeip/ -# make sure build dir is empty -RUN if [ -d /workspace/vsomeip/build/ ]; then rm -rf /workspace/vsomeip/build/; fi - -# RUN git clone --recurse-submodules -b v1.46.3 --depth 1 --shallow-submodules -c advice.detachedHead=false https://github.com/grpc/grpc - -RUN find vsomeip/ - -RUN mkdir vsomeip/build && cd vsomeip/build && \ - cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_SIGNAL_HANDLING=1 \ - -DCMAKE_INSTALL_PREFIX:PATH="/workspace/install" .. - # -DBASE_PATH=/tmp/vsomeip - -RUN cd vsomeip/build && make -j $(nproc) all install/strip -RUN cd vsomeip/build && make -j $(nproc) examples -## optional examples from vsomeip -# RUN cd vsomeip/build && make -j $(nproc) hello_world_service hello_world_client -RUN cd vsomeip/build && make -j $(nproc) tools vsomeip_ctrl routingmanagerd - -# RUN cd vsomeip/build/wiper_poc && make -j $(nproc) install - -FROM --platform=$TARGETPLATFORM ubuntu:20.04 as runtime - -LABEL org.opencontainers.image.description SOME/IP Kuksa.VAL feeder - -RUN apt-get -qqy update && apt-get install --no-install-recommends -qqy libboost-filesystem-dev libboost-thread-dev libboost-log-dev -# jq, ping might be required to update local config with proper ip addresses -RUN apt-get install -qqy --no-install-recommends jq net-tools iputils-ping - -## development helpers, to be removed in final image -# RUN apt-get install -qqy --no-install-recommends iproute2 iperf nano - -# reduce image size -RUN apt clean && rm -rf /var/lib/apt/lists/* - -# create base dir for vsomeip -WORKDIR /tmp/vsomeip -# enable volume mountpoint -WORKDIR /app/config -COPY --from=builder workspace/vsomeip/config/ /app/config/ - -WORKDIR /app/lib -COPY --from=builder /workspace/install/lib/. /app/lib/ - -WORKDIR /app/bin - -# RUN printf "alias lss='ls -la'\nalias ..='cd ..'\n" >> /root/.bashrc - -COPY --from=builder workspace/vsomeip/build/examples/*-sample /app/bin/ -COPY --from=builder workspace/vsomeip/build/tools/vsomeip_ctrl /app/bin/ -# COPY --from=builder workspace/vsomeip/build/wiper_poc/wiper-*-poc /app/bin/ -# COPY --from=builder workspace/vsomeip/wiper_poc/*.sh /app/bin/ -# COPY --from=builder workspace/vsomeip/build/wiper_poc/*.sh /app/bin/ -# COPY --from=builder workspace/vsomeip/examples/setup*.sh /app/bin/ -COPY --from=builder workspace/vsomeip/examples/run-*.sh /app/bin/ - - -# make sure vsomeip libs are in path -ENV LD_LIBRARY_PATH=/app/lib - -## configure as client by default -CMD [ "/app/bin/run-sample.sh" ] diff --git a/someip2val/docker/README.md b/someip2val/docker/README.md deleted file mode 100644 index b4483755..00000000 --- a/someip2val/docker/README.md +++ /dev/null @@ -1,157 +0,0 @@ -# SOME/IP integration in Docker containers - -SOME/IP provides service method (e.g. get/set) or event notifications. -For event notifications it is mandatory to have Service Discovery enabled on both client and the service (they should join the same multicast ip:port). -For service invocation it is also possible to disable Service Discovery, but both service and client definitions must be specified in both server and client config json files. - -## File Structure - -- [vsomeip](https://github.com/COVESA/vsomeip) is cloned in Dockerfile. -- `./vsomeip/examples`: contains changes to vsomeip examples copied over vsomeip files in Dockerfile. -- `./vsomeip/config`: has docker specific configuration files for notify-sample and subscribe-sample examples. -- `./docker-build.sh`: Useful for local building of the image (you may need to instal missing tools manually). -- `./docker-run-service.sh`: Script for running service (pub) container from vsomeip image. -- `./docker-run-client.sh`: Script for running client (sub) container from vsomeip image. - -## SOME/IP Configuration - -It is possible to connect client and server in local mode (using unix sockets in /tmp/vsomeip*), but that scenario requires --network host and sharing host /tmp directory in the container. - -For remote endpoints a docker network can be used, with the following configuration considerations: - -### Docker SOMEIP Service configuration - -`./vsomip/config/docker-notify-service.json` - configuration for notify-sample example. - -Path must be set in `VSOMEIP_CONFIGURATION`, as well as `VSOMEIP_APPLICATION_NAME="service-sample"` - -- service unicast address needs to be set with the container's IP address inside docker network. e.g. - - ```bash - $ hostname -I - 172.18.0.5 - ``` - - should be set in someip config: - - ```json - { - "unicast": "172.18.0.5" - } - ```` - -- service multicast for events `224.225.226.233:32344` needs to be published in docker, e.g. - - ```bash - docker run -p 224.225.226.233:32344:32344/udp - ``` - - and must be consistent with the config json: - - ```json - { - "service": "0x1234", - "instance": "0x5678", - "unreliable": "30509", - "multicast": { - "address": "224.225.226.233", - "port": "32344" - } - } - ``` - -- service discovery multicast `224.244.224.245:30490` needs to be published in docker as well, e.g. - - ```bash - docker run -p 224.244.224.245:30490:30490/udp` - ``` - - and must be consistent with the config json: - - ```json - "routing": "service-sample", - "service-discovery": { - "enable": "true", - "multicast": "224.244.224.245", - "port": "30490", - "protocol": "udp" - } - ``` - -### Docker SOMEIP client configuration - -`./vsomip/config/docker-notify-client.json` - configuration for subscribe-sample example. - -Path must be set in `VSOMEIP_CONFIGURATION`, as well as `VSOMEIP_APPLICATION_NAME="client-sample"` - -- client unicast address needs to be set with the container's IP address inside docker network. e.g. - - ```bash - $ hostname -I - 172.18.0.6 - ``` - - should be set in someip config: - - ```json - "unicast": "172.18.0.6" - ```` - -- service-discovery multicast `224.244.224.245:30490` needs to be consistent with the service config: - - ```json - "routing": "client-sample", - "service-discovery": { - "enable": "true", - "multicast": "224.244.224.245", - "port": "30490", - "protocol": "udp" - } - ``` - -## Testing SOME/IP communication - -1. Build local vsomeip image with: `./docker-build.sh` -1. Run notify service container: `./docker-run-service.sh` -1. Check service output (multicast ip should be published, unicast address should be correct for the container): - - ```text - [info] Application(service-sample, 1277) is initialized (11, 100). - [info] REGISTER EVENT(1277): [1234.5678.8778:is_provider=true] - ... - [debug] Joining to multicast group 224.244.224.245 from 172.18.0.2 - ... - Setting event (Length=1). - Setting event (Length=2). - Setting event (Length=3). - Setting event (Length=4). - ``` - -1. Run notify client container: `./docker-run-client.sh` -1. Check service logs for these lines: - - ```text - [info] Application(client-sample, 1344) is initialized (11, 100). - Client settings [protocol=UDP] - [info] REGISTER EVENT(1344): [1234.5678.8778:is_provider=false] - [info] SUBSCRIBE(1344): [1234.5678.4465:ffff:0] - ... - [info] REQUEST(1344): [1234.5678:255.4294967295] - [info] udp_server_endpoint_impl: SO_RCVBUF is: 212992 - [debug] Joining to multicast group 224.244.224.245 from 172.18.0.3 - ... - Service [1234.5678] is available. - Received a notification for Event [1234.5678.8778] to Client/Session [0000/019a] = (1) 00 - Received a notification for Event [1234.5678.8778] to Client/Session [0000/019b] = (2) 00 01 - Received a notification for Event [1234.5678.8778] to Client/Session [0000/019c] = (3) 00 01 02 - Received a notification for Event [1234.5678.8778] to Client/Session [0000/019d] = (4) 00 01 02 03 - ``` - - Notification payload is byte[] received from notify service container. So far it is not forwarded to Kuksa.VAL - - -**NOTE:** -In case some of those messages are missing you can try running bash entrypoint and manually starting someip apps, e.g.: - -- `./docker-run-service.sh bash` -- `./docker-run-client.sh bash` diff --git a/someip2val/docker/docker-build.sh b/someip2val/docker/docker-build.sh deleted file mode 100755 index b82579e2..00000000 --- a/someip2val/docker/docker-build.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -#******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -#*******************************************************************************/ - -[ "$1" = "-v" ] && VERBOSE="--progress=plain" && shift - -DOCKER_BUILDKIT=1 docker buildx build --platform linux/amd64 -f Dockerfile -t vsomeip . --load $VERBOSE $* -[ $? -eq 0 ] || exit 1 - -echo "Built Docker image:" -docker image ls | grep vsomeip - -echo -echo "To start someip service container:" -echo " ./docker-run-service.sh" -echo -echo "To start someip client container:" -echo " ./docker-run-client.sh" -echo diff --git a/someip2val/docker/docker-run-client.sh b/someip2val/docker/docker-run-client.sh deleted file mode 100755 index 2611c01a..00000000 --- a/someip2val/docker/docker-run-client.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -#******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -#*******************************************************************************/ - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -DOCKER_ENV="-e VSOMEIP_CONFIGURATION=/app/config/docker-notify-client.json -e VSOMEIP_APPLICATION_NAME=client-sample" # -e VSOMEIP_CLIENTSIDELOGGING=1 - -# DOCKER_VOL="-v $SCRIPT_DIR/vsomeip/config:/app/config" - -# DOCKER_PORTS="-p 224.225.226.233:32344:32344/udp -p 224.244.224.245:30490:30490/udp" -# DOCKER_PORTS="-p 22344:22344/udp -p 30490:30490/udp" #-p 30509:30509/udp -# DOCKER_PORTS="-p 30490:30490/udp" #-p 30509:30509/udp - -DOCKER_NET="someip" -if ! docker network inspect "$DOCKER_NET" &>/dev/null; then - docker network create "$DOCKER_NET" -fi - -echo -#echo "route add -net 224.0.0.0/4 dev eth0" -echo "Optionally execute the following commands in the container to update json file with required IPs:" -echo ' SERV_IP=$(ping -4 -n -q -w 1 someip-serv | grep PING | cut -d " " -f 3 | tr -d "()")' -echo ' jq --arg ip $(hostname -I | cut -d ' ' -f 1) --arg serv $SERV_IP '\''.unicast=$ip | .services[0].unicast=$serv'\'' "$VSOMEIP_CONFIGURATION" > "$VSOMEIP_CONFIGURATION.tmp" && mv "$VSOMEIP_CONFIGURATION.tmp" "$VSOMEIP_CONFIGURATION"' -echo - -## Allow args to override default entrypoint. e.g. $0 bash -# ENTRYPOINT="/app/bin/subscribe-sample --udp" -ENTRYPOINT="/app/bin/run-client.sh" -[ -n "$1" ] && ENTRYPOINT="$*" - -set -x -docker run --rm -it $DOCKER_VOL $DOCKER_ENV --network "$DOCKER_NET" $DOCKER_PORTS --name=someip-cli vsomeip $ENTRYPOINT -# --cap-add NET_ADMIN diff --git a/someip2val/docker/docker-run-service.sh b/someip2val/docker/docker-run-service.sh deleted file mode 100755 index 28b0fe78..00000000 --- a/someip2val/docker/docker-run-service.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -#******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -#*******************************************************************************/ - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -DOCKER_ENV="-e VSOMEIP_OFFER_ONCE=1 -e VSOMEIP_CONFIGURATION=/app/config/docker-notify-service.json -e VSOMEIP_APPLICATION_NAME=service-sample" # -e VSOMEIP_CLIENTSIDELOGGING=1 - -# DOCKER_VOL="-v $SCRIPT_DIR/vsomeip/config:/app/config" - -# DOCKER_PORTS="-p 224.225.226.233:32344:32344/udp -p 224.244.224.245:30490:30490/udp -p 32344:32344/udp" #-p 30509:30509/udp -DOCKER_PORTS="-p 32344:32344/udp -p 30490:30490/udp" #-p 30509:30509/udp - -DOCKER_NET="someip" -if ! docker network inspect "$DOCKER_NET" &>/dev/null; then - docker network create "$DOCKER_NET" -fi - -echo -echo -echo "Optionally execute the following commands in the container to update json file with required IPs:" -echo ' jq --arg ip $(hostname -I) '\''.unicast=$ip'\'' "$VSOMEIP_CONFIGURATION" > "$VSOMEIP_CONFIGURATION.tmp" && mv "$VSOMEIP_CONFIGURATION.tmp" "$VSOMEIP_CONFIGURATION"' -#echo ' route add -net 224.0.0.0/4 dev eth0' -echo - -## Allow args to override default entrypoint. e.g. $0 bash -# ENTRYPOINT="/app/bin/notify-sample --udp" -ENTRYPOINT="/app/bin/run-service.sh" -[ -n "$1" ] && ENTRYPOINT="$*" - -set -x -docker run --rm -it $DOCKER_VOL $DOCKER_ENV --network "$DOCKER_NET" $DOCKER_PORTS --name=someip-serv vsomeip $ENTRYPOINT -#--cap-add NET_ADMIN diff --git a/someip2val/docker/vsomeip/CMakeLists.txt b/someip2val/docker/vsomeip/CMakeLists.txt deleted file mode 100644 index 06e4258a..00000000 --- a/someip2val/docker/vsomeip/CMakeLists.txt +++ /dev/null @@ -1,721 +0,0 @@ -# Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -cmake_minimum_required (VERSION 2.8.12) -project (vsomeip) - -set (VSOMEIP_NAME vsomeip3) -set (VSOMEIP_COMPAT_NAME vsomeip) - -set (VSOMEIP_MAJOR_VERSION 3) -set (VSOMEIP_MINOR_VERSION 1) -set (VSOMEIP_PATCH_VERSION 20) -set (VSOMEIP_HOTFIX_VERSION 3) - -set (VSOMEIP_VERSION ${VSOMEIP_MAJOR_VERSION}.${VSOMEIP_MINOR_VERSION}.${VSOMEIP_PATCH_VERSION}) -set (PACKAGE_VERSION ${VSOMEIP_VERSION}) # Used in documentation/doxygen.in -set (CMAKE_VERBOSE_MAKEFILE off) - -if (NOT GTEST_ROOT) - if (DEFINED ENV{GTEST_ROOT}) - set(GTEST_ROOT $ENV{GTEST_ROOT}) - else() - set(GTEST_ROOT "n/a" CACHE STRING "Path to root folder of googletest. Must be set for building the tests.") - endif() -endif() - -################################################################################################### -# see http://www.cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file -################################################################################################### - -# Offer the user the choice of overriding the installation directories -set (INSTALL_LIB_DIR lib CACHE STRING "Installation directory for libraries") -set (INSTALL_BIN_DIR bin CACHE STRING "Installation directory for executables") -set (INSTALL_INCLUDE_DIR include CACHE STRING "Installation directory for header files") - -if (WIN32 AND NOT CYGWIN) - set (DEF_INSTALL_CMAKE_DIR CMake) -else () - set (DEF_INSTALL_CMAKE_DIR lib/cmake/${VSOMEIP_NAME}) -endif () - -set (INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE STRING "Installation directory for CMake files") - -################################################################################################### -# Set a default build type if none was specified -set(default_build_type "RelWithDebInfo") -if(NOT CMAKE_BUILD_TYPE) - message(STATUS "Setting build type to '${default_build_type}' as none was specified.") - set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE) - # Set the possible values of build type for cmake-gui - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") -endif() - -# OS -if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - set(OS "LINUX") - set(DL_LIBRARY "dl") - set(EXPORTSYMBOLS "-Wl,-export-dynamic -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exportmap.gcc") - set(NO_DEPRECATED "") - set(OPTIMIZE "") - set(OS_CXX_FLAGS "-D_GLIBCXX_USE_NANOSLEEP -pthread -O -Wall -Wextra -Wformat -Wformat-security -Wconversion -fexceptions -fstrict-aliasing -fstack-protector-strong -fasynchronous-unwind-tables -fno-omit-frame-pointer -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security -fPIE -pie -Wl,-z,relro,-z,now") -endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - -if (${CMAKE_SYSTEM_NAME} MATCHES "Android") - set(OS "ANDROID") - set(DL_LIBRARY "") - set(EXPORTSYMBOLS "") - set(NO_DEPRECATED "") - set(OPTIMIZE "") - - find_library(ANDROID_LOG_LIB log) - set(OS_LIBS ${ANDROID_LOG_LIB}) -endif(${CMAKE_SYSTEM_NAME} MATCHES "Android") - -if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - set(OS "FREEBSD") - set(DL_LIBRARY "") - set(EXPORTSYMBOLS "") - set(NO_DEPRECATED "-Wno-deprecated") - set(OPTIMIZE "") - set(OS_CXX_FLAGS "-pthread") -endif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - -################################################################################ -# Options -################################################################################ - -# DLT -if (DISABLE_DLT) -set (VSOMEIP_ENABLE_DLT 0) -else () -set (VSOMEIP_ENABLE_DLT 1) -endif () - -# Signal handling -if (ENABLE_SIGNAL_HANDLING) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVSOMEIP_ENABLE_SIGNAL_HANDLING") -endif () - -# Sanitizer -if (ENABLE_THREAD_SANITIZER) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread") -endif () - -if (ENABLE_LEAK_SANITIZER) -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=leak") -endif () - -# Configuration overlays -if (ENABLE_CONFIGURATION_OVERLAYS) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVSOMEIP_ENABLE_CONFIGURATION_OVERLAYS") -endif () - -# Compatibility -if (ENABLE_COMPAT) -set (VSOMEIP_ENABLE_COMPAT 1) -else () -set (VSOMEIP_ENABLE_COMPAT 0) -endif () - -# Multiple routing managers -if (ENABLE_MULTIPLE_ROUTING_MANAGERS) -set (VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS 1) -else () -set (VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS 0) -endif () - -# Session handling configuration -if (ENABLE_SESSION_HANDLING_CONFIG) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVSOMEIP_HAS_SESSION_HANDLING_CONFIG") -endif () - -################################################################################ -# Dependencies -################################################################################ - -# Threads -find_package(Threads REQUIRED) - -# Boost -find_package( Boost 1.55 COMPONENTS system thread filesystem REQUIRED ) -include_directories( ${Boost_INCLUDE_DIR} ) - -if(Boost_FOUND) - if(Boost_LIBRARY_DIR) - MESSAGE( STATUS "Boost_LIBRARY_DIR not empty using it: ${Boost_LIBRARY_DIR}" ) - else() - if(BOOST_LIBRARYDIR) - MESSAGE( STATUS "Boost_LIBRARY_DIR empty but BOOST_LIBRARYDIR is set setting Boost_LIBRARY_DIR to: ${BOOST_LIBRARYDIR}" ) - set(Boost_LIBRARY_DIR ${BOOST_LIBRARYDIR}) - endif() - endif() -else() - MESSAGE( STATUS "Boost was not found!") -endif() - -# cmake 3.15 introduced a new variable and a new format for the old one -if (DEFINED Boost_VERSION_MACRO) - set(VSOMEIP_BOOST_VERSION ${Boost_VERSION_MACRO}) -else() - set(VSOMEIP_BOOST_VERSION ${Boost_VERSION}) -endif() - -message( STATUS "Using boost version: ${VSOMEIP_BOOST_VERSION}" ) -if (${VSOMEIP_BOOST_VERSION} GREATER 107600) -message( ERROR "boost version ${VSOMEIP_BOOST_VERSION} is not (yet) supported. Latest supported version is 1.76.0" ) -elseif(${VSOMEIP_BOOST_VERSION} GREATER 107500) -set(VSOMEIP_BOOST_HELPER implementation/helper/1.76) -elseif(${VSOMEIP_BOOST_VERSION} GREATER 107300) -set(VSOMEIP_BOOST_HELPER implementation/helper/1.74) -elseif(${VSOMEIP_BOOST_VERSION} GREATER 106999) -set(VSOMEIP_BOOST_HELPER implementation/helper/1.70) -elseif(${VSOMEIP_BOOST_VERSION} GREATER 106599) -set(VSOMEIP_BOOST_HELPER implementation/helper/1.66) -else() -set(VSOMEIP_BOOST_HELPER implementation/helper/1.55) -endif() - -find_package(PkgConfig) - -# DLT -if(VSOMEIP_ENABLE_DLT EQUAL 1) -pkg_check_modules(DLT "automotive-dlt >= 2.11") -if(DLT_FOUND) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_DLT") -endif(DLT_FOUND) -endif() - -# SystemD -pkg_check_modules(SystemD "libsystemd") - -if(NOT SystemD_FOUND OR ${CMAKE_SYSTEM_NAME} MATCHES "Android") -MESSAGE( STATUS "Systemd was not found, watchdog disabled!") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWITHOUT_SYSTEMD") -else() -list(APPEND OS_LIBS ${SystemD_LIBRARIES}) -endif(NOT SystemD_FOUND OR ${CMAKE_SYSTEM_NAME} MATCHES "Android") - -# Multiple routing managers -if (VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS EQUAL 1) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS") -endif () - -################################################################################ -# Directories -################################################################################ - -include_directories( - interface -) - -include_directories(SYSTEM - ${VSOMEIP_BOOST_HELPER} - ${DLT_INCLUDE_DIRS} -) - -link_directories( - ${DLT_LIBDIR} -) - -if (${VSOMEIP_HOTFIX_VERSION} EQUAL 0) -add_definitions(-DVSOMEIP_VERSION="${VSOMEIP_VERSION}") -else() -add_definitions(-DVSOMEIP_VERSION="${VSOMEIP_VERSION}.${VSOMEIP_HOTFIX_VERSION}") -endif() - -if (MSVC) - message("using MSVC Compiler") - # add_definitions(-DVSOMEIP_DLL_COMPILATION) now it is controlled per target - SET(BOOST_WINDOWS_VERSION "0x600" CACHE STRING "Set the same Version as the Version with which Boost was built, otherwise there will be errors. (normaly 0x600 is for Windows 7 and 0x501 is for Windows XP)") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_WINSOCK_DEPRECATED_NO_WARNINGS -D_WIN32_WINNT=${BOOST_WINDOWS_VERSION} -DWIN32 -DBOOST_ASIO_DISABLE_IOCP /EHsc") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS -D_WIN32_WINNT=${BOOST_WINDOWS_VERSION} -DWIN32 -DBOOST_ASIO_DISABLE_IOCP /EHsc") - set(USE_RT "") - link_directories(${Boost_LIBRARY_DIR_DEBUG}) - ADD_DEFINITIONS( -DBOOST_ALL_DYN_LINK ) -else() - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D${OS} ${OS_CXX_FLAGS} -g ${OPTIMIZE} -std=c++11 ${NO_DEPRECATED} ${EXPORTSYMBOLS}") - if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Android") - set(USE_RT "rt") - endif() -endif() - -################################################################################ -# Configuration library -################################################################################ -file(GLOB ${VSOMEIP_NAME}-cfg_SRC - "implementation/configuration/src/*.cpp" -) -list(SORT ${VSOMEIP_NAME}-cfg_SRC) -if (VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS EQUAL 0) - add_library(${VSOMEIP_NAME}-cfg SHARED ${${VSOMEIP_NAME}-cfg_SRC}) - set_target_properties (${VSOMEIP_NAME}-cfg PROPERTIES VERSION ${VSOMEIP_VERSION} SOVERSION ${VSOMEIP_MAJOR_VERSION}) - if (MSVC) - set_target_properties(${VSOMEIP_NAME}-cfg PROPERTIES COMPILE_DEFINITIONS "VSOMEIP_DLL_COMPILATION_PLUGIN") - endif() - - target_link_libraries(${VSOMEIP_NAME}-cfg ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${OS_LIBS}) -endif () - -################################################################################ -# Base library -################################################################################ -file(GLOB ${VSOMEIP_NAME}_SRC - "implementation/endpoints/src/*.cpp" - "implementation/logger/src/*.cpp" - "implementation/tracing/src/*.cpp" - "implementation/message/src/*.cpp" - "implementation/plugin/src/*.cpp" - "implementation/routing/src/*.cpp" - "implementation/runtime/src/*.cpp" - "implementation/security/src/*.cpp" - "implementation/utility/src/*.cpp" -) -if (VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS EQUAL 1) -list(APPEND ${VSOMEIP_NAME}_SRC "implementation/configuration/src/configuration_impl.cpp") -endif() -list(SORT ${VSOMEIP_NAME}_SRC) - -add_library(${VSOMEIP_NAME} SHARED ${${VSOMEIP_NAME}_SRC}) -set_target_properties (${VSOMEIP_NAME} PROPERTIES VERSION ${VSOMEIP_VERSION} SOVERSION ${VSOMEIP_MAJOR_VERSION}) -if (MSVC) - set_target_properties(${VSOMEIP_NAME} PROPERTIES COMPILE_DEFINITIONS "VSOMEIP_DLL_COMPILATION") -endif () -target_include_directories(${VSOMEIP_NAME} INTERFACE - $ - $ - $) -# PRIVATE means the listed libraries won't be included in the "link interface", -# meaning the exported vsomeip3Targets.cmake targets won't try to link against -# them (which shouldn't be required). ${Boost_LIBRARIES} includes absolute -# build host paths as of writing, which also makes this important as it breaks -# the build. -target_link_libraries(${VSOMEIP_NAME} PRIVATE ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${DLT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${OS_LIBS}) - -################################################################################ -# Service Discovery library -################################################################################ -file(GLOB ${VSOMEIP_NAME}-sd_SRC - "implementation/service_discovery/src/*.cpp" -) -list(SORT ${VSOMEIP_NAME}-sd_SRC) - -add_library(${VSOMEIP_NAME}-sd SHARED ${${VSOMEIP_NAME}-sd_SRC}) -set_target_properties (${VSOMEIP_NAME}-sd PROPERTIES VERSION ${VSOMEIP_VERSION} SOVERSION ${VSOMEIP_MAJOR_VERSION}) -if (MSVC) - set_target_properties(${VSOMEIP_NAME}-sd PROPERTIES COMPILE_DEFINITIONS "VSOMEIP_DLL_COMPILATION_PLUGIN") -endif () - -target_link_libraries(${VSOMEIP_NAME}-sd ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${OS_LIBS}) - - -################################################################################ -# E2E library -################################################################################ -file(GLOB_RECURSE ${VSOMEIP_NAME}-e2e_SRC - "implementation/e2e_protection/src/*.cpp" -) -list(SORT ${VSOMEIP_NAME}-e2e_SRC) - -add_library(${VSOMEIP_NAME}-e2e SHARED ${${VSOMEIP_NAME}-e2e_SRC}) -set_target_properties (${VSOMEIP_NAME}-e2e PROPERTIES VERSION ${VSOMEIP_VERSION} SOVERSION ${VSOMEIP_MAJOR_VERSION}) -if (MSVC) - set_target_properties(${VSOMEIP_NAME}-e2e PROPERTIES COMPILE_DEFINITIONS "VSOMEIP_DLL_COMPILATION_PLUGIN") -endif () - -target_link_libraries(${VSOMEIP_NAME}-e2e ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${OS_LIBS}) - -################################################################################ -# Compatibility library -################################################################################ -if (VSOMEIP_ENABLE_COMPAT EQUAL 1) -set (VSOMEIP_COMPAT_MAJOR_VERSION 2) -set (VSOMEIP_COMPAT_VERSION ${VSOMEIP_COMPAT_MAJOR_VERSION}.99.99) - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVSOMEIP_ENABLE_COMPAT") - -file(GLOB_RECURSE ${VSOMEIP_COMPAT_NAME}_SRC - "implementation/compat/logging/src/*.cpp" - "implementation/compat/message/src/*.cpp" - "implementation/compat/runtime/src/*.cpp" -) -list(SORT ${VSOMEIP_COMPAT_NAME}_SRC) - -add_library(${VSOMEIP_COMPAT_NAME} SHARED ${${VSOMEIP_COMPAT_NAME}_SRC}) -set_target_properties (${VSOMEIP_COMPAT_NAME} PROPERTIES VERSION ${VSOMEIP_COMPAT_VERSION} SOVERSION ${VSOMEIP_COMPAT_MAJOR_VERSION}) -if (MSVC) - set_target_properties(${VSOMEIP_COMPAT_NAME} PROPERTIES COMPILE_DEFINITIONS "VSOMEIP_DLL_COMPILATION_PLUGIN") -endif () - -target_include_directories( - ${VSOMEIP_COMPAT_NAME} - PUBLIC - $ # for headers when building - $ # for generated files in build mode - $ # for clients in install mode -) -target_link_libraries(${VSOMEIP_COMPAT_NAME} PRIVATE ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${OS_LIBS}) - -endif () - -################################################################################ -# Configuration files -################################################################################ -set(EXAMPLE_CONFIG_FILES - "config/vsomeip.json" - "config/vsomeip-local.json" - "config/vsomeip-tcp-client.json" - "config/vsomeip-tcp-service.json" - "config/vsomeip-udp-client.json" - "config/vsomeip-udp-service.json" -) - -################################################################################ -# Configuration parameters -################################################################################ -set (VSOMEIP_BASE_PATH "/tmp") -if (BASE_PATH) -set (VSOMEIP_BASE_PATH ${BASE_PATH}) -endif () -set (VSOMEIP_DIAGNOSIS_ADDRESS "0x01") -if (DIAGNOSIS_ADDRESS) -set (VSOMEIP_DIAGNOSIS_ADDRESS ${DIAGNOSIS_ADDRESS}) -endif () -set (VSOMEIP_UNICAST_ADDRESS "127.0.0.1") -if (UNICAST_ADDRESS) -set (VSOMEIP_UNICAST_ADDRESS ${UNICAST_ADDRESS}) -endif () -set (VSOMEIP_ROUTING_READY_MESSAGE "SOME/IP routing ready.") -if (ROUTING_READY_MESSAGE) -set (VSOMEIP_ROUTING_READY_MESSAGE ${ROUTING_READY_MESSAGE}) -endif () - -set(DEFAULT_CONFIGURATION_FOLDER "/etc/vsomeip" CACHE PATH "Default configuration folder") -message(STATUS "Default configuration folder: ${DEFAULT_CONFIGURATION_FOLDER}") - -set(DEFAULT_CONFIGURATION_FILE "/etc/vsomeip.json" CACHE FILEPATH "Default configuration file") -message(STATUS "Default configuration file: ${DEFAULT_CONFIGURATION_FILE}") - -message("Predefined base path: ${VSOMEIP_BASE_PATH}") -message("Predefined unicast address: ${VSOMEIP_UNICAST_ADDRESS}") -message("Predefined diagnosis address: ${VSOMEIP_DIAGNOSIS_ADDRESS}") - -################################################################################ -# Installation -################################################################################ -set(INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/interface/vsomeip") - -file (GLOB_RECURSE vsomeip_INCLUDE RELATIVE ${INCLUDE_PATH} "interface/*.hpp" ) -list (SORT vsomeip_INCLUDE) - -foreach ( file ${vsomeip_INCLUDE} ) - get_filename_component( dir ${file} DIRECTORY ) - install( FILES "${INCLUDE_PATH}/${file}" DESTINATION "${INSTALL_INCLUDE_DIR}/vsomeip/${dir}" COMPONENT dev) -endforeach() - -install ( - TARGETS ${VSOMEIP_NAME} - # IMPORTANT: Add the vsomeip library to the "export-set" - EXPORT vsomeip3Targets - RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT - LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT - ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" - COMPONENT dev -) - -install ( - TARGETS ${VSOMEIP_NAME}-e2e - LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT shlib - RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin -) - -if (VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS EQUAL 0) -install ( - TARGETS ${VSOMEIP_NAME}-cfg - LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT shlib - RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin -) -endif () - -install ( - TARGETS ${VSOMEIP_NAME}-sd - LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT shlib - RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin -) - -if (VSOMEIP_ENABLE_COMPAT EQUAL 1) -install ( - TARGETS ${VSOMEIP_COMPAT_NAME} - EXPORT vsomeipTargets - LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT shlib - RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin -) - -export (TARGETS ${VSOMEIP_COMPAT_NAME} FILE "${PROJECT_BINARY_DIR}/vsomeipTargets.cmake") -export (PACKAGE ${VSOMEIP_COMPAT_NAME}) - -configure_file (vsomeipConfig.cmake.in "${PROJECT_BINARY_DIR}/vsomeipConfig.cmake" @ONLY) -configure_file (vsomeipConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/vsomeipConfigVersion.cmake" @ONLY) - -set (COMPAT_INSTALL_CMAKE_DIR "lib/cmake/${VSOMEIP_COMPAT_NAME}") - -install ( - EXPORT vsomeipTargets - DESTINATION "${COMPAT_INSTALL_CMAKE_DIR}" - COMPONENT dev -) - -install ( - FILES - "${PROJECT_BINARY_DIR}/vsomeipConfig.cmake" - "${PROJECT_BINARY_DIR}/vsomeipConfigVersion.cmake" - DESTINATION "${COMPAT_INSTALL_CMAKE_DIR}" - COMPONENT dev -) - -configure_file(vsomeip.pc.in ${PROJECT_BINARY_DIR}/vsomeip.pc @ONLY) -install(FILES ${PROJECT_BINARY_DIR}/vsomeip.pc DESTINATION lib/pkgconfig) - -endif () - -install ( - FILES ${EXAMPLE_CONFIG_FILES} DESTINATION etc/vsomeip COMPONENT config -) - -# Add all targets to the build-tree export set -export (TARGETS ${VSOMEIP_NAME} FILE "${PROJECT_BINARY_DIR}/vsomeip3Targets.cmake") - -# Export the package for use from the build-tree -# (this registers the build-tree with a global CMake-registry) -export (PACKAGE ${VSOMEIP_NAME}) - -# Create the vsomeip3Config.cmake and vsomeip3ConfigVersion files -configure_file (vsomeip3Config.cmake.in "${PROJECT_BINARY_DIR}/vsomeip3Config.cmake" @ONLY) -configure_file (vsomeip3ConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/vsomeip3ConfigVersion.cmake" @ONLY) - -# configure internal.hpp for correct version number -configure_file ( - "${PROJECT_SOURCE_DIR}/implementation/configuration/include/internal.hpp.in" - "${PROJECT_SOURCE_DIR}/implementation/configuration/include/internal.hpp" -) - -# Install the vsomeip3Config.cmake and vsomeip3ConfigVersion.cmake -install ( - FILES - "${PROJECT_BINARY_DIR}/vsomeip3Config.cmake" - "${PROJECT_BINARY_DIR}/vsomeip3ConfigVersion.cmake" - DESTINATION "${INSTALL_CMAKE_DIR}" - COMPONENT dev -) - -# Install the export set for use with the install-tree -install ( - EXPORT vsomeip3Targets - DESTINATION "${INSTALL_CMAKE_DIR}" - COMPONENT dev -) - -############################################################################## -# build documentation -############################################################################## -add_custom_target(doc) - -find_package(Doxygen) -if (NOT DOXYGEN_FOUND) - message(WARNING "Doxygen is not installed. Documentation can not be built.") -else() - # set configuration variables for doxygen.in - set(PROJECT "vsomeip") - set(DOCDIR documentation) - set(SRCDIR .) - set(GENERATE_HTML YES) - set(GENERATE_HTMLHELP NO) - set(GENERATE_CHI NO) - set(GENERATE_LATEX NO) - set(GENERATE_PDF NO) - set(GENERATE_RTF NO) - set(GENERATE_MAN NO) - set(GENERATE_XML NO) - set(HAVE_DOT YES) - - if(HAVE_DOT) - # Note: the @DOT_PATH@ variable won't be used in doxygen.in as doxygen - # somehow manages to strip the last slash from the path and therfore no - # graphs are generated. Therefore dot should be available in your $PATH - FIND_PROGRAM(DOT_PATH dot) - if ("${DOT_PATH}" STREQUAL "DOT_PATH-NOTFOUND") - message(WARNING "dot (graphviz) is not installed. Graphs in documentation can't be generated.") - else() - message("dot found") - endif() - endif() - - configure_file(documentation/doxygen.in ${PROJECT_BINARY_DIR}/Doxyfile @ONLY) - add_custom_target(doxygen-doc - COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/Doxyfile - SOURCES ${PROJECT_BINARY_DIR}/Doxyfile) - - add_dependencies(doc doxygen-doc) -endif() - -find_program(ASCIIDOC_PATH asciidoc) -find_program(SOURCE_HIGHLIGHT_PATH source-highlight) -if ("${ASCIIDOC_PATH}" STREQUAL "ASCIIDOC_PATH-NOTFOUND") - message(WARNING "asciidoc is not installed. Readme can not be built.") -elseif("${SOURCE_HIGHLIGHT_PATH}" STREQUAL "SOURCE_HIGHLIGHT_PATH-NOTFOUND") - message(WARNING "source-highlight is not installed. Readme can not be built.") -else() - message("asciidoc found") - message("source-highlight found") - add_custom_command(TARGET doc - POST_BUILD - COMMAND asciidoc - -a version=${VSOMEIP_VERSION} - -b html - -o documentation/vsomeipUserGuide.html - ${PROJECT_SOURCE_DIR}/documentation/vsomeipUserGuide) -endif() - -############################################################################## -# create pkg-config file -if(NOT WIN32) - configure_file(vsomeip3.pc.in ${PROJECT_BINARY_DIR}/vsomeip3.pc @ONLY) - install(FILES ${PROJECT_BINARY_DIR}/vsomeip3.pc DESTINATION lib/pkgconfig) -endif() - -############################################################################## -if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Android") - # build routing manager daemon (Non-Windows only) - if (NOT MSVC) - add_subdirectory( examples/routingmanagerd ) - endif() - - # build tools - add_custom_target( tools ) - add_subdirectory( tools ) - - # build examples - add_custom_target( examples ) - add_subdirectory( examples EXCLUDE_FROM_ALL ) - add_custom_target( hello_world ) - add_subdirectory( examples/hello_world EXCLUDE_FROM_ALL ) - - #build wiperpoc - # add_custom_target( wiper_poc ) - # add_subdirectory( wiper_poc ) -endif() - -############################################################################## -# Test section -############################################################################## - -############################################################################## -# google test - -# check for set environment variable -if(${GTEST_ROOT} STREQUAL "n/a") - message(STATUS "GTEST_ROOT is not defined. For building the tests the variable - GTEST_ROOT has to be defined. Tests can not be built.") - # early exit - return() # test can not be build -> make commands build_tests and check are not available -else() - message(STATUS "GTEST_ROOT is set. gtest root path set to ${GTEST_ROOT}") -endif() - -# build google test as static library (always) -> therefore deactivate BUILD_SHARED_LIBS in case it is active -set(BUILD_SHARED_LIBS_AUTOMATIC_OFF 0) -if ("${BUILD_SHARED_LIBS}" STREQUAL "ON") - set(BUILD_SHARED_LIBS OFF) - set(BUILD_SHARED_LIBS_AUTOMATIC_OFF 1) -endif() -add_subdirectory(${GTEST_ROOT} ${CMAKE_CURRENT_BINARY_DIR}/gtest EXCLUDE_FROM_ALL) -if ("${BUILD_SHARED_LIBS_AUTOMATIC_OFF}" STREQUAL "1") - set(BUILD_SHARED_LIBS ON) - set(BUILD_SHARED_LIBS_AUTOMATIC_OFF 0) -endif() - - - -############################################################################## -# build tests - -enable_testing() -SET(TESTS_BAT "OFF" CACHE BOOL - "Controls whether only BAT tests should be build or not") -SET(TEST_SYMLINK_CONFIG_FILES "OFF" CACHE BOOL - "Controls if the json and scripts needed needed to run the tests are copied or symlinked into the build directroy (ignored on Windows)") -SET(TEST_SYMLINK_CONFIG_FILES_RELATIVE "OFF" CACHE BOOL - "Controls if the json and scripts needed needed to run the tests are symlinked relatively into the build directroy (ignored on Windows)") - -SET(TEST_IP_DEFAULT_VALUE "XXX.XXX.XXX.XXX") -SET(TEST_IP_MASTER "${TEST_IP_DEFAULT_VALUE}" CACHE STRING - "The IP address of the interface which will act as test master") -SET(TEST_IP_SLAVE "${TEST_IP_DEFAULT_VALUE}" CACHE STRING - "The IP address of the interface which will act as test slave") - -if((${TEST_IP_MASTER} STREQUAL ${TEST_IP_DEFAULT_VALUE}) OR - (${TEST_IP_SLAVE} STREQUAL ${TEST_IP_DEFAULT_VALUE})) - message(WARNING "TEST_IP_MASTER and/or TEST_IP_SLAVE isn't set. " - "Only local tests will be runnable " - "Please specify them via for example " - "-DTEST_IP_MASTER=10.0.3.1 -DTEST_IP_SLAVE=10.0.3.125") -endif() - -SET(TEST_IP_SLAVE_SECOND "${TEST_IP_DEFAULT_VALUE}" CACHE STRING - "The second IP address of the interface which will act as test slave") -set(TEST_SECOND_ADDRESS "OFF" CACHE BOOL - "Controls whether second address tests should run or not") - -if(${TEST_IP_SLAVE_SECOND} STREQUAL ${TEST_IP_DEFAULT_VALUE}) - message(WARNING "TEST_IP_SLAVE_SECOND isn't set. " - "Test with more than one IP address on same interface is not enabled." - "Please specify them via for example " - "-TEST_IP_SLAVE_SECOND=10.0.3.126") -else() - set(TEST_SECOND_ADDRESS "ON") -endif() - -set(TEST_E2E_PROFILE_04 "OFF" CACHE BOOL - "Controls whether E2E Profile 04 tests should run or not") -if (ENABLE_SESSION_HANDLING_CONFIG) - set(TEST_E2E_PROFILE_04 "ON") -else () - message(WARNING "ENABLE_SESSION_HANDLING_CONFIG isn't set. " - "Test of E2E Profile 04 is not enabled.") -endif () - - -SET(TEST_UID_DEFAULT_VALUE "123456789") -SET(TEST_UID "${TEST_UID_DEFAULT_VALUE}" CACHE STRING - "The User ID of the user running the test: Needed for security") -SET(TEST_GID_DEFAULT_VALUE "123456789") -SET(TEST_GID "${TEST_GID_DEFAULT_VALUE}" CACHE STRING - "The Group ID of the user running the test: Needed for security") - -SET(TEST_SECURITY "ON" CACHE BOOL - "Controls whether security tests should run or not") - -if((${TEST_UID} STREQUAL ${TEST_UID_DEFAULT_VALUE}) OR - (${TEST_GID} STREQUAL ${TEST_GID_DEFAULT_VALUE})) - message(WARNING "TEST_UID and/or TEST_GID isn't set. " - "Security Tests are not runnable " - "Please specify them for example " - "-DTEST_UID=1000 -DTEST_GID=1000") - SET(TEST_SECURITY "OFF") -endif() - -add_custom_target(build_tests) -add_dependencies(build_tests vsomeip3) -add_dependencies(build_tests vsomeip3-sd) - -set(CMAKE_CTEST_COMMAND ctest -V) -add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) - -add_dependencies(check build_tests) - -############################################################################## -# add test directory - -add_subdirectory( test EXCLUDE_FROM_ALL ) diff --git a/someip2val/docker/vsomeip/config/docker-notify-client.json b/someip2val/docker/vsomeip/config/docker-notify-client.json deleted file mode 100644 index c627b560..00000000 --- a/someip2val/docker/vsomeip/config/docker-notify-client.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "__comment__": "has to be replaced with `hostname -I` within the container", - "unicast": "172.18.0.3", - - "logging": { - "level": "trace", - "console": "true", - "status_log_interval": "30", - "statistics": { - "interval": "30", - "min-frequency": "5", - "max-messages": "10" - }, - "version": { - "enable": "false", - "interval": "0" - } - }, - "tracing": { - "enable": "true", - "sd_enable": "true" - }, - - "applications": [ - { - "name": "client-sample", - "id": "0x1344" - } - ], - - "routing": "client-sample", - "service-discovery": { - "enable": "true", - "multicast": "224.244.224.245", - "port": "30490", - "protocol": "udp", - "initial_delay_min": "10", - "initial_delay_max": "100", - "repetitions_base_delay": "200", - "repetitions_max": "3", - "ttl": "3", - "cyclic_offer_delay": "2000", - "request_response_delay": "1500" - } -} diff --git a/someip2val/docker/vsomeip/config/docker-notify-service.json b/someip2val/docker/vsomeip/config/docker-notify-service.json deleted file mode 100644 index a4bccb55..00000000 --- a/someip2val/docker/vsomeip/config/docker-notify-service.json +++ /dev/null @@ -1,99 +0,0 @@ -{ - "__comment__": "has to be replaced with `hostname -I` within the container", - "unicast": "172.18.0.2", - - "logging": { - "level": "trace", - "console": "true", - "status_log_interval": "30", - "__memory_log_interval": "600", - "statistics": { - "interval": "30", - "min-frequency": "5", - "max-messages": "10" - }, - "version": { - "enable": "false", - "interval": "0" - } - }, - "tracing": { - "enable": "true", - "sd_enable": "true" - }, - - "applications": [ - { - "name": "service-sample", - "id": "0x1277" - } - ], - - "services": [ - { - "service": "0x1234", - "instance": "0x5678", - "unreliable": "30509", - "__multicast": { - "address": "224.225.226.233", - "port": "32344" - }, - "events": [ - { - "event": "0x8777", - "is_field": "false", - "is_reliable": "false", - "update-cycle": "2000" - }, - { - "event": "0x8778", - "is_field": "true", - "is_reliable": "false", - "update-cycle": "0" - }, - { - "event": "0x8779", - "is_field": "false", - "is_reliable": "false" - } - ], - "eventgroups": [ - { - "eventgroup": "0x4455", - "events": [ - "0x8777", - "0x8778" - ] - }, - { - "eventgroup": "0x4465", - "events": [ - "0x8778", - "0x8779" - ] - }, - { - "eventgroup": "0x4555", - "events": [ - "0x8777", - "0x8779" - ] - } - ] - } - ], - "routing": "service-sample", - "service-discovery": { - "enable": "true", - "multicast": "224.244.224.245", - "port": "30490", - "protocol": "udp", - "initial_delay_min": "10", - "initial_delay_max": "100", - "repetitions_base_delay": "200", - "repetitions_max": "3", - "ttl": "3", - "cyclic_offer_delay": "2000", - "request_response_delay": "1500" - } -} diff --git a/someip2val/docker/vsomeip/config/notify-client.json b/someip2val/docker/vsomeip/config/notify-client.json deleted file mode 100644 index f24d5907..00000000 --- a/someip2val/docker/vsomeip/config/notify-client.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "device": "enp0s3", - "unicast": "127.0.0.1", - "netmask": "255.255.0.0", - "logging" : - { - "level": "trace", - "console": "true", - "file": { "enable": "false", "path": "/tmp/vsomeip.log" }, - "dlt": "false", - "status_log_interval": "30", - "Xmemory_log_interval": "600", - "statistics": - { - "interval": "30", - "min-frequency": "5", - "max-messages": "10" - }, - "version": - { - "enable": "false", - "interval": "0" - } - }, - "watchdog": - { - "enable": "false", - "timeout": "2000", - "allowed_missing_pongs": "5" - }, - "tracing" : - { - "enable" : "true", - "sd_enable" : "true" - }, - - "applications" : - [ - { - "name" : "client-sample", - "id" : "0x1344" - } - ], - - "services" : - [ - { - "service" : "0x1234", - "instance" : "0x5678", - "unreliable" : "30509", - "unicast": "127.0.0.1", - "events" : - [ - { - "event" : "0x8777", - "is_field" : "false", - "is_reliable" : "false", - "update-cycle" : "2000" - }, - { - "event" : "0x8778", - "is_field" : "true", - "is_reliable" : "false", - "update-cycle" : "0" - }, - { - "event" : "0x8779", - "is_field" : "false", - "is_reliable" : "false" - } - ], - "eventgroups" : - [ - { - "eventgroup" : "0x4455", - "events" : [ "0x8777", "0x8778" ] - }, - { - "eventgroup" : "0x4465", - "events" : [ "0x8778", "0x8779" ] - }, - { - "eventgroup" : "0x4555", - "events" : [ "0x8777", "0x8779" ] - } - ] - } - ], - "__clients": - [ - { - "service": "0x1344", - "instance": "0x5000", - "reliable": [ "41234", "41235", "41236", "41237" ] - } - ], - - "routing" : "service-sample", - "service-discovery" : - { - "enable" : "true", - "multicast" : "224.244.224.245", - "port" : "30490", - "protocol" : "udp", - "initial_delay_min" : "10", - "initial_delay_max" : "100", - "repetitions_base_delay" : "200", - "repetitions_max" : "3", - "ttl" : "3", - "cyclic_offer_delay" : "2000", - "request_response_delay" : "1500" - } -} diff --git a/someip2val/docker/vsomeip/config/notify-service.json b/someip2val/docker/vsomeip/config/notify-service.json deleted file mode 100644 index fe361336..00000000 --- a/someip2val/docker/vsomeip/config/notify-service.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "device": "enp0s3", - "unicast": "192.168.100.115", - "netmask": "255.255.0.0", - "logging" : - { - "level": "trace", - "console": "true", - "file": { "enable": "false", "path": "/tmp/vsomeip.log" }, - "dlt": "false", - "status_log_interval": "30", - "__memory_log_interval": "600", - "statistics": - { - "interval": "30", - "min-frequency": "5", - "max-messages": "10" - }, - "version": - { - "enable": "false", - "interval": "0" - } - }, - "watchdog": - { - "enable": "false", - "timeout": "2000", - "allowed_missing_pongs": "5" - }, - "tracing" : - { - "enable" : "true", - "sd_enable" : "true" - }, - - "applications" : - [ - { - "name" : "service-sample", - "id" : "0x1234" - } - ], - - "services" : - [ - { - "service" : "0x1234", - "instance" : "0x5678", - "unreliable" : "30509", - "unicast": "192.168.100.115", - "__multicast" : - { - "address" : "224.225.226.233", - "port" : "32344" - }, - "events" : - [ - { - "event" : "0x8777", - "is_field" : "false", - "is_reliable" : "true", - "update-cycle" : "2000" - }, - { - "event" : "0x8778", - "is_field" : "true", - "is_reliable" : "true", - "update-cycle" : "0" - }, - { - "event" : "0x8779", - "is_field" : "false", - "is_reliable" : "true" - } - ], - "eventgroups" : - [ - { - "eventgroup" : "0x4455", - "events" : [ "0x8777", "0x8778" ] - }, - { - "eventgroup" : "0x4465", - "events" : [ "0x8778", "0x8779" ] - }, - { - "eventgroup" : "0x4555", - "events" : [ "0x8777", "0x8779" ] - } - ] - } - ], - - "routing" : "service-sample", - "service-discovery" : - { - "enable" : "true", - "multicast" : "224.244.224.245", - "port" : "30490", - "protocol" : "udp", - "initial_delay_min" : "10", - "initial_delay_max" : "100", - "repetitions_base_delay" : "200", - "repetitions_max" : "3", - "ttl" : "3", - "cyclic_offer_delay" : "2000", - "request_response_delay" : "1500" - } -} diff --git a/someip2val/docker/vsomeip/examples/run-client.sh b/someip2val/docker/vsomeip/examples/run-client.sh deleted file mode 100755 index 87fd689c..00000000 --- a/someip2val/docker/vsomeip/examples/run-client.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -#******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -#*******************************************************************************/ - -# important: match VSOMEIP_APPLICATION_NAME with VSOMEIP_CONFIGURATION config, must be equal! -export VSOMEIP_APPLICATION_NAME="client-sample" -export VSOMEIP_CONFIGURATION="/app/config/docker-notify-client.json" -# export VSOMEIP_CLIENTSIDELOGGING="" - -# make sure unicast ip is set in config for this container -jq --arg ip "$(hostname -I | cut -d ' ' -f 1)" '.unicast=$ip' "$VSOMEIP_CONFIGURATION" > "$VSOMEIP_CONFIGURATION.tmp" && mv "$VSOMEIP_CONFIGURATION.tmp" "$VSOMEIP_CONFIGURATION" - -echo "Running APP[$VSOMEIP_APPLICATION_NAME] with config $VSOMEIP_CONFIGURATION" -cat "$VSOMEIP_CONFIGURATION" - -set -x -/app/bin/subscribe-sample --udp diff --git a/someip2val/docker/vsomeip/examples/run-service.sh b/someip2val/docker/vsomeip/examples/run-service.sh deleted file mode 100755 index 134e226e..00000000 --- a/someip2val/docker/vsomeip/examples/run-service.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -#******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -#*******************************************************************************/ - -#export VSOMEIP_CLIENTSIDELOGGING="" - -# important: match VSOMEIP_APPLICATION_NAME with VSOMEIP_CONFIGURATION config, must be equal! -export VSOMEIP_APPLICATION_NAME="service-sample" - -export VSOMEIP_CONFIGURATION="/app/config/docker-notify-service.json" - -# make sure unicast ip is set in config for this container -jq --arg ip "$(hostname -I | cut -d ' ' -f 1)" '.unicast=$ip' "$VSOMEIP_CONFIGURATION" > "$VSOMEIP_CONFIGURATION.tmp" && mv "$VSOMEIP_CONFIGURATION.tmp" "$VSOMEIP_CONFIGURATION" - -echo "Running APP[$VSOMEIP_APPLICATION_NAME] with config $VSOMEIP_CONFIGURATION" -cat "$VSOMEIP_CONFIGURATION" - -set -x -/app/bin/notify-sample --udp diff --git a/someip2val/docker/vsomeip/examples/setup-routing.sh b/someip2val/docker/vsomeip/examples/setup-routing.sh deleted file mode 100755 index c7d8edbf..00000000 --- a/someip2val/docker/vsomeip/examples/setup-routing.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -#******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -#*******************************************************************************/ - -IF=$1 - -[ -z "$IF" ] && IF="eth0" - -route add -net 224.0.0.0/4 dev "$IF" diff --git a/someip2val/patches/000-cmake-reduce-gcc-warnings.patch b/someip2val/patches/000-cmake-reduce-gcc-warnings.patch deleted file mode 100644 index fc2541a9..00000000 --- a/someip2val/patches/000-cmake-reduce-gcc-warnings.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index aa83b7f..401174d 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -60,7 +60,8 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - set(EXPORTSYMBOLS "-Wl,-export-dynamic -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exportmap.gcc") - set(NO_DEPRECATED "") - set(OPTIMIZE "") -- set(OS_CXX_FLAGS "-D_GLIBCXX_USE_NANOSLEEP -pthread -O -Wall -Wextra -Wformat -Wformat-security -Wconversion -fexceptions -fstrict-aliasing -fstack-protector-strong -fasynchronous-unwind-tables -fno-omit-frame-pointer -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security -fPIE -pie -Wl,-z,relro,-z,now") -+ set(OS_CXX_FLAGS "-D_GLIBCXX_USE_NANOSLEEP -pthread -O -Wall -Wextra -Wformat -Wformat-security -Wno-unused-local-typedefs -fexceptions -fstrict-aliasing -fstack-protector-strong -fasynchronous-unwind-tables -fno-omit-frame-pointer -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security -fPIE -pie -Wl,-z,relro,-z,now") -+ # -Wconversion -Wunused-local-typedefs - endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - - if (${CMAKE_SYSTEM_NAME} MATCHES "Android") diff --git a/someip2val/patches/001-vsomeip-logger-fixes.patch b/someip2val/patches/001-vsomeip-logger-fixes.patch deleted file mode 100644 index a9d61394..00000000 --- a/someip2val/patches/001-vsomeip-logger-fixes.patch +++ /dev/null @@ -1,29 +0,0 @@ -diff --git a/implementation/logger/src/message.cpp b/implementation/logger/src/message.cpp -index e4a902f..4a25026 100644 ---- a/implementation/logger/src/message.cpp -+++ b/implementation/logger/src/message.cpp -@@ -39,9 +39,10 @@ message::~message() { - auto its_logger = logger_impl::get(); - auto its_configuration = its_logger->get_configuration(); - -- if (!its_configuration) -+ if (!its_configuration) { -+ std::cerr << "VSOMEIP<" << (int)level_ << ">: " << buffer_.data_.str() << std::endl; - return; -- -+ } - if (level_ > its_configuration->get_loglevel()) - return; - -@@ -76,8 +77,9 @@ message::~message() { - // Prepare time stamp - auto its_time_t = std::chrono::system_clock::to_time_t(when_); - auto its_time = std::localtime(&its_time_t); -- auto its_ms = (when_.time_since_epoch().count() / 100) % 1000000; -- -+ // auto its_ms = (when_.time_since_epoch().count() / 100) % 1000000; -+ auto its_ms = std::chrono::duration_cast -+ (when_.time_since_epoch()).count() % 1000000; - if (its_configuration->has_console_log()) { - #ifndef ANDROID - std::cout diff --git a/someip2val/patches/002-vsomeip-default-major-change.patch b/someip2val/patches/002-vsomeip-default-major-change.patch deleted file mode 100644 index 28cdf9da..00000000 --- a/someip2val/patches/002-vsomeip-default-major-change.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/interface/vsomeip/constants.hpp b/interface/vsomeip/constants.hpp -index 3a8201a..2406635 100644 ---- a/interface/vsomeip/constants.hpp -+++ b/interface/vsomeip/constants.hpp -@@ -13,7 +13,8 @@ - - namespace vsomeip_v3 { - --const major_version_t DEFAULT_MAJOR = 0x00; -+// const major_version_t DEFAULT_MAJOR = 0x00; -+const major_version_t DEFAULT_MAJOR = 0x01; // works better with autosar - const minor_version_t DEFAULT_MINOR = 0x00000000; - const ttl_t DEFAULT_TTL = 0xFFFFFF; // "until next reboot" - diff --git a/someip2val/patches/003-vsomeip-application-debugs.patch b/someip2val/patches/003-vsomeip-application-debugs.patch deleted file mode 100644 index 05045670..00000000 --- a/someip2val/patches/003-vsomeip-application-debugs.patch +++ /dev/null @@ -1,69 +0,0 @@ -diff --git a/implementation/runtime/src/application_impl.cpp b/implementation/runtime/src/application_impl.cpp -index aba8647..12fbd4d 100644 ---- a/implementation/runtime/src/application_impl.cpp -+++ b/implementation/runtime/src/application_impl.cpp -@@ -81,6 +81,8 @@ application_impl::application_impl(const std::string &_name) - } - - application_impl::~application_impl() { -+ VSOMEIP_INFO << "Destroying Application(" << name_ -+ << ", " << std::hex << std::setw(4) << std::setfill('0') << client_ << ")"; - runtime_->remove_application(name_); - try { - if (stop_thread_.joinable()) { -@@ -517,34 +519,43 @@ void application_impl::stop() { - stopped_ = true; - stopped_called_ = true; - for (const auto& thread : io_threads_) { -+ VSOMEIP_DEBUG << "application_impl::stop() io_threads_[] TID:" -+ << std::dec << (int)thread->native_handle(); - if (thread->get_id() == std::this_thread::get_id()) { -+ VSOMEIP_DEBUG << "application_impl::stop() stopping from io_thread TID:" -+ << std::dec << (int)thread->native_handle(); - block = false; - } - } - if (start_caller_id_ == stop_caller_id_) { -+ VSOMEIP_DEBUG << "application_impl::stop() stopping from same thread!"; - block = false; - } - } -- auto its_plugins = configuration_->get_plugins(name_); -- auto its_app_plugin_info = its_plugins.find(plugin_type_e::APPLICATION_PLUGIN); -- if (its_app_plugin_info != its_plugins.end()) { -- for (const auto& its_library : its_app_plugin_info->second) { -- auto its_application_plugin = plugin_manager::get()->get_plugin( -- plugin_type_e::APPLICATION_PLUGIN, its_library); -- if (its_application_plugin) { -- std::dynamic_pointer_cast(its_application_plugin)-> -- on_application_state_change(name_, application_plugin_state_e::STATE_STOPPED); -- } -- } -- -+ if (configuration_ == nullptr) { // don't crash if app init failed due to confugration load error -+ VSOMEIP_WARNING << "application_impl::stop() Missing configuration, avoid blocking" << std::endl; -+ block = false; - } -+ auto its_plugins = configuration_->get_plugins(name_); -+ auto its_app_plugin_info = its_plugins.find(plugin_type_e::APPLICATION_PLUGIN); -+ if (its_app_plugin_info != its_plugins.end()) { -+ for (const auto& its_library : its_app_plugin_info->second) { -+ auto its_application_plugin = plugin_manager::get()->get_plugin( -+ plugin_type_e::APPLICATION_PLUGIN, its_library); -+ if (its_application_plugin) { -+ std::dynamic_pointer_cast(its_application_plugin)-> -+ on_application_state_change(name_, application_plugin_state_e::STATE_STOPPED); -+ } -+ } - -+ } - { - std::lock_guard its_lock_start_stop(start_stop_mutex_); - stop_cv_.notify_one(); - } - - if (block) { -+ VSOMEIP_WARNING << "application_impl::stop() Blocked, waiting..." << std::endl; - std::unique_lock block_stop_lock(block_stop_mutex_); - while (!block_stopping_) { - block_stop_cv_.wait(block_stop_lock); \ No newline at end of file diff --git a/someip2val/proto/kuksa_data_broker/kuksa/val/v1/types.proto b/someip2val/proto/kuksa_data_broker/kuksa/val/v1/types.proto deleted file mode 100644 index 7e110f0a..00000000 --- a/someip2val/proto/kuksa_data_broker/kuksa/val/v1/types.proto +++ /dev/null @@ -1,286 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License 2.0 which is available at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ -syntax = "proto3"; - -package kuksa.val.v1; -import "google/protobuf/timestamp.proto"; - -option go_package = "kuksa/val/v1"; - -// Describes a VSS entry -// When requesting an entry, the amount of information returned can -// be controlled by specifying either a `View` or a set of `Field`s. -message DataEntry { - // Defines the full VSS path of the entry. - string path = 1; // [field: FIELD_PATH] - - // The value (datapoint) - Datapoint value = 2; // [field: FIELD_VALUE] - - // Actuator target (only used if the entry is an actuator) - Datapoint actuator_target = 3; // [field: FIELD_ACTUATOR_TARGET] - - // Metadata for this entry - Metadata metadata = 10; // [field: FIELD_METADATA] -} - -message Datapoint { - google.protobuf.Timestamp timestamp = 1; - - oneof value { - string string = 11; - bool bool = 12; - sint32 int32 = 13; - sint64 int64 = 14; - uint32 uint32 = 15; - uint64 uint64 = 16; - float float = 17; - double double = 18; - StringArray string_array = 21; - BoolArray bool_array = 22; - Int32Array int32_array = 23; - Int64Array int64_array = 24; - Uint32Array uint32_array = 25; - Uint64Array uint64_array = 26; - FloatArray float_array = 27; - DoubleArray double_array = 28; - } -} - -message Metadata { - // Data type - // The VSS data type of the entry (i.e. the value, min, max etc). - // - // NOTE: protobuf doesn't have int8, int16, uint8 or uint16 which means - // that these values must be serialized as int32 and uint32 respectively. - DataType data_type = 11; // [field: FIELD_METADATA_DATA_TYPE] - - // Entry type - EntryType entry_type = 12; // [field: FIELD_METADATA_ENTRY_TYPE] - - // Description - // Describes the meaning and content of the entry. - optional string description = 13; // [field: FIELD_METADATA_DESCRIPTION] - - // Comment [optional] - // A comment can be used to provide additional informal information - // on a entry. - optional string comment = 14; // [field: FIELD_METADATA_COMMENT] - - // Deprecation [optional] - // Whether this entry is deprecated. Can contain recommendations of what - // to use instead. - optional string deprecation = 15; // [field: FIELD_METADATA_DEPRECATION] - - // Unit [optional] - // The unit of measurement - optional string unit = 16; // [field: FIELD_METADATA_UNIT] - - // Value restrictions [optional] - // Restrict which values are allowed. - // Only restrictions matching the DataType {datatype} above are valid. - ValueRestriction value_restriction = 17; // [field: FIELD_METADATA_VALUE_RESTRICTION] - - // Entry type specific metadata - oneof entry_specific { - Actuator actuator = 20; // [field: FIELD_METADATA_ACTUATOR] - Sensor sensor = 30; // [field: FIELD_METADATA_SENSOR] - Attribute attribute = 40; // [field: FIELD_METADATA_ATTRIBUTE] - } -} - -/////////////////////// -// Actuator specific fields -message Actuator { - // Nothing for now -} - -//////////////////////// -// Sensor specific -message Sensor { - // Nothing for now -} - -//////////////////////// -// Attribute specific -message Attribute { - // Nothing for now. -} - -// Value restriction -// -// One ValueRestriction{type} for each type, since -// they don't make sense unless the types match -// -message ValueRestriction { - oneof type { - ValueRestrictionString string = 21; - // For signed VSS integers - ValueRestrictionInt signed = 22; - // For unsigned VSS integers - ValueRestrictionUint unsigned = 23; - // For floating point VSS values (float and double) - ValueRestrictionFloat floating_point = 24; - } -} - -message ValueRestrictionInt { - optional sint64 min = 1; - optional sint64 max = 2; - repeated sint64 allowed_values = 3; -} - -message ValueRestrictionUint { - optional uint64 min = 1; - optional uint64 max = 2; - repeated uint64 allowed_values = 3; -} - -message ValueRestrictionFloat { - optional double min = 1; - optional double max = 2; - - // allowed for doubles/floats not recommended - repeated double allowed_values = 3; -} - -// min, max doesn't make much sense for a string -message ValueRestrictionString { - repeated string allowed_values = 3; -} - -// VSS Data type of a signal -// -// Protobuf doesn't support int8, int16, uint8 or uint16. -// These are mapped to int32 and uint32 respectively. -// -enum DataType { - DATA_TYPE_UNSPECIFIED = 0; - DATA_TYPE_STRING = 1; - DATA_TYPE_BOOLEAN = 2; - DATA_TYPE_INT8 = 3; - DATA_TYPE_INT16 = 4; - DATA_TYPE_INT32 = 5; - DATA_TYPE_INT64 = 6; - DATA_TYPE_UINT8 = 7; - DATA_TYPE_UINT16 = 8; - DATA_TYPE_UINT32 = 9; - DATA_TYPE_UINT64 = 10; - DATA_TYPE_FLOAT = 11; - DATA_TYPE_DOUBLE = 12; - DATA_TYPE_TIMESTAMP = 13; - DATA_TYPE_STRING_ARRAY = 20; - DATA_TYPE_BOOLEAN_ARRAY = 21; - DATA_TYPE_INT8_ARRAY = 22; - DATA_TYPE_INT16_ARRAY = 23; - DATA_TYPE_INT32_ARRAY = 24; - DATA_TYPE_INT64_ARRAY = 25; - DATA_TYPE_UINT8_ARRAY = 26; - DATA_TYPE_UINT16_ARRAY = 27; - DATA_TYPE_UINT32_ARRAY = 28; - DATA_TYPE_UINT64_ARRAY = 29; - DATA_TYPE_FLOAT_ARRAY = 30; - DATA_TYPE_DOUBLE_ARRAY = 31; - DATA_TYPE_TIMESTAMP_ARRAY = 32; -} - -// Entry type -enum EntryType { - ENTRY_TYPE_UNSPECIFIED = 0; - ENTRY_TYPE_ATTRIBUTE = 1; - ENTRY_TYPE_SENSOR = 2; - ENTRY_TYPE_ACTUATOR = 3; -} - -// A `View` specifies a set of fields which should -// be populated in a `DataEntry` (in a response message) -enum View { - VIEW_UNSPECIFIED = 0; // Unspecified. Equivalent to VIEW_CURRENT_VALUE unless `fields` are explicitly set. - VIEW_CURRENT_VALUE = 1; // Populate DataEntry with value. - VIEW_TARGET_VALUE = 2; // Populate DataEntry with actuator target. - VIEW_METADATA = 3; // Populate DataEntry with metadata. - VIEW_FIELDS = 10; // Populate DataEntry only with requested fields. - VIEW_ALL = 20; // Populate DataEntry with everything. -} - -// A `Field` corresponds to a specific field of a `DataEntry`. -// -// It can be used to: -// * populate only specific fields of a `DataEntry` response. -// * specify which fields of a `DataEntry` should be set as -// part of a `Set` request. -// * subscribe to only specific fields of a data entry. -// * convey which fields of an updated `DataEntry` have changed. -enum Field { - FIELD_UNSPECIFIED = 0; // "*" i.e. everything - FIELD_PATH = 1; // path - FIELD_VALUE = 2; // value - FIELD_ACTUATOR_TARGET = 3; // actuator_target - FIELD_METADATA = 10; // metadata.* - FIELD_METADATA_DATA_TYPE = 11; // metadata.data_type - FIELD_METADATA_DESCRIPTION = 12; // metadata.description - FIELD_METADATA_ENTRY_TYPE = 13; // metadata.entry_type - FIELD_METADATA_COMMENT = 14; // metadata.comment - FIELD_METADATA_DEPRECATION = 15; // metadata.deprecation - FIELD_METADATA_UNIT = 16; // metadata.unit - FIELD_METADATA_VALUE_RESTRICTION = 17; // metadata.value_restriction.* - FIELD_METADATA_ACTUATOR = 20; // metadata.actuator.* - FIELD_METADATA_SENSOR = 30; // metadata.sensor.* - FIELD_METADATA_ATTRIBUTE = 40; // metadata.attribute.* -} - -// Error response shall be an HTTP-like code. -// Should follow https://www.w3.org/TR/viss2-transport/#status-codes. -message Error { - uint32 code = 1; - string reason = 2; - string message = 3; -} - -// Used in get/set requests to report errors for specific entries -message DataEntryError { - string path = 1; // vss path - Error error = 2; -} - -message StringArray { - repeated string values = 1; -} - -message BoolArray { - repeated bool values = 1; -} - -message Int32Array { - repeated sint32 values = 1; -} - -message Int64Array { - repeated sint64 values = 1; -} - -message Uint32Array { - repeated uint32 values = 1; -} - -message Uint64Array { - repeated uint64 values = 1; -} - -message FloatArray { - repeated float values = 1; -} - -message DoubleArray { - repeated double values = 1; -} diff --git a/someip2val/proto/kuksa_data_broker/kuksa/val/v1/val.proto b/someip2val/proto/kuksa_data_broker/kuksa/val/v1/val.proto deleted file mode 100644 index 71d5597a..00000000 --- a/someip2val/proto/kuksa_data_broker/kuksa/val/v1/val.proto +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License 2.0 which is available at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -syntax = "proto3"; - -package kuksa.val.v1; - -option go_package = "kuksa/val/v1"; - -import "kuksa/val/v1/types.proto"; - -// Note on authorization: -// Tokens (auth-token or auth-uuid) are sent as (GRPC / http2) metadata. -// -// The auth-token is a JWT compliant token as the examples found here: -// https://github.com/eclipse/kuksa.val/tree/master/kuksa_certificates/jwt -// -// See also https://github.com/eclipse/kuksa.val/blob/master/doc/jwt.md -// -// Upon reception of auth-token, server shall generate an auth-uuid in metadata -// that the client can use instead of auth-token in subsequent calls. - -service VAL { - // Get entries - rpc Get(GetRequest) returns (GetResponse); - - // Set entries - rpc Set(SetRequest) returns (SetResponse); - - // Subscribe to a set of entries - // - // Returns a stream of notifications. - // - // InvalidArgument is returned if the request is malformed. - rpc Subscribe(SubscribeRequest) returns (stream SubscribeResponse); - - // Shall return information that allows the client to determine - // what server/server implementation/version it is talking to - // eg. kuksa-databroker 0.5.1 - rpc GetServerInfo(GetServerInfoRequest) returns (GetServerInfoResponse); -} - -// Define which data we want -message EntryRequest { - string path = 1; - View view = 2; - repeated Field fields = 3; -} - -// Request a set of entries. -message GetRequest { - repeated EntryRequest entries = 1; -} - -// Global errors are specified in `error`. -// Errors for individual entries are specified in `errors`. -message GetResponse { - repeated DataEntry entries = 1; - repeated DataEntryError errors = 2; - Error error = 3; -} - -// Define the data we want to set -message EntryUpdate { - DataEntry entry = 1; - repeated Field fields = 2; -} - -// A list of entries to be updated -message SetRequest { - repeated EntryUpdate updates = 1; -} - -// Global errors are specified in `error`. -// Errors for individual entries are specified in `errors`. -message SetResponse { - Error error = 1; - repeated DataEntryError errors = 2; -} - -// Define what to subscribe to -message SubscribeEntry { - string path = 1; - View view = 2; - repeated Field fields = 3; -} - -// Subscribe to changes in datapoints. -message SubscribeRequest { - repeated SubscribeEntry entries = 1; -} - -// A subscription response -message SubscribeResponse { - repeated EntryUpdate updates = 1; -} - -message GetServerInfoRequest { - // Nothing yet -} - -message GetServerInfoResponse { - string name = 1; - string version = 2; -} diff --git a/someip2val/proto/kuksa_data_broker/sdv/databroker/v1/broker.proto b/someip2val/proto/kuksa_data_broker/sdv/databroker/v1/broker.proto deleted file mode 100644 index f8ffaf80..00000000 --- a/someip2val/proto/kuksa_data_broker/sdv/databroker/v1/broker.proto +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License 2.0 which is available at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -syntax = "proto3"; - -package sdv.databroker.v1; - -import "sdv/databroker/v1/types.proto"; - -service Broker { - // Request a set of datapoints (values) - // - // Returns a list of requested data points. - // - // InvalidArgument is returned if the request is malformed. - rpc GetDatapoints(GetDatapointsRequest) returns (GetDatapointsReply); - - // Set a datapoint (values) - rpc SetDatapoints(SetDatapointsRequest) returns (SetDatapointsReply); - - // Subscribe to a set of data points or conditional expressions - // using the Data Broker Query Syntax (described in QUERY.md) - // - // Returns a stream of replies. - // - // InvalidArgument is returned if the request is malformed. - rpc Subscribe(SubscribeRequest) returns (stream SubscribeReply); - - // Request the metadata of a set of datapoints - // - // Returns metadata of the requested data points that exist. - rpc GetMetadata(GetMetadataRequest) returns (GetMetadataReply); -} - -message GetDatapointsRequest { - // A list of requested data points. - repeated string datapoints = 1; -} - -message GetDatapointsReply { - // Contains the values of the requested data points. - // If a requested data point is not available, the corresponding Datapoint - // will have the respective failure value set. - map datapoints = 1; -} - -message SetDatapointsRequest { - // A map of data points to set - map datapoints = 1; -} - -message SetDatapointsReply { - // A map of errors (if any) - map errors = 1; -} - -message SubscribeRequest { - // Subscribe to a set of data points (or expressions) described - // by the provided query. - // The query syntax is a subset of SQL and is described in more - // detail in the QUERY.md file. - string query = 2; -} - -message SubscribeReply { - // Contains the fields specified by the query. - // If a requested data point value is not available, the corresponding - // Datapoint will have it's respective failure value set. - map fields = 1; -} - -message GetMetadataRequest { - // Request metadata for a list of data points referenced by their names. - // e.g. "Vehicle.Cabin.Seat.Row1.Pos1.Position" or "Vehicle.Speed". - // - // If no names are provided, metadata for all known data points will be - // returned. - repeated string names = 1; -} - -message GetMetadataReply { - // Contains metadata of the requested data points. If a data point - // doesn't exist (i.e. not known to the Data Broker) the corresponding - // Metadata isn't part of the returned list. - repeated Metadata list = 1; -} diff --git a/someip2val/proto/kuksa_data_broker/sdv/databroker/v1/collector.proto b/someip2val/proto/kuksa_data_broker/sdv/databroker/v1/collector.proto deleted file mode 100644 index c67a5def..00000000 --- a/someip2val/proto/kuksa_data_broker/sdv/databroker/v1/collector.proto +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License 2.0 which is available at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -syntax = "proto3"; - -import "sdv/databroker/v1/types.proto"; - -package sdv.databroker.v1; - -service Collector { - // Register new datapoint (metadata) - // - // If the registration of at least one of the passed data point fails, the overall registration - // is rejected and the gRPC status code ABORTED is returned (to indicate the "aborted" registration). - // The details, which data point(s) caused the failure and the reason, is passed in back in human- - // readable form in the status message. Possible failure resaons are: - // * PERMISSION_DENIED - Not allowed to register this name - // * ALREADY_REGISTERED - The data point is already registered by some other feeder - // * RE_REGISTRATION_MISMATCH - Already registered by this feeder but with differing metadata - // * INVALID_NAME - The passed name of the datapoint has an invalid structure - // * INVALID_VALUE_TYPE - The passed ValueType is not supported - // * INVALID_CHANGE_TYPE - The passed ChangeType is not supported - rpc RegisterDatapoints(RegisterDatapointsRequest) returns (RegisterDatapointsReply); - - // Provide a set of updated datapoint values to the broker. - // This is the unary equivalent of `StreamDatapoints` below and is better suited for cases - // where the frequency of updates is rather low. - // - // NOTE: The values provided in a single request are handled as a single update in the - // data broker. This ensures that any clients requesting (or subscribing to) a set of - // datapoints will get a consistent update, i.e. that either all values are updated or - // none are. - // - // Returns: any errors encountered updating the datapoints - // - rpc UpdateDatapoints(UpdateDatapointsRequest) returns (UpdateDatapointsReply); - - // Provide a stream with updated datapoint values to the broker. - // This is the streaming equivalent of `UpdateDatapoints` above and is better suited for - // cases where the frequency of updates is high. - // - // NOTE: The values provided in a single request are handled as a single update in the - // data broker. This ensures that any clients requesting (or subscribing to) a set of - // datapoints will get a consistent update, i.e. that either all values are updated or - // none are. - // - // Returns: any errors encountered updating the datapoints - // - rpc StreamDatapoints(stream StreamDatapointsRequest) returns (stream StreamDatapointsReply); -} - -message UpdateDatapointsRequest { - map datapoints = 1; -} - -message UpdateDatapointsReply { - map errors = 1; // If empty, everything went well -} - -message StreamDatapointsRequest { - map datapoints = 1; -} - -message StreamDatapointsReply { - map errors = 1; // If empty, everything went well -} - -message RegisterDatapointsRequest { - repeated RegistrationMetadata list = 1; -} - -message RegistrationMetadata { - // Name of the data point - // (e.g. "Vehicle.Cabin.Seat.Row1.Pos1.Position" or "Vehicle.Speed") - string name = 1; - DataType data_type = 2; - string description = 3; - ChangeType change_type = 4; - - // int32 min_update_hz = 10; // Only for CONTINUOUS - // int32 max_update_hz = 11; // Only for CONTINUOUS -}; - -message RegisterDatapointsReply { - // Maps each data point name passed in RegisterDatapointsRequest to a data point id - map results = 1; -} diff --git a/someip2val/proto/kuksa_data_broker/sdv/databroker/v1/types.proto b/someip2val/proto/kuksa_data_broker/sdv/databroker/v1/types.proto deleted file mode 100644 index ca180073..00000000 --- a/someip2val/proto/kuksa_data_broker/sdv/databroker/v1/types.proto +++ /dev/null @@ -1,160 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License 2.0 which is available at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -syntax = "proto3"; - -import "google/protobuf/timestamp.proto"; - -package sdv.databroker.v1; - -// Data type of a signal -// -// Protobuf doesn't support int8, int16, uint8 or uint16. -// These are mapped to sint32 and uint32 respectively. -// -enum DataType { - STRING = 0; - BOOL = 1; - INT8 = 2; - INT16 = 3; - INT32 = 4; - INT64 = 5; - UINT8 = 6; - UINT16 = 7; - UINT32 = 8; - UINT64 = 9; - FLOAT = 10; - DOUBLE = 11; - TIMESTAMP = 12; - STRING_ARRAY = 20; - BOOL_ARRAY = 21; - INT8_ARRAY = 22; - INT16_ARRAY = 23; - INT32_ARRAY = 24; - INT64_ARRAY = 25; - UINT8_ARRAY = 26; - UINT16_ARRAY = 27; - UINT32_ARRAY = 28; - UINT64_ARRAY = 29; - FLOAT_ARRAY = 30; - DOUBLE_ARRAY = 31; - TIMESTAMP_ARRAY = 32; -} - -enum DatapointError { - UNKNOWN_DATAPOINT = 0; - INVALID_TYPE = 1; - ACCESS_DENIED = 2; - INTERNAL_ERROR = 3; - OUT_OF_BOUNDS = 4; -} - -enum EntryType { - ENTRY_TYPE_UNSPECIFIED = 0; - ENTRY_TYPE_SENSOR = 1; - ENTRY_TYPE_ACTUATOR = 2; - ENTRY_TYPE_ATTRIBUTE = 3; -} - -enum ChangeType { - STATIC = 0; // Value never changes - ON_CHANGE = 1; // Updates are provided every time the value changes (i.e. - // window is open / closed) - CONTINUOUS = 2; // Value is updated continuously. Broker needs to tell - // provider the preferred (update) frequency. -} - -message StringArray { - repeated string values = 1; -} - -message BoolArray { - repeated bool values = 1; -} - -message Int32Array { - repeated sint32 values = 1; -} - -message Int64Array { - repeated sint64 values = 1; -} - -message Uint32Array { - repeated uint32 values = 1; -} - -message Uint64Array { - repeated uint64 values = 1; -} - -message FloatArray { - repeated float values = 1; -} - -message DoubleArray { - repeated double values = 1; -} - -message Datapoint { - // Timestamp of the value - google.protobuf.Timestamp timestamp = 1; - - // values - oneof value { - Failure failure_value = 10; - string string_value = 11; - bool bool_value = 12; - sint32 int32_value = 13; - sint64 int64_value = 14; - uint32 uint32_value = 15; - uint64 uint64_value = 16; - float float_value = 17; - double double_value = 18; - StringArray string_array = 21; - BoolArray bool_array = 22; - Int32Array int32_array = 23; - Int64Array int64_array = 24; - Uint32Array uint32_array = 25; - Uint64Array uint64_array = 26; - FloatArray float_array = 27; - DoubleArray double_array = 28; - } - - enum Failure { - // The data point is known, but doesn't have a valid value - INVALID_VALUE = 0; - // The data point is known, but no value is available - NOT_AVAILABLE = 1; - // Unknown datapoint - UNKNOWN_DATAPOINT = 2; - // Access denied - ACCESS_DENIED = 3; - // Unexpected internal error - INTERNAL_ERROR = 4; - } -} - -message Metadata { - // Id to be used in "get" and "subscribe" requests. Ids stay valid during - // one power cycle, only. - int32 id = 1; - EntryType entry_type = 2; - string name = 4; - DataType data_type = 5; - ChangeType change_type = 6; // CONTINUOUS or STATIC or ON_CHANGE - string description = 7; - - // int32 min_update_hz = 10; // Only for CONTINUOUS - // int32 max_update_hz = 11; // Only for CONTINUOUS -}; diff --git a/someip2val/src/CMakeLists.txt b/someip2val/src/CMakeLists.txt deleted file mode 100644 index 2e7d1847..00000000 --- a/someip2val/src/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -#******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -#*******************************************************************************/ - -add_subdirectory(lib/broker_feeder) -add_subdirectory(lib/someip_client) -add_subdirectory(lib/wiper_poc) - -add_subdirectory(someip_feeder) - -# example someip service sending wiper events -add_subdirectory(examples/wiper_service) \ No newline at end of file diff --git a/someip2val/src/examples/wiper_service/CMakeLists.txt b/someip2val/src/examples/wiper_service/CMakeLists.txt deleted file mode 100644 index f4ea2b96..00000000 --- a/someip2val/src/examples/wiper_service/CMakeLists.txt +++ /dev/null @@ -1,68 +0,0 @@ -#******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -#*******************************************************************************/ - -cmake_minimum_required (VERSION 3.11) - -# Project -project(WiperExamples CXX) - -# external dependencies -# find_package(Boost 1.55 COMPONENTS system thread filesystem REQUIRED) -if (NOT vsomeip3_POPULATED) - find_package(vsomeip3) -endif() -find_package(Threads REQUIRED) - -# add_definitions(-DVSOMEIP_ENABLE_SIGNAL_HANDLING=1) - -# Wiper POC -add_executable(wiper_service - wiper_server.cc - wiper_sim.cc -) -target_link_libraries(wiper_service - wiper_poc - vsomeip3 - # ${Boost_LIBRARIES} - # ${DL_LIBRARY} - pthread -) -target_include_directories(wiper_service - PUBLIC - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} -) - -add_executable(wiper_client - wiper_client.cc -) -target_include_directories(wiper_client - PUBLIC - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} -) -target_link_libraries(wiper_client - wiper_poc - vsomeip3 - # ${Boost_LIBRARIES} - # ${DL_LIBRARY} - pthread -) - -install(TARGETS - wiper_service - wiper_client - RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" -) - -################################################################################################### diff --git a/someip2val/src/examples/wiper_service/wiper_client.cc b/someip2val/src/examples/wiper_service/wiper_client.cc deleted file mode 100644 index ad56e6c5..00000000 --- a/someip2val/src/examples/wiper_service/wiper_client.cc +++ /dev/null @@ -1,477 +0,0 @@ -/******************************************************************************** -* Copyright (c) 2022 Contributors to the Eclipse Foundation -* -* See the NOTICE file(s) distributed with this work for additional -* information regarding copyright ownership. -* -* This program and the accompanying materials are made available under the -* terms of the Apache License 2.0 which is available at -* http://www.apache.org/licenses/LICENSE-2.0 -* -* SPDX-License-Identifier: Apache-2.0 -********************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "wiper_poc.h" - -static int debug = ::getenv("DEBUG") ? ::atoi(::getenv("DEBUG")) : 1; - -using namespace sdv::someip::wiper; - -// fw decl -std::string message_type_to_string(vsomeip::message_type_e msg_type); - -// struct request_status_t { -// vsomeip::return_code_e code; -// std::shared_ptr payload; -// }; - -class wiper_client { - -private: - std::shared_ptr app_; - bool use_tcp_; - bool use_vss_; - bool use_events_; - bool is_registered_; - t_WiperRequest vss_req_; // vss request to send once - - bool blocked_; - bool running_; - - std::mutex mutex_; - std::condition_variable condition_; - - std::mutex request_mutex_; - std::condition_variable request_condition_; - // request_status_t request_status_; - - // blocked_ / is_offered_ must be initialized before starting the threads! - // std::thread request_thread_; - -public: - wiper_client(bool _use_tcp, bool _use_events=true, bool _use_vss=false, t_WiperRequest _vss={}) : - app_(vsomeip::runtime::get()->create_application()) - , use_tcp_(_use_tcp) - , use_vss_(_use_vss) - , vss_req_(_vss) - , use_events_(_use_events) - , is_registered_(false) - , blocked_(false) - , running_(true) - //, request_thread_(std::bind(&wiper_client::run, this)) - { - // pthread_setname_np(request_thread_.native_handle(), "request_thread"); - } - - bool init() { - std::lock_guard its_lock(mutex_); - if (!app_->init()) { - std::cerr << "Couldn't initialize application" << std::endl; - return false; - } - std::printf("### Client settings [cli_id=0x%04x, app='%s', protocol=%s, use_events=%d, use_vss=%d, routing=%d]\n", - app_->get_client() , app_->get_name().c_str(), - (use_tcp_ ? "TCP" : "UDP"), - use_events_, use_vss_, - app_->is_routing()); - - app_->register_state_handler( - std::bind(&wiper_client::on_state, this, - std::placeholders::_1)); - - app_->register_message_handler( - vsomeip::ANY_SERVICE, vsomeip::ANY_INSTANCE, vsomeip::ANY_METHOD, -// WIPER_SERVICE_ID, WIPER_INSTANCE_ID, WIPER_METHOD_ID, - std::bind(&wiper_client::on_message, this, - std::placeholders::_1)); - - if (use_events_) { - app_->register_availability_handler( - WIPER_SERVICE_ID, WIPER_INSTANCE_ID, - std::bind(&wiper_client::on_availability, - this, - std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), - WIPER_SERVICE_MAJOR, WIPER_SERVICE_MINOR); - } - if (use_vss_) { - app_->register_availability_handler( - WIPER_VSS_SERVICE_ID, WIPER_VSS_INSTANCE_ID, - std::bind(&wiper_client::on_vss_availability, - this, - std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), - WIPER_VSS_SERVICE_MAJOR, WIPER_VSS_SERVICE_MINOR); - } - - blocked_ = true; - condition_.notify_one(); - - return true; - } - - // call is blocking current thread - void start() { - app_->start(); - } - - /* - * Handle signal to shutdown - */ - void stop() { - running_ = false; - blocked_ = true; - condition_.notify_one(); - request_condition_.notify_one(); - - app_->clear_all_handler(); - - if (use_events_) { - // cleanup event service - app_->unsubscribe(WIPER_SERVICE_ID, WIPER_INSTANCE_ID, WIPER_EVENTGROUP_ID); - app_->release_event(WIPER_SERVICE_ID, WIPER_INSTANCE_ID, WIPER_EVENT_ID); - app_->release_service(WIPER_SERVICE_ID, WIPER_INSTANCE_ID); - } - - if (use_vss_) { - // cleanup req/resp service - app_->release_service(WIPER_VSS_SERVICE_ID, WIPER_VSS_INSTANCE_ID); - } - - app_->stop(); - } - - void on_state(vsomeip::state_type_e _state) { - if (_state == vsomeip::state_type_e::ST_REGISTERED) { - if (use_events_) { - std::printf("[on_state] Requesting WiperEvent [%04x.%04x] v%u.%u\n", - WIPER_SERVICE_ID, - WIPER_INSTANCE_ID, - WIPER_SERVICE_MAJOR, - WIPER_SERVICE_MINOR); - app_->request_service( - WIPER_SERVICE_ID, - WIPER_INSTANCE_ID, - WIPER_SERVICE_MAJOR, - WIPER_SERVICE_MINOR); - } - if (use_vss_) { - std::printf("[on_state] Requesting VSS [%04x.%04x] v%u.%u\n", - WIPER_VSS_SERVICE_ID, - WIPER_VSS_INSTANCE_ID, - WIPER_VSS_SERVICE_MAJOR, - WIPER_VSS_SERVICE_MINOR); - app_->request_service( - WIPER_VSS_SERVICE_ID, - WIPER_VSS_INSTANCE_ID, - WIPER_VSS_SERVICE_MAJOR, - WIPER_VSS_SERVICE_MINOR); - } - is_registered_ = true; - } - } - - void on_availability(vsomeip::service_t _service, vsomeip::instance_t _instance, bool _is_available) { - std::cout << "### Wiper Event Service [" - << std::setw(4) << std::setfill('0') << std::hex << _service << "." << _instance - << "] is " - << (_is_available ? "available." : "NOT available.") - << std::endl; - - if (_is_available && use_events_) { - std::set its_groups; - its_groups.insert(WIPER_EVENTGROUP_ID); - app_->request_event( - WIPER_SERVICE_ID, WIPER_INSTANCE_ID, WIPER_EVENT_ID, - its_groups, vsomeip::event_type_e::ET_FIELD, - (use_tcp_ ? vsomeip::reliability_type_e::RT_RELIABLE : vsomeip::reliability_type_e::RT_UNRELIABLE)); - - app_->subscribe(WIPER_SERVICE_ID, WIPER_INSTANCE_ID, WIPER_EVENTGROUP_ID, WIPER_SERVICE_MAJOR); - } - } - - void on_vss_availability(vsomeip::service_t _service, vsomeip::instance_t _instance, bool _is_available) { - std::cout << "### VSS Service [" - << std::setw(4) << std::setfill('0') << std::hex << _service << "." << _instance - << "] is " - << (_is_available ? "available." : "NOT available.") - << std::endl; - - if (_is_available && use_vss_) { - wiper_vss_set(vss_req_); - } - } - - void on_message(const std::shared_ptr &_response) { - std::stringstream its_message; - sdv::someip::wiper::t_Event event; - - its_message << "Received a " - << message_type_to_string(_response->get_message_type()) << " for [" - << std::setw(4) << std::setfill('0') << std::hex - << _response->get_service() << "." - << std::setw(4) << std::setfill('0') << std::hex - << _response->get_instance() << "." - << std::setw(4) << std::setfill('0') << std::hex - << _response->get_method() << "] to Client/Session [" - << std::setw(4) << std::setfill('0') << std::hex - << _response->get_client() << "/" - << std::setw(4) << std::setfill('0') << std::hex - << _response->get_session() - << "] = "; - std::shared_ptr its_payload = - _response->get_payload(); - its_message << "(" << std::dec << its_payload->get_length() << ") "; - - if (debug > 0) { - its_message << sdv::someip::wiper::bytes_to_string(its_payload->get_data(), its_payload->get_length()); - } - // for (uint32_t i = 0; i < its_payload->get_length(); ++i) - // its_message << std::hex << std::setw(2) << std::setfill('0') - // << (int) its_payload->get_data()[i] << " "; - std::cout << its_message.str() << std::endl; - - if (_response->get_service() == WIPER_SERVICE_ID && - _response->get_instance() == WIPER_INSTANCE_ID && - _response->get_method() == WIPER_EVENT_ID) - { - sdv::someip::wiper::deserialize_event( - reinterpret_cast(its_payload->get_data()), - its_payload->get_length(), - event); - sdv::someip::wiper::print_status("###", event); - } else - if (_response->get_service() == WIPER_VSS_SERVICE_ID && - _response->get_instance() == WIPER_VSS_INSTANCE_ID && - _response->get_method() == WIPER_VSS_METHOD_ID) - { - // std::lock_guard its_lock(request_mutex_); - // request_status_.code = _response->get_return_code(); - // request_status_.payload = _response->get_payload(); - std::cout << "### Got VSS Reply: { " - << "rc:" << std::dec << (int)_response->get_return_code() - << ", 0x[ " - << sdv::someip::wiper::bytes_to_string( - _response->get_payload()->get_data(), - _response->get_payload()->get_length()) - << "] }" << std::endl; - request_condition_.notify_one(); - - if (!use_events_) { - std::cout << "### Stopping app (no events)." << std::endl; - stop(); - } - - } else { - std::cout << "### Got message from unknown service!" << std::endl; - } - } - - void run() { - // request/response thread - if (debug > 0) std::cout << "// TH: waiting for init..." << std::endl; - std::unique_lock its_lock(mutex_); - while (running_ && !blocked_) - condition_.wait(its_lock); - if (debug > 0) std::cout << "// TH: init done." << std::endl; - - int vss_index = 0; - t_WiperRequest vss_reqests[] = { - { 40, 80.0f, e_WiperMode::WIPE }, - { 50, 20.0f, e_WiperMode::WIPE }, - { 30, 10.0f, e_WiperMode::WIPE }, - { 30, 2.0f, e_WiperMode::WIPE }, - { 70, 2.0f, e_WiperMode::EMERGENCY_STOP } - }; - - while (running_) { - // sleep some time, then send vss request - std::cout << "TH: Sendng VSS[" << vss_index << "] ..." << std::endl; - bool res = wiper_vss_set(vss_reqests[vss_index++]); - if (vss_index > 5) { - vss_index = 0; - } - for (int i = 0; i<5 && running_; i++) { - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - } - } - - } - - bool wiper_vss_set(t_WiperRequest vss_reqest, bool wait_response = false) { - - std::unique_lock its_lock(request_mutex_); - - // CreatePayload for VSS Request - uint8_t data[WIPER_SET_PAYLOAD_SIZE]; - if (!sdv::someip::wiper::serialize_vss_request(data, sizeof(data), vss_reqest)) { - std::cerr << "Failed serializing VSS data!" << std::endl; - return false; - } - // Create a new request - std::shared_ptr rq = vsomeip::runtime::get()->create_request(); - // Set the VSS service as target of the request - rq->set_service(WIPER_VSS_SERVICE_ID); - rq->set_instance(WIPER_VSS_INSTANCE_ID); - rq->set_method(WIPER_VSS_METHOD_ID); - // rq->set_interface_version(WIPER_VSS_SERVICE_MAJOR); not needed, set to vsomeip_v3::sd::interface_version(0x1) - - std::shared_ptr pl = vsomeip::runtime::get()->create_payload(); - pl->set_data(data, sizeof(data)); - rq->set_payload(pl); - // Send the request to the service. Response will be delivered to the - // registered message handler - std::cout << "### Sending VSS Request: " - << sdv::someip::wiper::vss_request_to_string(vss_reqest) - << std::endl; - app_->send(rq); - std::cout << "### VSS Request sent." << std::endl; - - if (wait_response) { - if (debug > 0) std::cout << "// waiting for reply..." << std::endl; - condition_.wait(its_lock); - if (debug > 0) std::cout << "// waiting for reply..." << std::endl; - } - - return true; - } - -}; - - -std::string message_type_to_string(vsomeip::message_type_e msg_type) { - switch (msg_type) { - case vsomeip::message_type_e::MT_ERROR: - return "Error"; - case vsomeip::message_type_e::MT_ERROR_ACK: - return "Error/ack"; - case vsomeip::message_type_e::MT_NOTIFICATION: - return "Notification"; - case vsomeip::message_type_e::MT_NOTIFICATION_ACK: - return "Notification/ack"; - case vsomeip::message_type_e::MT_REQUEST: - return "Request"; - case vsomeip::message_type_e::MT_REQUEST_ACK: - return "Request/ack"; - case vsomeip::message_type_e::MT_REQUEST_NO_RETURN: - return "Request/no_ret"; - case vsomeip::message_type_e::MT_REQUEST_NO_RETURN_ACK: - return "Request/no_ret/ack"; - case vsomeip::message_type_e::MT_RESPONSE: - return "Response"; - case vsomeip::message_type_e::MT_RESPONSE_ACK: - return "Response/ack"; - default: - std::stringstream its_message; - its_message << "Unknown <0x" << std::hex << (int)msg_type << ">"; - return its_message.str(); - } -} - - -wiper_client *wiper_client_ptr(nullptr); -void handle_signal(int _signal) { - if (wiper_client_ptr != nullptr && - (_signal == SIGINT || _signal == SIGTERM)) - wiper_client_ptr->stop(); -} - - -int main(int argc, char **argv) { - - // default values - bool use_tcp = false; - bool use_vss = false; - bool use_events = true; - - uint8_t vss_freq = 40; - float vss_pos = 60.0f; - e_WiperMode vss_mode = e_WiperMode::WIPE; - - std::string arg_tcp_enable("--tcp"); - std::string arg_udp_enable("--udp"); - - - std::string arg_vss_mode("--mode"); - std::string arg_vss_freq("--freq"); - std::string arg_vss_pos("--pos"); - - std::string arg_vss_only("--vss"); - - int i = 1; - while (i < argc) { - if (arg_tcp_enable == argv[i]) { - use_tcp = true; - } else if (arg_udp_enable == argv[i]) { - use_tcp = false; - } else if (arg_vss_only == argv[i]) { - use_events = false; - use_vss = true; // fallback to defaults - if (debug > 1) std::cout << " // [main] use_events: " << use_events << std::endl; - } else if (arg_vss_mode == argv[i] && i + 1 < argc) { - vss_mode = (e_WiperMode)atoi(argv[++i]); - if (debug > 1) std::cout << " // [main] vss_mode: " << (int)vss_mode << std::endl; - use_vss = true; - } else if (arg_vss_freq == argv[i] && i + 1 < argc) { - vss_freq = atoi(argv[++i]); - if (debug > 1) std::cout << " // [main] vss_freq: " << std::dec << (int)vss_freq << std::endl; - use_vss = true; - } else if (arg_vss_pos == argv[i] && i + 1 < argc) { - vss_pos = atof(argv[++i]); - if (debug > 1) std::cout << " // [main] vss_pos: " << vss_pos << std::endl; - use_vss = true; - } else { - std::cout << "Usage: " << argv[0] << " {CONNECTION} {VSS_OPTIONS} " << std::endl; - std::cout << std::endl; - std::cout << "CONNECTION:" << std::endl; - std::cout << "\t --tcp \tUse reliable Some/IP endpoints" << std::endl; - std::cout << "\t --udp \tUse unreliable Some/IP endpoints. Default:true" << std::endl; - std::cout << std::endl; - std::cout << "VSS_OPTIONS:" << std::endl; - std::cout << "\t --vss \tOnly Set Wiper Mode (no events)" << std::endl; - std::cout << "\t --mode \tSet Wiper Mode (0=PLANT, 1=STOP, 2=WIPE, 3=EMERGENCY). Default:2" << std::endl; - std::cout << "\t --freq \tSet Wiper Frequency [0..90], Default:40 " << std::endl; - std::cout << "\t --pos \tSet Wiper Position (0.0..180.0). Default:60.0" << std::endl; - std::cout << std::endl; - exit(1); - } - i++; - } - - // sanity checks for VSOMEIP environment - const char* app_name = ::getenv("VSOMEIP_APPLICATION_NAME"); - if (!app_name) { - std::cerr << "Environment variable VSOMEIP_APPLICATION_NAME not set!" << std::endl; - return 1; - } - - const char* app_config = ::getenv("VSOMEIP_CONFIGURATION"); - if (!app_config) { - std::cerr << "Environment variable VSOMEIP_CONFIGURATION not set!" << std::endl; - return 1; - } - - t_WiperRequest vss = { vss_freq, vss_pos, vss_mode }; - if (debug > 1 && use_vss) { - std::cout << " // [main] Setting VSS : " << vss_request_to_string(vss) << std::endl; - } - wiper_client client(use_tcp, use_events, use_vss, vss); - wiper_client_ptr = &client; - signal(SIGINT, handle_signal); - signal(SIGTERM, handle_signal); - - if (client.init()) { - client.start(); - return 0; - } else { - return 1; - } -} diff --git a/someip2val/src/examples/wiper_service/wiper_server.cc b/someip2val/src/examples/wiper_service/wiper_server.cc deleted file mode 100644 index 697baadd..00000000 --- a/someip2val/src/examples/wiper_service/wiper_server.cc +++ /dev/null @@ -1,590 +0,0 @@ -/******************************************************************************** -* Copyright (c) 2022 Contributors to the Eclipse Foundation -* -* See the NOTICE file(s) distributed with this work for additional -* information regarding copyright ownership. -* -* This program and the accompanying materials are made available under the -* terms of the Apache License 2.0 which is available at -* http://www.apache.org/licenses/LICENSE-2.0 -* -* SPDX-License-Identifier: Apache-2.0 -********************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "wiper_poc.h" -#include "wiper_sim.h" - - -int debug = ::getenv("DEBUG") ? ::atoi(::getenv("DEBUG")) : 0; - -static int sim_auto = ::getenv("SIM_AUTO") ? ::atoi(::getenv("SIM_AUTO")) : 0; - -using namespace sdv::someip::wiper; - -class wiper_service { - -public: - - wiper_service(bool _use_tcp, uint32_t _cycle) : - app_(vsomeip::runtime::get()->create_application()), - is_registered_(false), - use_tcp_(_use_tcp), - cycle_(_cycle), - blocked_(false), - running_(true), - is_offered_(false), - wiper_sim_(cycle_), - offer_thread_(std::bind(&wiper_service::run, this)), - notify_thread_(std::bind(&wiper_service::notify_th, this)) - { - pthread_setname_np(offer_thread_.native_handle(), "wiper_run"); - pthread_setname_np(notify_thread_.native_handle(), "wiper_notify"); - } - - bool init() { - std::lock_guard its_lock(mutex_); - - if (!app_->init()) { - std::cerr << "Couldn't initialize application" << std::endl; - return false; - } - app_->register_state_handler( - std::bind(&wiper_service::on_state, this, - std::placeholders::_1)); - //// - // register wiper event service - // - std::set its_groups; - its_groups.insert(WIPER_EVENTGROUP_ID); - app_->offer_event( - WIPER_SERVICE_ID, - WIPER_INSTANCE_ID, - WIPER_EVENT_ID, - its_groups, - vsomeip::event_type_e::ET_FIELD, std::chrono::milliseconds::zero(), - false, true, nullptr, - use_tcp_ ? vsomeip::reliability_type_e::RT_RELIABLE : vsomeip::reliability_type_e::RT_UNRELIABLE - // vsomeip::reliability_type_e::RT_UNKNOWN - ); - - { - std::lock_guard its_lock(payload_mutex_); - payload_ = vsomeip::runtime::get()->create_payload(); - } - - // - // register wiper vss service - // - - // register a callback for responses from the service - app_->register_message_handler( - WIPER_VSS_SERVICE_ID, - WIPER_VSS_INSTANCE_ID, - WIPER_VSS_METHOD_ID, - std::bind(&wiper_service::on_vss_message_cb, this, - std::placeholders::_1)); - - // register a callback which is called as soon as the service is available - app_->register_availability_handler( - WIPER_VSS_SERVICE_ID, - WIPER_VSS_INSTANCE_ID, - std::bind(&wiper_service::on_availability_cb, this, - std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); - - blocked_ = true; - condition_.notify_one(); - return true; - } - - void start() { - app_->start(); - } - - void on_vss_message_cb(const std::shared_ptr &_request) { - std::stringstream its_message; - t_Event event; - - its_message << "### [VSS] Received a Request for [" - << std::setw(4) << std::setfill('0') << std::hex - << _request->get_service() << "." - << std::setw(4) << std::setfill('0') << std::hex - << _request->get_instance() << "." - << std::setw(4) << std::setfill('0') << std::hex - << _request->get_method() << "] to Client/Session [" - << std::setw(4) << std::setfill('0') << std::hex - << _request->get_client() << "/" - << std::setw(4) << std::setfill('0') << std::hex - << _request->get_session() - << "] = "; - std::shared_ptr its_payload = _request->get_payload(); - its_message << "(" << std::dec << its_payload->get_length() << ")"; - if (debug > 1) { - its_message << " ["; - for (int i=0; iget_length(); i++) { - its_message - << std::setw(2) << std::setfill('0') << std::hex - << (int)its_payload->get_data()[i] << " "; - } - its_message << "]"; - } - - std::cout << std::endl; - std::cout << its_message.str() << std::endl; - std::cout << std::endl; - - // TODO create and send response - std::shared_ptr its_response = vsomeip::runtime::get()->create_response(_request); - std::shared_ptr resp_payload = vsomeip::runtime::get()->create_payload(); - - uint8_t result = 0x01; // or 0x01 for error - - t_WiperRequest wiper_request; - if (deserialize_vss_request(its_payload->get_data(), its_payload->get_length(), wiper_request)) { - std::cout << "### [VSS] received: " - << vss_request_to_string(wiper_request) - << std::endl; - // TODO: start/stop wiping, etc. - wiper_sim_.model_set(wiper_request); - result = 0x00; // ok - } else { - std::cerr << "### [VSS] Failed to deserialize payload!" << std::endl; - } - - std::vector its_payload_data; - its_payload_data.push_back(result); - - resp_payload->set_data(its_payload_data); - its_response->set_payload(resp_payload); - - if (debug > 0) std::cout << "### [VSS] Sending VSS Response..." << std::endl; - app_->send(its_response); - if (debug > 1) std::cout << "### [VSS] done." << std::endl; - } - - void on_availability_cb(vsomeip::service_t _service, vsomeip::instance_t _instance, bool _is_available) { - std::cout << "### [VSS] Service [" - << std::setw(4) << std::setfill('0') << std::hex << _service - << "." - << std::setw(4) << std::setfill('0') << std::hex << _instance - << "] is " - << (_is_available ? "available." : "NOT available.") - << std::endl; - if (_is_available) { - // TODO: what? - } - } - - - /* - * Handle signal to shutdown - */ - void stop() { - running_ = false; - blocked_ = true; - condition_.notify_one(); - notify_condition_.notify_one(); - app_->clear_all_handler(); - stop_offer(); - if (offer_thread_.joinable()) { - offer_thread_.join(); - } - if (notify_thread_.joinable()) { - notify_thread_.join(); - } - app_->stop(); - } - - void offer() { - std::lock_guard its_lock(notify_mutex_); - std::printf("Application %s offering VSS [%04x.%04x] v%u.%u\n", - app_->get_name().c_str(), - WIPER_VSS_SERVICE_ID, WIPER_VSS_INSTANCE_ID, - WIPER_VSS_SERVICE_MAJOR, WIPER_VSS_SERVICE_MINOR); - - app_->offer_service(WIPER_VSS_SERVICE_ID, WIPER_VSS_INSTANCE_ID, - WIPER_VSS_SERVICE_MAJOR, WIPER_VSS_SERVICE_MINOR); - - std::printf("Application %s offering [%04x.%04x] v%u.%u\n", - app_->get_name().c_str(), - WIPER_SERVICE_ID, WIPER_INSTANCE_ID, - WIPER_SERVICE_MAJOR, WIPER_SERVICE_MINOR); - - app_->offer_service(WIPER_SERVICE_ID, WIPER_INSTANCE_ID, - WIPER_SERVICE_MAJOR, WIPER_SERVICE_MINOR); - - is_offered_ = true; - notify_condition_.notify_one(); - } - - void stop_offer() { - std::printf("Application %s stop offering [%04x.%04x] v%u.%u\n", - app_->get_name().c_str(), WIPER_SERVICE_ID, WIPER_INSTANCE_ID, - WIPER_SERVICE_MAJOR, WIPER_SERVICE_MINOR); - app_->stop_offer_service(WIPER_SERVICE_ID, WIPER_INSTANCE_ID, - WIPER_SERVICE_MAJOR, WIPER_SERVICE_MINOR); - - std::printf("Application %s offering VSS [%04x.%04x] v%u.%u\n", - app_->get_name().c_str(), - WIPER_VSS_SERVICE_ID, WIPER_VSS_INSTANCE_ID, - WIPER_VSS_SERVICE_MAJOR, WIPER_VSS_SERVICE_MINOR); - - app_->stop_offer_service(WIPER_VSS_SERVICE_ID, WIPER_VSS_INSTANCE_ID, - WIPER_VSS_SERVICE_MAJOR, WIPER_VSS_SERVICE_MINOR); - - is_offered_ = false; - } - - void on_state(vsomeip::state_type_e _state) { - std::cout << "Application " << app_->get_name() << " is " - << (_state == vsomeip::state_type_e::ST_REGISTERED ? - "registered." : "deregistered.") << std::endl; - - is_registered_ = (_state == vsomeip::state_type_e::ST_REGISTERED); - if (is_registered_) { - // we are registered at the runtime and can offer our service - // offer(); -> this generates a blocking state handler! - } - } - - void run() { - // offer thread, reused for set as well - std::unique_lock its_lock(mutex_); - while (!blocked_) - condition_.wait(its_lock); - - bool is_offer(true); - - // predefined vss positions - int vss_index = 0; - t_WiperRequest vss_reqests[] = { - { 40, 80.0f, e_WiperMode::WIPE }, - { 50, 20.0f, e_WiperMode::WIPE }, - { 30, 10.0f, e_WiperMode::WIPE }, - { 30, 2.0f, e_WiperMode::WIPE }, - { 70, 2.0f, e_WiperMode::EMERGENCY_STOP } - }; - - while (running_) { - if (is_offer) - offer(); - else - stop_offer(); - - if (sim_auto) { - std::cout << "# SIM: Setting VSS [" << vss_index << "] ..." << std::endl; - wiper_sim_.model_set(vss_reqests[vss_index++]); - if (vss_index > 5) { - vss_index = 0; - } - } - for (int i = 0; i < 10 && running_; i++) { - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - } - - //is_offer = !is_offer; // Disabled toggling of event availability each 10sec - } - } - - void notify_th() { - std::shared_ptr its_message - = vsomeip::runtime::get()->create_request(use_tcp_); - - its_message->set_service(WIPER_SERVICE_ID); - its_message->set_instance(WIPER_INSTANCE_ID); - its_message->set_method(WIPER_EVENT_ID); - // its_message->set_interface_version(WIPER_SERVICE_MAJOR); - - t_Event event; - uint8_t its_data[WIPER_EVENT_PAYLOAD_SIZE]; - size_t its_size = sizeof(its_data); - - while (running_) - { - std::unique_lock its_lock(notify_mutex_); - while (!is_offered_ && running_) - notify_condition_.wait(its_lock); - - //auto now = std::chrono::system_clock::now(); - auto event_ts = 0;//std::chrono::time_point_cast(now).time_since_epoch().count(); - auto sim_step = 500; - if (sim_step > cycle_) { - sim_step = cycle_; - } - while (is_offered_ && running_) - { - // run model step - bool was_cycle_ending = wiper_sim_.is_cycle_ending(); - wiper_sim_.model_step(event); - std::this_thread::sleep_for(std::chrono::milliseconds(sim_step)); // run cycle 10 ms - event_ts += sim_step; // FIXME: use ts delta - if (!is_offered_ || !running_) { - break; - } - if (event_ts >= cycle_ || was_cycle_ending != wiper_sim_.is_cycle_ending()) { - if (debug > 1) { - std::printf("[EVENT] ActualPos:%6.2f, DriveCurrent:%5.2f, Wiping:%d, CycEnd:%d, PosReach:%d, Seq:%3d, [%5.3f]\n", - event.data.ActualPosition, event.data.DriveCurrent, - event.data.isWiping, event.data.isEndingWipeCycle, event.data.isPositionReached, - (int)event.sequenceCounter, (float)event_ts / 1000.0f); - } - - event_ts = 0; - if (serialize_wiper_event(event, (uint8_t*)&its_data, its_size)) { - std::lock_guard its_lock(payload_mutex_); - payload_->set_data(its_data, its_size); - if (debug > 2) { - std::printf("### app.notify(%04x.%04x/%04x) -> %lu bytes\n", - WIPER_SERVICE_ID, WIPER_INSTANCE_ID, WIPER_EVENT_ID, its_size); - } - if (debug > 3) { - std::cout << "### Notify payload: " - << bytes_to_string(its_data, its_size) - << "]" << std::endl; - } - app_->notify(WIPER_SERVICE_ID, WIPER_INSTANCE_ID, WIPER_EVENT_ID, payload_); - } - } - } - } - } - -#if 0 - void notify_th_random() { - std::shared_ptr its_message - = vsomeip::runtime::get()->create_request(use_tcp_); - - its_message->set_service(WIPER_SERVICE_ID); - its_message->set_instance(WIPER_INSTANCE_ID); - its_message->set_method(WIPER_EVENT_ID); - // its_message->set_interface_version(WIPER_SERVICE_MAJOR); - - t_Event event; - uint32_t its_size = sizeof(event); - uint8_t its_data[its_size]; - - // wiper_model_init(event); - - event.data.ActualPosition = 90; - event.data.DriveCurrent = 10; - event.data.TempGear = 100; - event.data.isBlocked = false; - event.data.isEndingWipeCycle = false; - event.data.isOverheated = false; - event.data.isPositionReached = false; - event.data.isWiperError = false; - event.data.isWiping = true; - event.data.ECUTemp = 75; - event.data.LINError = 255; - event.data.isUnderVoltage = false; - event.data.isOverVoltage = false; - - // model init - event.sequenceCounter = 0; - - const float default_pos_step = 3.13f; - const float default_current = 10.0f; - float pos_step = default_pos_step; - - std::random_device rd; // Will be used to obtain a seed for the random number engine - std::mt19937 gen(rd()); // Standard mersenne_twister_engine seeded with rd() - std::uniform_real_distribution current_rnd(-0.05f, 0.05f); - std::uniform_real_distribution speed_rnd(0.0f, default_pos_step/3.0f); - - uint32_t counter = 0; - while (running_) - { - std::unique_lock its_lock(notify_mutex_); - while (!is_offered_ && running_) - notify_condition_.wait(its_lock); - while (is_offered_ && running_) - { - // run model step - counter++; - event.sequenceCounter = (uint8_t)(counter & 0xFF); - - // toggle isOverheated ~9s - if ((cycle_ * counter) % 9000 == 0) { - event.data.isOverheated = !event.data.isOverheated; - std::cout << std::endl << "*** wiper " - << (event.data.isOverheated ? "Overheated." : "not Overheated") << std::endl << std::endl; - } - - // toggle isWiping ~5s - if ((cycle_ * counter) % 5000 == 0) { - event.data.isWiping = !event.data.isWiping; - std::cout << std::endl << "*** wiping " - << (event.data.isWiping ? "started." : "stopped.") << std::endl << std::endl; - } - - // simulate wiper movement - if (event.data.isWiping) { - if (event.data.ActualPosition >= 150.0f) { - pos_step = -default_pos_step; - } else - if (event.data.ActualPosition < default_pos_step) { - pos_step = default_pos_step; - } - event.data.ActualPosition += pos_step + speed_rnd(gen); - - event.data.DriveCurrent = default_current + current_rnd(gen); - } else { - event.data.DriveCurrent = 0.0f; - } - - if (debug > 0) { - std::printf("[EVENT] Seq:%3d, ActualPos: %f, DriveCurrent: %f\n", - (int)event.sequenceCounter, event.data.ActualPosition, event.data.DriveCurrent); - } - // serialize t_Event as someip payload - its_data[0] = event.sequenceCounter; - float_to_bytes(event.data.ActualPosition, &its_data[1]); - float_to_bytes(event.data.DriveCurrent, &its_data[5]); - its_data[9] = event.data.TempGear; - its_data[10] = event.data.isWiping; - its_data[11] = event.data.isEndingWipeCycle; - its_data[12] = event.data.isWiperError; - its_data[13] = event.data.isPositionReached; - its_data[14] = event.data.isBlocked; - its_data[15] = event.data.isOverheated; - its_data[16] = event.data.ECUTemp; - its_data[17] = event.data.LINError; - its_data[18] = event.data.isOverVoltage; - its_data[19] = event.data.isUnderVoltage; - - { - std::lock_guard its_lock(payload_mutex_); - payload_->set_data(its_data, its_size); - if (debug > 1) { - std::printf("### app.notify(%04x.%04x/%04x) -> %u bytes\n", - WIPER_SERVICE_ID, WIPER_INSTANCE_ID, WIPER_EVENT_ID, its_size); - } - if (debug > 2) { - std::cout << "### Notify payload: " - << bytes_to_string(its_data, its_size) - << "]" << std::endl; - } - app_->notify(WIPER_SERVICE_ID, WIPER_INSTANCE_ID, WIPER_EVENT_ID, payload_); - } - if (running_) { - std::this_thread::sleep_for(std::chrono::milliseconds(cycle_)); - } - } - } - } -#endif - -private: - std::shared_ptr app_; - bool is_registered_; - bool use_tcp_; - uint32_t cycle_; - - std::mutex mutex_; - std::condition_variable condition_; - bool blocked_; - bool running_; - - std::mutex notify_mutex_; - std::condition_variable notify_condition_; - bool is_offered_; - - std::mutex payload_mutex_; - std::shared_ptr payload_; - - // blocked_ / is_offered_ must be initialized before starting the threads! - std::thread offer_thread_; - std::thread notify_thread_; - - // model simulator - t_Event model_event; - wiper_simulator wiper_sim_; -}; - -wiper_service *its_sample_ptr(nullptr); - -void handle_signal(int _signal) { - if (its_sample_ptr != nullptr && - (_signal == SIGINT || _signal == SIGTERM)) - its_sample_ptr->stop(); -} -// #endif - -int main(int argc, char **argv) { - bool use_tcp = false; - uint32_t cycle = 100; // default 1s - - std::string tcp_enable("--tcp"); - std::string udp_enable("--udp"); - std::string cycle_arg("--cycle"); - std::string sim_arg("--sim"); - - // sanity checks for VSOMEIP environment - const char* app_name = ::getenv("VSOMEIP_APPLICATION_NAME"); - if (!app_name) { - std::cerr << "Environment variable VSOMEIP_APPLICATION_NAME not set!" << std::endl; - return 1; - } - - const char* app_config = ::getenv("VSOMEIP_CONFIGURATION"); - if (!app_config) { - std::cerr << "Environment variable VSOMEIP_CONFIGURATION not set!" << std::endl; - return 1; - } - - if (vsomeip::DEFAULT_MAJOR != 0) { - std::cout << "# Warning: compiled with vsomeip::DEFAULT_MAJOR=" << std::dec << (int)vsomeip::DEFAULT_MAJOR << std::endl; - } - - const char* cycle_env= ::getenv("CYCLE"); - if (cycle_env) { - cycle = atoi(cycle_env); - } - for (int i = 1; i < argc; i++) { - if (tcp_enable == argv[i]) { - use_tcp = true; - break; - } else - if (udp_enable == argv[i]) { - use_tcp = false; - break; - } - else - if (cycle_arg == argv[i] && i + 1 < argc) { - i++; - std::stringstream converter; - converter << argv[i]; - converter >> cycle; - } else - if (sim_arg == argv[i]) { - sim_auto = 1; // override envrionment - break; - } - - } - - wiper_service its_sample(use_tcp, cycle); - its_sample_ptr = &its_sample; - signal(SIGINT, handle_signal); - signal(SIGTERM, handle_signal); - - if (its_sample.init()) { - its_sample.start(); - return 0; - } else { - its_sample.stop(); - return 1; - } -} diff --git a/someip2val/src/examples/wiper_service/wiper_sim.cc b/someip2val/src/examples/wiper_service/wiper_sim.cc deleted file mode 100644 index 4508f3bb..00000000 --- a/someip2val/src/examples/wiper_service/wiper_sim.cc +++ /dev/null @@ -1,210 +0,0 @@ -/******************************************************************************** -* Copyright (c) 2022 Contributors to the Eclipse Foundation -* -* See the NOTICE file(s) distributed with this work for additional -* information regarding copyright ownership. -* -* This program and the accompanying materials are made available under the -* terms of the Apache License 2.0 which is available at -* http://www.apache.org/licenses/LICENSE-2.0 -* -* SPDX-License-Identifier: Apache-2.0 -********************************************************************************/ - -#include - -#include "wiper_sim.h" - -extern int debug; - -namespace sdv { -namespace someip { -namespace wiper { - -static int sim_debug = getenv("SIM_DEBUG") ? atoi(getenv("SIM_DEBUG")) : 0; - -wiper_simulator::wiper_simulator(uint32_t _cycle) : - model_counter_(0), - gen_(rd_()), - cycle_(_cycle), - current_rnd_(), - speed_rnd_(), - sim_pos_step_(0), - sim_frequency_(0), - sim_wiping_(false), - sim_cylce_ending_(false), - sim_cycle_ending_count_(0), - sim_set_ts_(0), - sim_ts_(0) -{ - model_init(); -} - -void wiper_simulator::model_init() { - - current_rnd_ = std::uniform_real_distribution(-0.05f, 0.05f); - speed_rnd_ = std::uniform_real_distribution(0.0f, 0.1f); - - auto now = std::chrono::system_clock::now(); - sim_ts_ = std::chrono::time_point_cast(now).time_since_epoch().count(); - sim_set_ts_ = sim_ts_; - sim_pos_step_ = 0; - sim_cycle_ending_count_ = 0; - sim_target_pos_ = 15; - - event_.sequenceCounter = 0; - event_.data.ActualPosition = sim_target_pos_; - event_.data.DriveCurrent = 10; - event_.data.TempGear = 100; - event_.data.isBlocked = false; - event_.data.isEndingWipeCycle = true; - event_.data.isOverheated = false; - event_.data.isPositionReached = true; - event_.data.isWiperError = false; - event_.data.isWiping = true; - event_.data.ECUTemp = 75; - event_.data.LINError = 255; - event_.data.isUnderVoltage = false; - event_.data.isOverVoltage = false; -} - -void wiper_simulator::model_step(t_Event& event) { - - std::lock_guard its_lock(configure_mutex_); - - auto now = std::chrono::system_clock::now(); - auto now_ms = std::chrono::time_point_cast(now).time_since_epoch().count(); - auto sim_elapsed_ms = now_ms - sim_ts_; - - model_counter_++; - - float sim_current = 0.0f; - float sim_actual_pos = sim_target_pos_; - bool sim_pos_reached = true; - - // simulate wiper movement (not depending on sim_active_) - if (sim_wiping_) { - double sim_moved = sim_elapsed_ms * sim_pos_step_; - double next_pos = event_.data.ActualPosition + sim_moved; - - bool pos_reached = (sim_pos_step_ >= 0 && next_pos >= sim_target_pos_) || - (sim_pos_step_ < 0 && next_pos <= sim_target_pos_); - if (pos_reached) { - // allow several cycle ending events, then pos reached - if (!sim_cylce_ending_) { - sim_cylce_ending_ = true; - sim_cycle_ending_count_ = 0; - } - if (++sim_cycle_ending_count_ < 3) { - next_pos = sim_target_pos_ + speed_rnd_(gen_); - sim_pos_step_ = 0; // reset sim step - sim_pos_reached = false; - if (sim_debug > 0) { - std::cout << "[SIM] *** Wiper Cycle ending. current pos: " - << next_pos << ", target: " << sim_target_pos_ << std::endl; - } - } else { - if (sim_debug > 0) { - auto op_elapsed_ms = now_ms - sim_set_ts_; - std::cout << "[SIM] *** Reached target: " << sim_target_pos_ - << ", sim_position: " << next_pos - << " in " << op_elapsed_ms << " ms." - << std::endl; - } - sim_wiping_ = false; - sim_cylce_ending_ = false; - sim_cycle_ending_count_ = 0; - next_pos = sim_target_pos_; - sim_pos_reached = true; - } - } else { - sim_pos_reached = false; - } - - // sanity checks - if (sim_wiping_ && next_pos < -1.0f) { - if (sim_debug > 2) { - std::cout << "[SIM] Reset invalid position " << next_pos << " to 0." << std::endl; - } - next_pos = 0; - } - if (sim_wiping_ && next_pos > 181.0f) { - if (sim_debug > 2) { - std::cout << "[SIM] Reset invalid position: " << next_pos << " to 180." << std::endl; - } - next_pos = 180.0f; - } - - sim_actual_pos = next_pos; //sim_elapsed_ms * sim_pos_step_; // sim_pos_step_ + speed_rnd_(gen_); - sim_current = default_current + current_rnd_(gen_); - } - - event_.sequenceCounter = (uint8_t)(model_counter_ & 0xFF); - event_.data.isWiping = sim_wiping_; - event_.data.isPositionReached = sim_pos_reached; - event_.data.isEndingWipeCycle = sim_cylce_ending_; - event_.data.DriveCurrent = sim_current; - event_.data.ActualPosition = sim_actual_pos; - - sim_ts_ = now_ms; - event = event_; // copy should be ok - - // reduce dumps (each second) if wiping has stopped - if (sim_debug > 0 && (sim_wiping_ || (model_counter_ % 10) == 0)) { - std::printf("[SIM] ## ActualPos:%6.2f, DriveCurrent:%5.2f, Wiping:%d, CycEnd:%d, PosReach:%d, Seq:%-3d | sim_model_step:%5.4f, elapsed:%-4ld\n", - event.data.ActualPosition, event.data.DriveCurrent, - event.data.isWiping, event.data.isEndingWipeCycle, event.data.isPositionReached, - (int)event.sequenceCounter, sim_pos_step_, sim_elapsed_ms); - } -} - - -void wiper_simulator::model_set(const t_WiperRequest &req) { - std::lock_guard its_lock(configure_mutex_); - - std::cout << "[SIM] *** WiperSim::model_set <" - << wiper_mode_to_string(req.Mode) - << ", freq:" << (int)req.Frequency - << ", target:" << req.TargetPosition - << ">" << std::endl; - - if (req.Mode == e_WiperMode::WIPE) { - sim_wiping_ = true; - } else { - sim_wiping_ = false; - } - - sim_frequency_ = req.Frequency; - sim_target_pos_ = req.TargetPosition; - // | freq = cycles per 60000 ms <=> freq * 180.0 degrees per 60000 ms. - // | model step per ms - sim_pos_step_ = sim_frequency_ * 180.0f / 60000.0f; - - // get current pos vs target pos - if (event_.data.ActualPosition > sim_target_pos_) { - sim_pos_step_ = -sim_pos_step_; - } - if (debug > 0) { - std::cout << "[SIM] *** Moving (" - << event_.data.ActualPosition - << " -> " << sim_target_pos_ - << "), pos/ms: " << sim_pos_step_; - } - - if (debug > 0) std::cout << std::endl << "[SIM] *** wiping " - << (sim_wiping_ ? "started." : "stopped.") - << std::endl << std::endl; - // reset timestamp - auto now = std::chrono::system_clock::now(); - sim_set_ts_ = std::chrono::time_point_cast(now).time_since_epoch().count(); - sim_ts_ = sim_set_ts_; - sim_cylce_ending_ = false; -} - -bool wiper_simulator::is_cycle_ending() { - return sim_cylce_ending_; -} - -} // namespace wiper -} // namespace someip -} // namespace sdv diff --git a/someip2val/src/examples/wiper_service/wiper_sim.h b/someip2val/src/examples/wiper_service/wiper_sim.h deleted file mode 100644 index dc0a278c..00000000 --- a/someip2val/src/examples/wiper_service/wiper_sim.h +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************** -* Copyright (c) 2022 Contributors to the Eclipse Foundation -* -* See the NOTICE file(s) distributed with this work for additional -* information regarding copyright ownership. -* -* This program and the accompanying materials are made available under the -* terms of the Apache License 2.0 which is available at -* http://www.apache.org/licenses/LICENSE-2.0 -* -* SPDX-License-Identifier: Apache-2.0 -********************************************************************************/ - -#ifndef VSOMEIP_WIPER_SIM_H -#define VSOMEIP_WIPER_SIM_H - -#include -#include -#include - -#include "wiper_poc.h" - -namespace sdv { -namespace someip { -namespace wiper { - -const float default_current = 10.0f; - -class wiper_simulator { - -public: - wiper_simulator(uint32_t _cycle); - - void model_step(t_Event& event); - - void model_set(const t_WiperRequest &req); - - bool is_cycle_ending(); - -protected: - void model_init(); - -private: - int model_counter_; - uint32_t cycle_; - t_Event event_; - - float sim_pos_step_; - bool sim_wiping_; - bool sim_cylce_ending_; - int sim_cycle_ending_count_; - int sim_frequency_; - float sim_target_pos_; - int64_t sim_set_ts_; - int64_t sim_ts_; - - std::random_device rd_; // Will be used to obtain a seed for the random number engine - std::mt19937 gen_; - std::uniform_real_distribution current_rnd_; - std::uniform_real_distribution speed_rnd_; - - std::mutex configure_mutex_; -}; - -} // namespace wiper -} // namespace someip -} // namespace sdv - - -#endif // VSOMEIP_WIPER_SIM_H diff --git a/someip2val/src/lib/broker_feeder/CMakeLists.txt b/someip2val/src/lib/broker_feeder/CMakeLists.txt deleted file mode 100644 index 0045a462..00000000 --- a/someip2val/src/lib/broker_feeder/CMakeLists.txt +++ /dev/null @@ -1,103 +0,0 @@ -#******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -#*******************************************************************************/ - -# Data Broker Proto file -set(PROTO_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../proto/kuksa_data_broker) - -find_package(Protobuf REQUIRED) -find_package(gRPC REQUIRED) - -# Needed for cross build, env vars set via conan env_generator -find_program(PROTOC_PROGRAM_TEMP - NAMES protoc - PATHS ENV PATH - NO_DEFAULT_PATH -) -get_filename_component(PROTOC_PROGRAM_TEMP "${PROTOC_PROGRAM_TEMP}" ABSOLUTE) -set_property(TARGET protobuf::protoc PROPERTY IMPORTED_LOCATION ${PROTOC_PROGRAM_TEMP}) - -# Needed for cross build, env vars set via conan env_generator -# Do not use previously found program (GRPC_CPP_PLUGIN_PROGRAM) but new varaible: GRPC_CPP_PLUGIN_PROGRAM_ENV -find_program(GRPC_CPP_PLUGIN_PROGRAM_ENV - NAMES grpc_cpp_plugin - PATHS ENV PATH - NO_DEFAULT_PATH -) -get_filename_component(GRPC_CPP_PLUGIN_PROGRAM_ENV "${GRPC_CPP_PLUGIN_PROGRAM_ENV}" ABSOLUTE) - -message("--- [broker_feedder] Using protoc: ${PROTOC_PROGRAM_TEMP}") -message("--- [broker_feedder] Using grpc_cpp_plugin: ${GRPC_CPP_PLUGIN_PROGRAM_ENV}") -message("--- [broker_feedder] protoc version:") -execute_process ( - COMMAND "${PROTOC_PROGRAM_TEMP}" --version -) - -add_library(data_broker_feeder - STATIC - data_broker_feeder.cc - collector_client.cc - actuator_subscriber.cc -) - -target_link_libraries(data_broker_feeder - PUBLIC - protobuf::libprotobuf - gRPC::grpc++ - gRPC::grpc++_reflection -) - -target_include_directories(data_broker_feeder - PUBLIC - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} -) - - -# protobuf -protobuf_generate( - TARGET - data_broker_feeder - LANGUAGE - cpp - PROTOS - ${PROTO_SOURCE_DIR}/sdv/databroker/v1/broker.proto - ${PROTO_SOURCE_DIR}/sdv/databroker/v1/collector.proto - ${PROTO_SOURCE_DIR}/sdv/databroker/v1/types.proto - - ${PROTO_SOURCE_DIR}/kuksa/val/v1/types.proto - ${PROTO_SOURCE_DIR}/kuksa/val/v1/val.proto - IMPORT_DIRS - ${PROTO_SOURCE_DIR} -) - -# GRPC services -protobuf_generate( - TARGET - data_broker_feeder - LANGUAGE - grpc - GENERATE_EXTENSIONS - .grpc.pb.h - .grpc.pb.cc - PROTOS - ${PROTO_SOURCE_DIR}/sdv/databroker/v1/collector.proto - ${PROTO_SOURCE_DIR}/sdv/databroker/v1/broker.proto - ${PROTO_SOURCE_DIR}/kuksa/val/v1/val.proto - PLUGIN - "protoc-gen-grpc=${GRPC_CPP_PLUGIN_PROGRAM_ENV}" - IMPORT_DIRS - ${PROTO_SOURCE_DIR} -) - -# get_property(DB_FDB_FEEDER_INCLUDE_DIRSEEDER_INCLUDE_DIRS TARGET data_broker_feeder PROPERTY INCLUDE_DIRECTORIES) -# message(INFO " : ${DB_FEEDER_INCLUDE_DIRS}") diff --git a/someip2val/src/lib/broker_feeder/actuator_subscriber.cc b/someip2val/src/lib/broker_feeder/actuator_subscriber.cc deleted file mode 100644 index bd9cfab9..00000000 --- a/someip2val/src/lib/broker_feeder/actuator_subscriber.cc +++ /dev/null @@ -1,178 +0,0 @@ -/******************************************************************************** -* Copyright (c) 2022 Contributors to the Eclipse Foundation -* -* See the NOTICE file(s) distributed with this work for additional -* information regarding copyright ownership. -* -* This program and the accompanying materials are made available under the -* terms of the Apache License 2.0 which is available at -* http://www.apache.org/licenses/LICENSE-2.0 -* -* SPDX-License-Identifier: Apache-2.0 -********************************************************************************/ -#include -#include - -#include "simple_log.h" -#include "actuator_subscriber.h" - -// declare logger in root namespace -LOGGER_STATIC_INIT("# ActuatorSubscriber::"); - -namespace sdv { -namespace broker_feeder { -namespace kuksa { - -// helper for printing vector elements -template std::ostream& operator<<(std::ostream& os, const std::vector &v) { - for (auto t : v) { - os << t << " "; - } - return os; -} - -ActuatorSubscriber::ActuatorSubscriber(std::shared_ptr client) : - client_(client), - subscriber_active_(false), - cb_(nullptr), - actuators_() -{ - LOGGER_SET_LEVEL_ENV("KUKSA_DEBUG", LEVEL_INF); -} - -ActuatorSubscriber::~ActuatorSubscriber() { - LOG_TRACE << "called." << std::endl; - if (subscriber_active_) { - Shutdown(); - } - LOG_TRACE << "done." << std::endl; -} - -void ActuatorSubscriber::Shutdown() { - LOG_DEBUG << "subscriber_active_: " << subscriber_active_ << std::endl; - if (subscriber_active_) { - subscriber_active_ = false; - std::lock_guard lock(context_mutex_); - if (subscriber_context_) { - LOG_DEBUG << "Cancelling subscriber context ..." << std::endl; - subscriber_context_->TryCancel(); - } - } -} - -void ActuatorSubscriber::Init(std::vector subscribe_actuators, ActuatorChangeCallback cb) { - actuators_ = subscribe_actuators; - cb_ = cb; - if (LOGGER_ENABLED(LEVEL_INF)) { - std::stringstream ss; - ss << "Initialized for actuators: [ "; - for (auto sub: subscribe_actuators) { - ss << sub << " "; - } - ss << "]" << std::endl; - LOG_INFO << ss.str(); - } -} - -void ActuatorSubscriber::Run() { - - if (actuators_.size() == 0) { - LOG_ERROR << "No actuators to subscribe!"; - subscriber_active_ = false; - LOG_INFO << "Exiting" << std::endl; - return; - } - - subscriber_active_ = true; - int backoff = 1; - LOG_INFO << "Starting actuator target subscriber [" << client_->GetBrokerAddr() << "]" << std::endl; - while (subscriber_active_) { - auto deadline = std::chrono::system_clock::now() + std::chrono::seconds(backoff); - if (!client_->WaitForConnected(deadline)) { - LOG_INFO << "Not connected" << std::endl; - if (backoff < 10) { - backoff++; - } - continue; - } else { - backoff = 1; - } - LOG_INFO << "Connected to [" << client_->GetBrokerAddr() << "]" << std::endl; - - ::kuksa::val::v1::SubscribeResponse response; - ::kuksa::val::v1::SubscribeRequest request; - for (auto i=0; iset_path(actuators_[i]); - entry->add_fields(::kuksa::val::v1::Field::FIELD_ACTUATOR_TARGET); - entry->add_fields(::kuksa::val::v1::Field::FIELD_METADATA); - } - - // guard subscriber_context_ for concurrent access on Shutdown() - std::unique_ptr<::grpc::ClientReader<::kuksa::val::v1::SubscribeResponse>> reader = nullptr; - { - std::lock_guard lock(context_mutex_); - subscriber_context_ = client_->createClientContext(); - if (LOGGER_ENABLED(LEVEL_DBG)) { - LOG_DEBUG << "Subscribing: [ " << actuators_ << "]" << std::endl; - } - reader = client_->Subscribe(subscriber_context_.get(), request); - LOG_INFO << "Actuator targets Subscribed!" << std::endl; - } - - while (subscriber_active_ && reader->Read(&response)) { - LOG_TRACE << "[SUB] updates_size:" << response.updates_size() << std::endl; - ActuatorValues changes; - for (auto& update : response.updates()) { - if (!subscriber_active_) break; - if (LOGGER_ENABLED(LEVEL_DBG)) { - std::stringstream ss; - ss << "[SUB] " << update.entry().path() - << ", value_case:" << static_cast(update.entry().actuator_target().value_case()) - << ", target: { " << update.entry().actuator_target().ShortDebugString() << " }"; - LOG_DEBUG << ss.str() << std::endl; - } - changes.emplace( - update.entry().path(), - update.entry().actuator_target()); - } - if (cb_ && subscriber_active_) { - cb_(changes); - } - } - - grpc::Status status = reader->Finish(); - if (status.ok()) { - LOG_INFO << "Disconnected." << std::endl; - } else if (subscriber_active_) { - client_->handleGrpcError(status, "ActuatorSubscriber::Run()"); - if (LOGGER_ENABLED(LEVEL_DBG)) { - std::lock_guard lock(context_mutex_); - if (subscriber_context_ != nullptr) { - LOG_DEBUG << "Disconnection details: " << - subscriber_context_->debug_error_string() << std::endl; - } - } - // prevent busy polling if subscribe failed with error - std::this_thread::sleep_for(std::chrono::seconds(5)); - } - - // guard subscriber_context_ for concurrent access on Shutdown() - { - std::lock_guard lock(context_mutex_); - LOG_DEBUG << "Destroying context.." << std::endl; - subscriber_context_ = nullptr; - } - } - - LOG_INFO << "Done." << std::endl; -} - -std::shared_ptr ActuatorSubscriber::createInstance(std::shared_ptr client) { - return std::make_shared(client); -} - - -} // namespace kuksa -} // namespace broker_feeder -} // namespace sdv diff --git a/someip2val/src/lib/broker_feeder/actuator_subscriber.h b/someip2val/src/lib/broker_feeder/actuator_subscriber.h deleted file mode 100644 index da857736..00000000 --- a/someip2val/src/lib/broker_feeder/actuator_subscriber.h +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************** -* Copyright (c) 2022 Contributors to the Eclipse Foundation -* -* See the NOTICE file(s) distributed with this work for additional -* information regarding copyright ownership. -* -* This program and the accompanying materials are made available under the -* terms of the Apache License 2.0 which is available at -* http://www.apache.org/licenses/LICENSE-2.0 -* -* SPDX-License-Identifier: Apache-2.0 -********************************************************************************/ -#pragma once - -#include -#include -#include -#include - -#include "sdv/databroker/v1/types.pb.h" -#include "collector_client.h" - -namespace sdv { -namespace broker_feeder { -namespace kuksa { - -typedef std::map ActuatorValues; - -typedef std::function ActuatorChangeCallback; - -class ActuatorSubscriber { -public: - - ActuatorSubscriber(std::shared_ptr client); - virtual ~ActuatorSubscriber(); - - void Init(std::vector actuators = {}, ActuatorChangeCallback cb = nullptr); - void Run(); - void Shutdown(); - static std::shared_ptr createInstance(std::shared_ptr client); - -protected: - // disable copy constructor and copy assignment - ActuatorSubscriber() = default; - ActuatorSubscriber(const ActuatorSubscriber&) = delete; - ActuatorSubscriber& operator=(const ActuatorSubscriber&) = delete; - -private: - int log_level_; - std::shared_ptr client_; - std::unique_ptr subscriber_context_; - std::atomic subscriber_active_; - std::mutex context_mutex_; - std::vector actuators_; - ActuatorChangeCallback cb_; -}; - - -} // namespace kuksa -} // namespace broker_feeder -} // namespace sdv diff --git a/someip2val/src/lib/broker_feeder/collector_client.cc b/someip2val/src/lib/broker_feeder/collector_client.cc deleted file mode 100644 index d2eceaca..00000000 --- a/someip2val/src/lib/broker_feeder/collector_client.cc +++ /dev/null @@ -1,160 +0,0 @@ -/******************************************************************************** -* Copyright (c) 2022 Contributors to the Eclipse Foundation -* -* See the NOTICE file(s) distributed with this work for additional -* information regarding copyright ownership. -* -* This program and the accompanying materials are made available under the -* terms of the Apache License 2.0 which is available at -* http://www.apache.org/licenses/LICENSE-2.0 -* -* SPDX-License-Identifier: Apache-2.0 -********************************************************************************/ - -#include - -#include "simple_log.h" -#include "collector_client.h" - -/*** LOG helpers */ -LOGGER_STATIC_INIT("# CollectorClient::"); - -namespace sdv { -namespace broker_feeder { - - -std::string getEnvVar(const std::string& name, const std::string& defaultValue) { - char* value = std::getenv(name.c_str()); - return value != nullptr ? std::string(value) : defaultValue; -} - -std::shared_ptr CollectorClient::createInstance(std::string broker_addr, std::string auth_token) { - return std::make_shared(broker_addr, auth_token); -} - -CollectorClient::CollectorClient(std::string broker_addr, std::string auth_token) - : broker_addr_(broker_addr) - , auth_token_(auth_token) - , connected_(false) -{ - // set log level from env "KUKSA_DEBUG", defaults to info - LOGGER_SET_LEVEL_ENV("KUKSA_DEBUG", LEVEL_INF); - - changeToDaprPortIfSet(broker_addr); - metadata_ = getGrpcMetadata(); - channel_ = grpc::CreateChannel(broker_addr, grpc::InsecureChannelCredentials()); - stub_ = sdv::databroker::v1::Collector::NewStub(channel_); - kuksa_stub_ = kuksa::val::v1::VAL::NewStub(channel_); -} - -bool CollectorClient::WaitForConnected(std::chrono::_V2::system_clock::time_point deadline) { - connected_ = channel_->WaitForConnected(deadline); - return connected_; -} - -grpc_connectivity_state CollectorClient::GetState() { - return channel_->GetState(false); -} - -bool CollectorClient::Connected() { - return connected_; -} - -void CollectorClient::SetDisconnected() { - connected_ = false; -} - -std::string CollectorClient::GetBrokerAddr() { - return broker_addr_; -} - -GrpcMetadata CollectorClient::getGrpcMetadata() { - GrpcMetadata grpc_metadata; - std::string dapr_app_id = getEnvVar("VEHICLEDATABROKER_DAPR_APP_ID"); - if (!dapr_app_id.empty()) { - grpc_metadata["dapr-app-id"] = dapr_app_id; - LOG_TRACE << "Setting dapr-app-id: " << dapr_app_id << std::endl; - - } - // allow overriding token file from env - std::string databroker_token = auth_token_.empty() ? getEnvVar("BROKER_TOKEN") : auth_token_; - if (!databroker_token.empty()) { - auto header = "Bearer " + databroker_token; - grpc_metadata["authorization"] = header; - LOG_TRACE << "Adding authorization: " << header << std::endl; - } - return grpc_metadata; -} - - -/** Change the port of the broker address passed to the c-tor to the port - * set by a possibly set DAPR_GRPC_PORT environment variable. */ -void CollectorClient::changeToDaprPortIfSet(std::string& broker_addr) { - std::string dapr_port = getEnvVar("DAPR_GRPC_PORT"); - if (!dapr_port.empty()) { - std::string::size_type colon_pos = broker_addr.find_last_of(':'); - broker_addr = broker_addr.substr(0, colon_pos + 1) + dapr_port; - LOG_INFO << "changing to DAPR GRPC port:" << broker_addr << std::endl; - } -} - -::grpc::Status CollectorClient::RegisterDatapoints(::grpc::ClientContext* context, - const ::sdv::databroker::v1::RegisterDatapointsRequest& request, - ::sdv::databroker::v1::RegisterDatapointsReply* response) { - return stub_->RegisterDatapoints(context, request, response); -} - -::grpc::Status CollectorClient::UpdateDatapoints(::grpc::ClientContext* context, - const ::sdv::databroker::v1::UpdateDatapointsRequest& request, - ::sdv::databroker::v1::UpdateDatapointsReply* response) { - return stub_->UpdateDatapoints(context, request, response); -} - -std::unique_ptr<::grpc::ClientReader<::kuksa::val::v1::SubscribeResponse>> -CollectorClient::Subscribe(::grpc::ClientContext *context, - const ::kuksa::val::v1::SubscribeRequest &request) { - return kuksa_stub_->Subscribe(context, request); -} - -/** Create the client context for a gRPC call and add possible gRPC metadata */ -std::unique_ptr CollectorClient::createClientContext() { - auto context = std::make_unique(); - for (const auto& metadata : metadata_) { - context->AddMetadata(metadata.first, metadata.second); - LOG_TRACE << " AddMetadata(" << metadata.first << ", " << metadata.second << ")" << std::endl; - } - LOG_TRACE << "ClientContext created." << std::endl; - return context; -} - -bool CollectorClient::handleGrpcError(const grpc::Status& status, const std::string& caller) { - if (status.ok()) return false; - - bool fatal_error = true; - std::stringstream ss; - ss << caller << " failed:\n" - << " ErrorCode: " << status.error_code() << "\n" - << " ErrorMsg: '" << status.error_message() << "'\n" - << " ErrorDet: '" << status.error_details() << "'\n" - << " grpcChannelState: " << GetState(); - LOG_ERROR << ss.str() << std::endl; - - switch (status.error_code()) { - case GRPC_STATUS_INTERNAL: - case GRPC_STATUS_UNAUTHENTICATED: - case GRPC_STATUS_UNIMPLEMENTED: - // case GRPC_STATUS_UNKNOWN: // disabled due to dapr {GRPC_STATUS_UNKNOWN; ErrorMsg: 'timeout waiting for address for app id vehicledatabroker'} - LOG_ERROR << ">>> Unrecoverable error -> stopping client." << std::endl; - fatal_error = true; - break; - default: - LOG_ERROR << ">>> Maybe temporary error -> trying reconnection to broker" << std::endl; - fatal_error = false; - break; - } - SetDisconnected(); - return fatal_error; -} - -} // namespace broker_feeder -} // namespace sdv diff --git a/someip2val/src/lib/broker_feeder/collector_client.h b/someip2val/src/lib/broker_feeder/collector_client.h deleted file mode 100644 index 79aa544f..00000000 --- a/someip2val/src/lib/broker_feeder/collector_client.h +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************** -* Copyright (c) 2022 Contributors to the Eclipse Foundation -* -* See the NOTICE file(s) distributed with this work for additional -* information regarding copyright ownership. -* -* This program and the accompanying materials are made available under the -* terms of the Apache License 2.0 which is available at -* http://www.apache.org/licenses/LICENSE-2.0 -* -* SPDX-License-Identifier: Apache-2.0 -********************************************************************************/ -#pragma once - -#include - -#include -#include - -#include "sdv/databroker/v1/collector.grpc.pb.h" -#include "kuksa/val/v1/val.grpc.pb.h" - -namespace sdv { -namespace broker_feeder { - -using GrpcMetadata = std::map; - -std::string getEnvVar(const std::string& name, const std::string& defaultValue = {}); - -class CollectorClient { - -public: - - /** - * Create a new instance - * - * @param broker_addr address of the broker to connect to; format ":" - * @param auth_token Optional OAuth jwt token to authorize with DataBroker - */ - static std::shared_ptr createInstance(std::string broker_addr, std::string auth_token = {}); - - /** - * @brief Construct a new Collector Client object - * - * @param broker_addr address of the broker to connect to; format ":" - * @param auth_token Optional OAuth jwt token to authorize with DataBroker - */ - CollectorClient(std::string broker_addr, std::string auth_token); - - virtual ~CollectorClient() = default; - - bool WaitForConnected(std::chrono::_V2::system_clock::time_point deadline); - - grpc_connectivity_state GetState(); - - bool Connected(); - - void SetDisconnected(); - - std::string GetBrokerAddr(); - - std::unique_ptr createClientContext(); - - ::grpc::Status RegisterDatapoints(::grpc::ClientContext* context, - const ::sdv::databroker::v1::RegisterDatapointsRequest& request, - ::sdv::databroker::v1::RegisterDatapointsReply* response); - - ::grpc::Status UpdateDatapoints(::grpc::ClientContext* context, - const ::sdv::databroker::v1::UpdateDatapointsRequest& request, - ::sdv::databroker::v1::UpdateDatapointsReply* response); - - std::unique_ptr<::grpc::ClientReader<::kuksa::val::v1::SubscribeResponse>> Subscribe( - ::grpc::ClientContext *context, - const ::kuksa::val::v1::SubscribeRequest &request); - - /** Log the gRPC error information and - * - either trigger re-connection and "recoverable" errors - * - or deactivate the feeder. - */ - bool handleGrpcError(const grpc::Status& status, const std::string& caller); - -protected: - /** Change the port of the broker address passed to the c-tor to the port - * set by a possibly set DAPR_GRPC_PORT environment variable. */ - void changeToDaprPortIfSet(std::string& broker_addr); - - /** - * @brief Returns GRPC Metadata object with set "authorization" / "dapr-app-id" headers - * - * @return GrpcMetadata - */ - GrpcMetadata getGrpcMetadata(); - -private: - GrpcMetadata metadata_; - std::shared_ptr channel_; - std::unique_ptr stub_; - std::unique_ptr kuksa_stub_; - std::atomic connected_; - std::atomic active_; - std::string broker_addr_; - std::string auth_token_; -}; - - -} // namespace broker_feeder -} // namespace sdv diff --git a/someip2val/src/lib/broker_feeder/create_datapoint.h b/someip2val/src/lib/broker_feeder/create_datapoint.h deleted file mode 100644 index 5a77258f..00000000 --- a/someip2val/src/lib/broker_feeder/create_datapoint.h +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************** -* Copyright (c) 2022 Contributors to the Eclipse Foundation -* -* See the NOTICE file(s) distributed with this work for additional -* information regarding copyright ownership. -* -* This program and the accompanying materials are made available under the -* terms of the Apache License 2.0 which is available at -* http://www.apache.org/licenses/LICENSE-2.0 -* -* SPDX-License-Identifier: Apache-2.0 -********************************************************************************/ -/** - * @file create_datapoint.h - * @brief File contains helper functions to create a Datapoint structure - * - */ -#pragma once - -#include "sdv/databroker/v1/types.pb.h" - -namespace sdv { -namespace broker_feeder { - -sdv::databroker::v1::Datapoint createInvalidValue() { - sdv::databroker::v1::Datapoint datapoint; - datapoint.set_failure_value(sdv::databroker::v1::Datapoint_Failure_INVALID_VALUE); - return datapoint; -} - -sdv::databroker::v1::Datapoint createNotAvailableValue() { - sdv::databroker::v1::Datapoint datapoint; - datapoint.set_failure_value(sdv::databroker::v1::Datapoint_Failure_NOT_AVAILABLE); - return datapoint; -} - -sdv::databroker::v1::Datapoint createDatapoint(bool value) { - sdv::databroker::v1::Datapoint datapoint; - datapoint.set_bool_value(value); - return datapoint; -} - -sdv::databroker::v1::Datapoint createDatapoint(int32_t value) { - sdv::databroker::v1::Datapoint datapoint; - datapoint.set_int32_value(value); - return datapoint; -} - -sdv::databroker::v1::Datapoint createDatapoint(uint32_t value) { - sdv::databroker::v1::Datapoint datapoint; - datapoint.set_uint32_value(value); - return datapoint; -} - -sdv::databroker::v1::Datapoint createDatapoint(int64_t value) { - sdv::databroker::v1::Datapoint datapoint; - datapoint.set_int64_value(value); - return datapoint; -} - -sdv::databroker::v1::Datapoint createDatapoint(uint64_t value) { - sdv::databroker::v1::Datapoint datapoint; - datapoint.set_uint64_value(value); - return datapoint; -} - -sdv::databroker::v1::Datapoint createDatapoint(float value) { - sdv::databroker::v1::Datapoint datapoint; - datapoint.set_float_value(value); - return datapoint; -} - -sdv::databroker::v1::Datapoint createDatapoint(double value) { - sdv::databroker::v1::Datapoint datapoint; - datapoint.set_double_value(value); - return datapoint; -} - -sdv::databroker::v1::Datapoint createDatapoint(const std::string& value) { - sdv::databroker::v1::Datapoint datapoint; - datapoint.set_string_value(value); - return datapoint; -} - -} // namespace broker_feeder -} // namespace sdv diff --git a/someip2val/src/lib/broker_feeder/data_broker_feeder.cc b/someip2val/src/lib/broker_feeder/data_broker_feeder.cc deleted file mode 100644 index 29cce24d..00000000 --- a/someip2val/src/lib/broker_feeder/data_broker_feeder.cc +++ /dev/null @@ -1,258 +0,0 @@ -/******************************************************************************** -* Copyright (c) 2022 Contributors to the Eclipse Foundation -* -* See the NOTICE file(s) distributed with this work for additional -* information regarding copyright ownership. -* -* This program and the accompanying materials are made available under the -* terms of the Apache License 2.0 which is available at -* http://www.apache.org/licenses/LICENSE-2.0 -* -* SPDX-License-Identifier: Apache-2.0 -********************************************************************************/ -/** - * @file data_broker_feeder.cc - * @brief File contains implementation of the generic class DataBrokerFeeder. - * - */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "data_broker_feeder.h" -#include "sdv/databroker/v1/collector.grpc.pb.h" - -#include "simple_log.h" - -// declare logger in root namespace -LOGGER_STATIC_INIT("# DataBrokerFeeder::"); - -namespace sdv { -namespace broker_feeder { - -using DatapointId = google::protobuf::int32; - -class DataBrokerFeederImpl final: - public DataBrokerFeeder -{ -private: - const GrpcMetadata grpc_metadata_; - const DatapointConfiguration dp_config_; - DatapointValues stored_values_; - google::protobuf::Map id_map_; - - std::atomic feeder_active_; - std::string broker_addr_; - std::mutex stored_values_mutex_; - std::condition_variable feeder_thread_sync_; - - std::shared_ptr client_; - std::unique_ptr subscriber_context_; - - public: - DataBrokerFeederImpl(std::shared_ptr client, DatapointConfiguration&& dp_config) - : client_(client) - , dp_config_(std::move(dp_config)) - , feeder_active_(true) - { - LOGGER_SET_LEVEL_ENV("DBF_DEBUG", LEVEL_INF); - } - - ~DataBrokerFeederImpl() { Shutdown(); } - - void Run() override { - /* This thread is responsible for establishing a connection to the data broker. - * Once connection is present, it starts registering the data points (metadata) - * with the broker and feeds the initial values (plus possible already stored values - * to the broker. - * Afterwards it is forwarding values stored by the feeding medthods and trys - * re-establishing a lost connection to the broker. - */ - while (feeder_active_) { - LOG_INFO << "Connecting to data broker [" << client_->GetBrokerAddr() << "] ..." << std::endl; - auto deadline = std::chrono::system_clock::now() + std::chrono::seconds(5); - client_->WaitForConnected(deadline); - if (client_->Connected()) { - LOG_INFO << "connected to data broker." << std::endl; - } - if (feeder_active_ && client_->Connected()) { - if (!registerDatapoints()) { - // don't attempt to feed values (too often) if registration status was an error - std::this_thread::sleep_for(std::chrono::seconds(5)); - continue; - } - } - - bool also_feed_initial_values = true; - while (feeder_active_ && client_->Connected()) { - feedStoredValues(also_feed_initial_values); - also_feed_initial_values = false; - - if (feeder_active_ && client_->Connected()) { - std::unique_lock lock(stored_values_mutex_); - if (stored_values_.empty()) { - feeder_thread_sync_.wait(lock); - } - } - } - } - } - - void Shutdown() override { - if (feeder_active_) { - LOG_INFO << "Waiting for feeder to stop ..." << std::endl; - { - std::unique_lock lock(stored_values_mutex_); - stored_values_.clear(); - feeder_active_ = false; - } - feeder_thread_sync_.notify_all(); - LOG_INFO << "Feeder stopped." << std::endl; - } - - if (subscriber_context_) { - subscriber_context_->TryCancel(); - } - } - - /** Feed a set ("batch") of datapoint values to the data broker. - * If the data broker is currently not connected or another "recoverable"error occurs, the passed - * values are stored by the feeder and tried being send, when the connection to the broker could be - * established (again). - */ - void FeedValues(const DatapointValues& values) override - { - if (feeder_active_) { - LOG_TRACE << "Enqueue " << values.size() << " values." << std::endl; - std::unique_lock lock(stored_values_mutex_); - storeValues(values); - feeder_thread_sync_.notify_all(); - } - } - - /** Feed a single datapoint value to the data broker. - * (@see FeedValues) - */ - void FeedValue(const std::string& name, const sdv::databroker::v1::Datapoint& value) override - { - if (feeder_active_) { - LOG_TRACE << "Enqueue value: { " << value.ShortDebugString() << " } " << std::endl; - std::unique_lock lock(stored_values_mutex_); - storeValue(name, value); - feeder_thread_sync_.notify_all(); - } - } - -private: - /** Add the passed values to the stored values (possibly overwriting already stored values) */ - void storeValues(const DatapointValues& values) { - for (const auto& value : values) { - storeValue(value.first, value.second); - } - } - - /** Add the passed value to the stored values (possibly overwriting an already stored value) */ - void storeValue(const std::string& name, const sdv::databroker::v1::Datapoint& value) { - stored_values_[name] = value; - } - - /** Register the data points (metadata) passed to the c-tor with the data broker. - */ - bool registerDatapoints() { - LOG_DEBUG << "Registering " << dp_config_.size() << " datapoints." << std::endl; - sdv::databroker::v1::RegisterDatapointsRequest request; - for (const auto& metadata : dp_config_) { - ::sdv::databroker::v1::RegistrationMetadata reg_data; - reg_data.set_name(metadata.name); - reg_data.set_data_type(metadata.data_type); - reg_data.set_change_type(metadata.change_type); - reg_data.set_description(metadata.description); - request.mutable_list()->Add(std::move(reg_data)); - } - - auto context = client_->createClientContext(); - sdv::databroker::v1::RegisterDatapointsReply reply; - grpc::Status status = client_->RegisterDatapoints(context.get(), request, &reply); - if (status.ok()) { - LOG_INFO << "Datapoints registered." << std::endl; - id_map_ = std::move(*reply.mutable_results()); - for (const auto& name_to_id : id_map_) { - LOG_DEBUG << " '" << name_to_id.first << "' -> " << std::dec << name_to_id.second << std::endl; - } - return true; - } else { - client_->handleGrpcError(status, "DataBrokerFeederImpl::registerDatapoints"); - return false; - } - } - - /** Feed stored and - on demand - initial values to the data broker. - * If for a datapoint an initial as well as a stored value is present, the stored on gets precedence. - */ - void feedStoredValues(bool feed_initial_values = false) { - DatapointValues values_to_feed; - { - std::unique_lock lock(stored_values_mutex_); - values_to_feed.swap(stored_values_); - } - if (feed_initial_values) { - for (const auto& metadata : dp_config_) { - values_to_feed.insert(std::make_pair(metadata.name, metadata.initial_value)); - } - } - bool successfully_sent = feedToBroker(values_to_feed); - if (!successfully_sent) { - restoreValues(std::move(values_to_feed)); - } - } - - /** Feed the passed values to the data broker. */ - bool feedToBroker(const DatapointValues& values_to_feed) { - LOG_DEBUG << "Feeding " << std::dec << values_to_feed.size() << " values." << std::endl; - sdv::databroker::v1::UpdateDatapointsRequest request; - for (const auto& value : values_to_feed) { - auto iter = id_map_.find(value.first); - if (iter != id_map_.end()) { - auto id = iter->second; - (*request.mutable_datapoints())[id] = value.second; - LOG_DEBUG <<" '"<< value.first <<"' ("<< id <<") of type " - << std::dec << (int)value.second.value_case() - << ", value: { " << value.second.ShortDebugString() << " }" - << std::endl; - } else { - LOG_ERROR <<" Unknown name '" << value.first << "'!" << std::endl; - } - } - - auto context = client_->createClientContext(); - sdv::databroker::v1::UpdateDatapointsReply reply; - grpc::Status status = client_->UpdateDatapoints(context.get(), request, &reply); - if (status.ok()) { - return true; - } - client_->handleGrpcError(status, "DataBrokerFeederImpl::feedToBroker"); - return false; - } - - /** Re-store values on a feeding error; already contained values are rated newer and are not overwritten */ - void restoreValues(DatapointValues&& values) { - std::unique_lock lock(stored_values_mutex_); - stored_values_.insert(values.begin(), values.end()); - } - -}; - -std::shared_ptr DataBrokerFeeder::createInstance(std::shared_ptr client, - DatapointConfiguration&& dpConfig) { - return std::make_shared(client, std::move(dpConfig)); -} - -} // namespace broker_feeder -} // namespace sdv diff --git a/someip2val/src/lib/broker_feeder/data_broker_feeder.h b/someip2val/src/lib/broker_feeder/data_broker_feeder.h deleted file mode 100644 index 2a0f05bc..00000000 --- a/someip2val/src/lib/broker_feeder/data_broker_feeder.h +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************** -* Copyright (c) 2022 Contributors to the Eclipse Foundation -* -* See the NOTICE file(s) distributed with this work for additional -* information regarding copyright ownership. -* -* This program and the accompanying materials are made available under the -* terms of the Apache License 2.0 which is available at -* http://www.apache.org/licenses/LICENSE-2.0 -* -* SPDX-License-Identifier: Apache-2.0 -********************************************************************************/ -/** - * @file data_broker_feeder.h - * @brief The DataBrokerFeeder is generic feeder allowing to register and - * feed data points into the KUKSA Data Broker: - * * The set of feedable datapoints is passed on construction time - * to the feeder as a parameter together with the broker address. - * * Data points can be feed separately or as a batch. - * * It handles the registration of the data points (metadata) with - * the Data Broker. - * * It also handles reconnection to the broker after connection loss - */ -#pragma once - -#include -#include -#include -#include - -#include "collector_client.h" -#include "sdv/databroker/v1/types.pb.h" -namespace sdv { -namespace broker_feeder { - - -struct DatapointMetadata { - std::string name; - sdv::databroker::v1::DataType data_type; - sdv::databroker::v1::ChangeType change_type; - sdv::databroker::v1::Datapoint initial_value; - std::string description; -}; - -using DatapointConfiguration = std::vector; -using DatapointValues = std::unordered_map; - -class DataBrokerFeeder { -public: - /** - * Create a new feeder instance - * - * @param broker_addr address of the broker to connect to; format ":" - * @param dpConfig metadata and initial values of the data points to register - */ - static std::shared_ptr createInstance(std::shared_ptr client, - DatapointConfiguration&& dpConfig); - - virtual ~DataBrokerFeeder() = default; - - /** - * Starts the feeder trying to connect to the data broker, registering data points - * and sending data point updates to the broker. - * Note: This function will block the calling thread until the feeder is terminated by - * an unrecoverable error or a call to Shutdown() or the destructor. It should typically - * run in an own thread created by the caller. - */ - virtual void Run() = 0; - - /** Terminates the running feeder */ - virtual void Shutdown() = 0; - - /** - * Try to feed a single data point value to the broker. - * The data point must have been part of the dpConfig passed at creation time. - * @param name Name (path) of the data point to be fed (update). - * @param value The value to be fed - */ - virtual void FeedValue(const std::string& name, const sdv::databroker::v1::Datapoint& value) = 0; - - /** - * Try to feed a batch of data point values to the broker. - * The data points must have been part of the dpConfig passed at creation time. - * @param values A map of data point names (keys) to data point values to be fed - */ - virtual void FeedValues(const DatapointValues& values) = 0; - -protected: - DataBrokerFeeder() = default; - DataBrokerFeeder(const DataBrokerFeeder&) = delete; - DataBrokerFeeder& operator=(const DataBrokerFeeder&) = delete; -}; - - -} // namespace broker_feeder -} // namespace sdv diff --git a/someip2val/src/lib/broker_feeder/simple_log.h b/someip2val/src/lib/broker_feeder/simple_log.h deleted file mode 100644 index 2229aed5..00000000 --- a/someip2val/src/lib/broker_feeder/simple_log.h +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************** -* Copyright (c) 2022 Contributors to the Eclipse Foundation -* -* See the NOTICE file(s) distributed with this work for additional -* information regarding copyright ownership. -* -* This program and the accompanying materials are made available under the -* terms of the Apache License 2.0 which is available at -* http://www.apache.org/licenses/LICENSE-2.0 -* -* SPDX-License-Identifier: Apache-2.0 -********************************************************************************/ -#pragma once - -#include -#include -#include - -namespace sdv { -namespace logger { - -const int LEVEL_ERR = 0; -const int LEVEL_INF = 1; -const int LEVEL_DBG = 2; -const int LEVEL_TRC = 3; - -#define DEFAULT_LOGLEVEL ::sdv::logger::LEVEL_INF - -/// Using static C strings as structs are destroyed atexit() and logging causes invalid reads - -/** - * @brief Use LOGGER_STATIC_INIT("") in your class *before* namespace declaration - */ -#define LOGGER_STATIC_INIT(MODULE) \ - using namespace sdv::logger; \ - static constexpr const char* g_log_module = MODULE; \ - static int g_log_level = DEFAULT_LOGLEVEL; - -#define LOGGER_SET_LEVEL(LEVEL) \ - g_log_level = LEVEL; - -#define LOGGER_SET_LEVEL_ENV(ENV_PROP, DEFAULT_VALUE) \ - g_log_level = ::sdv::logger::GetEnvironmentInt(ENV_PROP, DEFAULT_VALUE); - -#define LOGGER_ENABLED(LEVEL) \ - (g_log_level >= LEVEL) - - -// /!\ WARNING: LOG_XXX functions use unsafe if (), could consume else from parent block! -#define LOG_TRACE if (LOGGER_ENABLED(::sdv::logger::LEVEL_TRC)) std::cout << g_log_module << __func__ << ": [trace] " -#define LOG_DEBUG if (LOGGER_ENABLED(::sdv::logger::LEVEL_DBG)) std::cout << g_log_module << __func__ << ": [debug] " -#define LOG_INFO if (LOGGER_ENABLED(::sdv::logger::LEVEL_INF)) std::cout << g_log_module << __func__ << ": [info] " -#define LOG_ERROR if (LOGGER_ENABLED(::sdv::logger::LEVEL_ERR)) std::cerr << g_log_module << __func__ << ": [error] " - -inline int GetEnvironmentInt(std::string envName, int default_value) { - const char* val = std::getenv(envName.c_str()); - if (!val) return default_value; - return std::atoi(val); -} - -} // namespace logger -} // namespace sdv diff --git a/someip2val/src/lib/someip_client/CMakeLists.txt b/someip2val/src/lib/someip_client/CMakeLists.txt deleted file mode 100644 index a61b9e7f..00000000 --- a/someip2val/src/lib/someip_client/CMakeLists.txt +++ /dev/null @@ -1,48 +0,0 @@ -#******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -#*******************************************************************************/ - -cmake_minimum_required(VERSION 3.11) - -# external dependencies -#find_package(Boost 1.55 COMPONENTS system thread filesystem REQUIRED ) -if (NOT vsomeip3_POPULATED) - find_package(vsomeip3) -endif() -find_package(Threads REQUIRED) - -# Wiper POC -add_library(someip_client - EXCLUDE_FROM_ALL - STATIC - someip_client.cc -) - -target_link_libraries(someip_client - PRIVATE - vsomeip3 - ${Boost_LIBRARIES} - ${DL_LIBRARY} -) - -target_include_directories(someip_client - PUBLIC - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} -) - -install(TARGETS someip_client - PUBLIC_HEADER - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} -) - -################################################################################################### diff --git a/someip2val/src/lib/someip_client/sample_ids.h b/someip2val/src/lib/someip_client/sample_ids.h deleted file mode 100644 index b478f48b..00000000 --- a/someip2val/src/lib/someip_client/sample_ids.h +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************** -* Copyright (c) 2022 Contributors to the Eclipse Foundation -* -* See the NOTICE file(s) distributed with this work for additional -* information regarding copyright ownership. -* -* This program and the accompanying materials are made available under the -* terms of the Apache License 2.0 which is available at -* http://www.apache.org/licenses/LICENSE-2.0 -* -* SPDX-License-Identifier: Apache-2.0 -********************************************************************************/ - -#ifndef SOMEIP_SAMPLE_IDS_H -#define SOMEIP_SAMPLE_IDS_H - -#define SAMPLE_SERVICE_MAJOR 0x01 -#define SAMPLE_SERVICE_MINOR 0x00 - -#define SAMPLE_SERVICE_ID 0x1234 -#define SAMPLE_INSTANCE_ID 0x5678 -#define SAMPLE_METHOD_ID 0x0421 - -#define SAMPLE_EVENTGROUP_ID 0x4465 -#define SAMPLE_EVENT_ID 0x8000 - -// Internally considered as invalid value for service/instance/method IDs -#define SAMPLE_INVALID_VALUE 0x0000 - - -#endif // SOMEIP_SAMPLE_IDS_H diff --git a/someip2val/src/lib/someip_client/someip_client.cc b/someip2val/src/lib/someip_client/someip_client.cc deleted file mode 100644 index efa64ee8..00000000 --- a/someip2val/src/lib/someip_client/someip_client.cc +++ /dev/null @@ -1,483 +0,0 @@ -/******************************************************************************** -* Copyright (c) 2022 Contributors to the Eclipse Foundation -* -* See the NOTICE file(s) distributed with this work for additional -* information regarding copyright ownership. -* -* This program and the accompanying materials are made available under the -* terms of the Apache License 2.0 which is available at -* http://www.apache.org/licenses/LICENSE-2.0 -* -* SPDX-License-Identifier: Apache-2.0 -********************************************************************************/ - -#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING -// # warning VSOMEIP_ENABLE_SIGNAL_HANDLING is not defined! -#endif - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "sample_ids.h" -#include "someip_client.h" - -namespace sdv { -namespace someip { - -/*** LOG helpers */ -#define LEVEL_TRC 3 -#define LEVEL_DBG 2 -#define LEVEL_INF 1 -#define LEVEL_ERR 0 - -#define MODULE_PREFIX "# SomeIPClient<" - -#define LOG_TRACE if (config_.debug >= LEVEL_TRC) std::cout << MODULE_PREFIX << name_ << ">::" << __func__ << ": [trace] " -#define LOG_DEBUG if (config_.debug >= LEVEL_DBG) std::cout << MODULE_PREFIX << name_ << ">::" << __func__ << ": [debug] " -#define LOG_INFO if (config_.debug >= LEVEL_INF) std::cout << MODULE_PREFIX << name_ << ">::" << __func__ << ": [info] " -#define LOG_ERROR if (config_.debug >= LEVEL_ERR) std::cerr << MODULE_PREFIX << name_ << ">::" << __func__ << ": [error] " - -SomeIPClient::SomeIPClient(SomeIPConfig _config, message_callback_t _callback) : - config_(_config), - callback_(_callback), - stop_requested_(false), - initialized_(false), - use_req_(false), - req_service_available(false) -{ - use_tcp_ = config_.use_tcp; - name_ = config_.app_name.empty() ? "UNKNOWN" : config_.app_name; - // log_prefix_ = "*** [SomeIPClient/" + name_ + "] " - - // FIXME: replace with config_. everywhere... - service_ = config_.service; - instance_ = config_.instance; - service_major_ = config_.service_major; - service_minor_ = config_.service_minor; - event_group_ = config_.event_group; - event_ = config_.event; - - use_req_ = config_.req.use_req; - // req_config_ = config_.req; - req_service_ = config_.req.service; - req_instance_ = config_.req.instance; - req_service_major_ = config_.req.service_major; - req_service_minor_ = config_.req.service_minor; - req_method_ = config_.req.method; - - app_ = vsomeip::runtime::get()->create_application(name_); - if (callback_ == nullptr) { - LOG_ERROR << "Warning, Some/IP callback is not set!" << std::endl; - } -} - -SomeIPClient::~SomeIPClient() { - LOG_TRACE << "called. " << std::endl; - Shutdown(); - LOG_TRACE << "done." << std::endl; -} - -bool SomeIPClient::init() { - // WARNING: init() may call std::exit() in some cases, it probably would deadlock on app->stop() - if (!app_->init()) { - LOG_ERROR << "Couldn't initialize application: " << app_->get_name() << std::endl; - return false; - } - // important! handles stop() from app->init() - initialized_ = true; - name_ = app_->get_name(); // app name is valid here - - LOG_INFO << "Client settings " - << "{ service:0x" << std::hex << std::setfill('0') << std::setw(4) << service_ - << ", instance:0x" << std::hex << std::setfill('0') << std::setw(4) << instance_ - << ", ver " << std::dec << (int)service_major_ << "." << (int)service_minor_ - << ", group_:0x" << std::hex << std::setfill('0') << std::setw(4) << event_group_ - << ", event:0x" << std::hex << std::setfill('0') << std::setw(4) << event_ - << "} [protocol=" << (use_tcp_ ? "TCP" : "UDP") << "]" - << std::endl; - - app_->register_state_handler( - std::bind(&SomeIPClient::on_state, this, - std::placeholders::_1)); - - app_->register_message_handler( - vsomeip::ANY_SERVICE, vsomeip::ANY_INSTANCE, vsomeip::ANY_METHOD, - std::bind(&SomeIPClient::on_message, this, - std::placeholders::_1)); - - app_->register_availability_handler( - vsomeip_v3::ANY_SERVICE, vsomeip_v3::ANY_INSTANCE, - std::bind(&SomeIPClient::on_availability, - this, - std::placeholders::_1, std::placeholders::_2, std::placeholders::_3) - ); - - init_event_service(service_, instance_, event_group_, event_, service_major_, service_minor_); - return true; -} - - -void SomeIPClient::init_event_service( - vsomeip::service_t service, - vsomeip::instance_t instance, - vsomeip::eventgroup_t event_group, - vsomeip::event_t event, - vsomeip::major_version_t service_major, - vsomeip::minor_version_t service_minor) { - - std::set its_groups; - its_groups.insert(event_group); - - vsomeip::event_type_e event_type = vsomeip::event_type_e::ET_FIELD; - vsomeip::reliability_type_e reliability_type = - (use_tcp_ ? vsomeip::reliability_type_e::RT_RELIABLE : - vsomeip::reliability_type_e::RT_UNRELIABLE); - LOG_INFO << "Request event [" - << std::hex << std::setfill('0') << std::setw(4) << service << "." - << std::hex << std::setfill('0') << std::setw(4) << instance - << "], event:0x" << std::hex << std::setfill('0') << std::setw(4) << event - << ", event_type:" << std::dec << (int)event_type - << ", reliability:" << std::dec << (int)reliability_type - << std::endl; - app_->request_event( - service, instance, event, - its_groups, - event_type, - reliability_type); - - LOG_INFO << "Subscribing [" - << std::hex << std::setfill('0') << std::setw(4) << service << "." - << std::hex << std::setfill('0') << std::setw(4) << instance - << "] ver." << std::dec << (int)service_major - << ", event_group:0x" - << std::hex << std::setfill('0') << std::setw(4) << event_group - << ", event:0x" - << std::hex << std::setfill('0') << std::setw(4) << event - << std::endl; - - app_->subscribe(service, instance, event_group, service_major, event); -} - -/** - * @brief SOMEIP main thread, blocking call, should be called in a thread - * - * @return true if initialized - */ -bool SomeIPClient::Run() { - if (init()) { - start(); - return true; - } - return false; -} - -void SomeIPClient::Shutdown() { - std::unique_lock its_lock(stop_mutex_); - LOG_TRACE << "Shutdown() / stop_requested_=" << stop_requested_ - << ", initialized_=" << initialized_ << std::endl; - if (!stop_requested_) { - stop_requested_ = true; - LOG_DEBUG << "Shutting down..." << std::endl; - stop(); - } -} - -void SomeIPClient::start() { - LOG_INFO << "Starting..." << std::endl; - app_->start(); - LOG_TRACE << "done." << std::endl; -} - -/** - * @brief Shuts down someip client (may be called from signal handler) - * May cause problems if someip is compiled with -DVSOMEIP_ENABLE_SIGNAL_HANDLING - */ -void SomeIPClient::stop() { - LOG_INFO << "Stopping..." << std::endl; - - req_service_available = false; - req_condition_.notify_all(); - - app_->clear_all_handler(); - LOG_DEBUG << "Releasing Event service..." << std::endl; - app_->unsubscribe(service_, instance_, event_group_, event_); - app_->release_event(service_, instance_, event_); - app_->release_service(service_, instance_); - - if (use_req_) { - LOG_DEBUG << "Releasing Reqest/Response service..." << std::endl; - app_->release_service(req_service_, req_instance_); - } - if (!initialized_) { - LOG_INFO << "Not stopping partially initialized app!" << std::endl; - } else { // experimental code, stop may hung, without it rely on app destructor - if (config_.debug > 2) { - LOG_INFO << "app->stop()" << std::endl; - } - app_->stop(); - if (config_.debug > 0) { - LOG_INFO << "stopped." << std::endl; - } - } -} - -const SomeIPConfig SomeIPClient::GetConfig() const { - return (const SomeIPConfig)config_; -} - -void SomeIPClient::on_state(vsomeip::state_type_e _state) { - if (config_.debug > 0) { - LOG_INFO << "State " - << (_state == vsomeip::state_type_e::ST_REGISTERED ? "REGISTERED" : "DEREGISTERED") - << std::endl; - } - if (_state == vsomeip::state_type_e::ST_REGISTERED) { - LOG_INFO << "Requesting Event Service [" - << std::setw(4) << std::setfill('0') << std::hex << service_ - << "." - << std::setw(4) << std::setfill('0') << std::hex << instance_ - << " v" - << std::dec << (int)service_major_ - << "." - << (int)service_minor_ << "]" << std::endl; - app_->request_service(service_, instance_, service_major_, service_minor_); - - if (use_req_) { - LOG_INFO << "Requesting Request/Response Service [" - << std::setw(4) << std::setfill('0') << std::hex << req_service_ - << "." - << std::setw(4) << std::setfill('0') << std::hex << req_instance_ - << " v" - << std::dec << (int)req_service_major_ - << "." - << (int)req_service_minor_ << "]" << std::endl; - app_->request_service(req_service_, req_instance_, - req_service_major_, req_service_minor_); - } - } -} - -void SomeIPClient::on_availability(vsomeip::service_t _service, vsomeip::instance_t _instance, bool _is_available) { - LOG_INFO << "Service [" - << std::setw(4) << std::setfill('0') << std::hex << _service << "." - << std::setw(4) << std::setfill('0') << std::hex << _instance - << "] is " - << (_is_available ? "available." : "NOT available.") - << std::endl; - - // if (_service == service_ && _instance == instance_) { - // } else - if (_service == req_service_ && _instance == req_instance_) { - LOG_INFO << "Notify Request Service available" << std::endl; - req_service_available = _is_available; - req_condition_.notify_one(); - } -} - -void SomeIPClient::on_message(const std::shared_ptr &_response) { - std::shared_ptr its_payload = _response->get_payload(); - if (config_.debug > 2) { - std::stringstream its_message; - its_message << "Received a " - << message_type_to_string(_response->get_message_type()) - << " for Event [" - << std::setw(4) << std::setfill('0') << std::hex - << _response->get_service() << "." - << std::setw(4) << std::setfill('0') << std::hex - << _response->get_instance() << "." - << std::setw(4) << std::setfill('0') << std::hex - << _response->get_method() << "] v" - << _response->get_interface_version() - << " to Client/Session [" - << std::setw(4) << std::setfill('0') << std::hex - << _response->get_client() << "/" - << std::setw(4) << std::setfill('0') << std::hex - << _response->get_session() - << "] = "; - - its_message << "(" << std::dec << its_payload->get_length() << ") "; - for (uint32_t i = 0; i < its_payload->get_length(); ++i) { - its_message << std::hex << std::setw(2) << std::setfill('0') - << (int) its_payload->get_data()[i] << " "; - } - its_message << std::endl; - LOG_INFO << its_message.str(); - } - // callback should handle if it knows service:instance:event and avoid parsing wrong events - if (callback_ != nullptr) { - int rc = callback_(_response->get_service(), - _response->get_instance(), - _response->get_method(), - its_payload->get_data(), - its_payload->get_length()); - if (rc) { - LOG_ERROR << "WARNING! callback failed decoding " - << its_payload->get_length() << " bytes" << std::endl; - } - } -} - -int SomeIPClient::SendRequest(vsomeip::service_t req_service, vsomeip::instance_t req_instance, - vsomeip::method_t req_method, std::vector payload) -{ - std::unique_lock cond_lock(req_mutex_); - if (!use_req_) { - LOG_ERROR << "Requst Service not enabled!" << std::endl; - return -1; - } - if (!req_service_available) { - LOG_DEBUG << "Waiting for Request Service..." << std::endl; - auto deadline = std::chrono::system_clock::now() + std::chrono::seconds(5); - req_condition_.wait_until(cond_lock, deadline); - if (!req_service_available) { - LOG_ERROR << "Requst Service not available! Attempt sending anyway..." << std::endl; - // return -2; - } - } - // Create a new request - std::shared_ptr rq = vsomeip::runtime::get()->create_request(); - // Set the VSS service as target of the request - rq->set_service(req_service); - rq->set_instance(req_instance); - rq->set_method(req_method); - // rq->set_interface_version(req_major); // not needed, set to vsomeip_v3::sd::interface_version(0x1) - - std::shared_ptr pl = vsomeip::runtime::get()->create_payload(); - pl->set_data(payload); - rq->set_payload(pl); - // Send the request to the service. Response will be delivered to the - // registered message handler - std::stringstream ss; - ss << "### Sending Request to [" - << std::setw(4) << std::setfill('0') << std::hex << req_service << "." - << std::setw(4) << std::setfill('0') << std::hex << req_instance << "." - << std::setw(4) << std::setfill('0') << std::hex << req_method << "]"; - - if (config_.debug > 0) { - ss << " with payload: " << hexdump(payload.data(), payload.size()); - } - ss << std::endl; - LOG_INFO << ss.str(); - app_->send(rq); - LOG_TRACE << "### Request sent." << std::endl; - // TODO: wait for reply? - return 0; -} - - - -std::shared_ptr SomeIPClient::createInstance(SomeIPConfig _config, message_callback_t callback) -{ - return std::make_shared(_config, callback); -} - -SomeIPConfig SomeIPClient::createEnvConfig() { - // SomeIPConfig config = SomeIPClient::createDefaultConfig(); - SomeIPConfig config; - config.debug = getEnvironmentInt("SOMEIP_CLI_DEBUG", 1); - - config.use_tcp = (getEnvironmentInt("SOMEIP_CLI_TCP", 0) == 1); - config.app_config = getEnvironmentStr("VSOMEIP_CONFIGURATION", ""); - config.app_name = getEnvironmentStr("VSOMEIP_APPLICATION_NAME", "UNKNOWN"); - - config.service = getEnvironmentInt("SOMEIP_CLI_SERVICE", SAMPLE_SERVICE_ID); - config.instance = getEnvironmentInt("SOMEIP_CLI_INSTANCE", SAMPLE_INSTANCE_ID); - - config.event_group = getEnvironmentInt("SOMEIP_CLI_EVENTGROUP", SAMPLE_EVENTGROUP_ID); - config.event = getEnvironmentInt("SOMEIP_CLI_EVENT", SAMPLE_EVENT_ID); - - config.service_major = getEnvironmentInt("SOMEIP_CLI_MAJOR", SAMPLE_SERVICE_MAJOR); - config.service_minor = getEnvironmentInt("SOMEIP_CLI_MINOR", SAMPLE_SERVICE_MINOR); - - // req/response support (disabled by default) - config.req.use_req = (getEnvironmentInt("SOMEIP_CLI_REQ", 0) == 1); - config.req.service = getEnvironmentInt("SOMEIP_CLI_REQ_SERVICE", SAMPLE_INVALID_VALUE); - config.req.instance = getEnvironmentInt("SOMEIP_CLI_REQ_INSTANCE", SAMPLE_INVALID_VALUE); - config.req.service_major = getEnvironmentInt("SOMEIP_CLI_REQ_MAJOR", vsomeip::DEFAULT_MAJOR); - config.req.service_minor = getEnvironmentInt("SOMEIP_CLI_REQ_MINOR", vsomeip::DEFAULT_MINOR); - config.req.method = getEnvironmentInt("SOMEIP_CLI_REQ_METHOD", SAMPLE_INVALID_VALUE); - // TODO: validate req config? - - return config; -} - - -std::string message_type_to_string(vsomeip::message_type_e msg_type) { - switch (msg_type) { - case vsomeip::message_type_e::MT_ERROR: - return "Error"; - case vsomeip::message_type_e::MT_ERROR_ACK: - return "Error/ack"; - case vsomeip::message_type_e::MT_NOTIFICATION: - return "Notification"; - case vsomeip::message_type_e::MT_NOTIFICATION_ACK: - return "Notification/ack"; - case vsomeip::message_type_e::MT_REQUEST: - return "Request"; - case vsomeip::message_type_e::MT_REQUEST_ACK: - return "Request/ack"; - case vsomeip::message_type_e::MT_REQUEST_NO_RETURN: - return "Request/no_ret"; - case vsomeip::message_type_e::MT_REQUEST_NO_RETURN_ACK: - return "Request/no_ret/ack"; - case vsomeip::message_type_e::MT_RESPONSE: - return "Response"; - case vsomeip::message_type_e::MT_RESPONSE_ACK: - return "Response/ack"; - default: - std::stringstream its_message; - its_message << "Unknown <0x" << std::hex << (int)msg_type << ">"; - return its_message.str(); - } -} - -int getEnvironmentInt(const std::string &envVar, int defaultValue, bool dump) { - const char* envValue = ::getenv(envVar.c_str()); - if (envValue) { - try { - int result = std::stoi(std::string(envValue), nullptr, 0); - if (dump) { - std::cout << __func__ << " [env] " << envVar << " := " << envValue << std::endl; - } - return result; - } catch(std::exception const& ex) { - std::cerr << __func__ << " Invalid integer for " << envVar - << " : " << envValue - << ", (" << ex.what() << ")" << std::endl; - } - } - return defaultValue; -} - -std::string getEnvironmentStr(const std::string &envVar, const std::string &defaultValue, bool dump) { - const char* value = ::getenv(envVar.c_str()); - if (value) { - if (dump) { - std::cout << __func__ << " [env] " << envVar << " := " << value << std::endl; - } - return std::string(value); - } - return defaultValue; -} - -std::string hexdump(uint8_t *buf, size_t size) { - std::stringstream ss; - // ss << "(" << std::dec << size << ") "; - for (uint32_t i = 0; i < size; ++i) { - ss << std::hex << std::setw(2) << std::setfill('0') << (int) buf[i]; - if (i < size - 1) { - ss << " "; - } - } - return ss.str(); -} - -} // namespace someip -} // namespace sdv diff --git a/someip2val/src/lib/someip_client/someip_client.h b/someip2val/src/lib/someip_client/someip_client.h deleted file mode 100644 index 688346fe..00000000 --- a/someip2val/src/lib/someip_client/someip_client.h +++ /dev/null @@ -1,264 +0,0 @@ -/******************************************************************************** -* Copyright (c) 2022 Contributors to the Eclipse Foundation -* -* See the NOTICE file(s) distributed with this work for additional -* information regarding copyright ownership. -* -* This program and the accompanying materials are made available under the -* terms of the Apache License 2.0 which is available at -* http://www.apache.org/licenses/LICENSE-2.0 -* -* SPDX-License-Identifier: Apache-2.0 -********************************************************************************/ - -#ifndef SOMEIP_CLIENT_H -#define SOMEIP_CLIENT_H - -#include - -#include -#include "sample_ids.h" - -namespace sdv { -namespace someip { - - -struct SomeIPRequestConfig { - bool use_req = false; - /** - * @brief SOME/IP Service ID for request/response - */ - vsomeip::service_t service = SAMPLE_INVALID_VALUE; - - /** - * @brief SOME/IP Instance ID for request/response - */ - vsomeip::instance_t instance = SAMPLE_INVALID_VALUE; - - /** - * @brief SOME/IP Method ID or request/response - */ - vsomeip::method_t method = SAMPLE_INVALID_VALUE; - - /** - * @brief SOME/IP Service major version. May be needed if service/someip - * impl register with major != 0 - */ - vsomeip::major_version_t service_major = vsomeip::ANY_MAJOR; - /** - * @brief SOME/IP Service minor version. - */ - vsomeip::minor_version_t service_minor = vsomeip::ANY_MINOR; -}; - - -/** - * @brief SOME/IP Client configuration. - * - * NOTE: There is a dependency on app_name and config file specified in - * VSOMEIP_CONFIGURATION environment variable. - * - */ -struct SomeIPConfig { - - /** - * @brief vsomeip Application Name. Must match provided app_config json file! - * Also defined in "VSOMEIP_APPLICATION_NAME" environment variable. - */ - std::string app_name = "UNKNOWN"; - - /** - * @brief Just a reference to exported "VSOMEIP_CONFIGURATION" environment variable - */ - std::string app_config = ""; - - /** - * @brief If true, reliable endpoits should be used, depends on the notify server configuration - */ - bool use_tcp = false; - - /** - * @brief someip client debug verbosity (0=quiet, ...) - */ - int debug = 0; - - /** - * @brief SOME/IP Service ID to subscribe - */ - vsomeip::service_t service = SAMPLE_SERVICE_ID; - - /** - * @brief SOME/IP Instance ID to subscribe - */ - vsomeip::instance_t instance = SAMPLE_INSTANCE_ID; - - /** - * @brief SOME/IP EventGroup ID - */ - vsomeip::eventgroup_t event_group = SAMPLE_EVENTGROUP_ID; - - /** - * @brief SOME/IP Event ID - */ - vsomeip::event_t event = SAMPLE_EVENT_ID; - - /** - * @brief SOME/IP Service major version. May be needed if service/someip - * impl register with major != 0 - */ - vsomeip::major_version_t service_major = vsomeip::ANY_MAJOR; - /** - * @brief SOME/IP Service minor version. - */ - vsomeip::minor_version_t service_minor = vsomeip::ANY_MINOR; - - ///// request response service config - SomeIPRequestConfig req; -}; - -/** - * @brief callback std::function for handling incoming SOME/IP payload - * - * @param payload uint8_t* someip notification payload - * @param size someip payload size - * @return <0 on error - */ -typedef std::function < - int (vsomeip::service_t service, - vsomeip::instance_t instance, - vsomeip::method_t event, - const uint8_t *payload, - size_t size) - > message_callback_t; - -/** - * @brief Wraps a generic SOME/IP Client for receiving notification events and feeding received raw SOME/IP - * payload to specified callback for custom decoding - */ -class SomeIPClient -{ -public: - - /** - * @brief Create an Instance of someip client. - * - * @param _config SomeIPConfig structure with client configuration - * @param _callback user provided callback for handling raw event payload - * @return std::shared_ptr - */ - static std::shared_ptr createInstance(SomeIPConfig _config, message_callback_t _callback); - - // static SomeIPConfig createDefaultConfig(); - static SomeIPConfig createEnvConfig(); - - // SomeIPClient(bool _use_tcp, message_callback_t _callback = nullptr); - SomeIPClient(SomeIPConfig _config, message_callback_t _callback = nullptr); - - virtual ~SomeIPClient(); - - const SomeIPConfig GetConfig() const; - - bool Run(); - void Shutdown(); - - int SendRequest(vsomeip::service_t service, vsomeip::instance_t instance, vsomeip::method_t method, - std::vector payload); - - -protected: - bool init(); - void start(); // blocking call, should be called from a thread - void stop(); - -protected: - SomeIPClient() = default; - SomeIPClient(const SomeIPClient&) = delete; - SomeIPClient& operator=(const SomeIPClient&) = delete; - - void on_state(vsomeip::state_type_e _state); - void on_message(const std::shared_ptr &_response); - void on_availability(vsomeip::service_t _service, vsomeip::instance_t _instance, bool _is_available); - - void init_event_service( - vsomeip::service_t service, - vsomeip::instance_t instance, - vsomeip::eventgroup_t event_group, - vsomeip::event_t event, - vsomeip::major_version_t service_major, - vsomeip::minor_version_t service_minor); - - protected: - std::shared_ptr app_; - std::string name_; - std::string log_prefix_; - message_callback_t callback_; - SomeIPConfig config_; - - std::atomic stop_requested_; - std::atomic initialized_; - std::mutex stop_mutex_; - - // TODO: use values from config_ - bool use_tcp_; - vsomeip_v3::service_t service_; - vsomeip_v3::major_version_t service_major_; - vsomeip_v3::minor_version_t service_minor_; - vsomeip_v3::instance_t instance_; - vsomeip_v3::eventgroup_t event_group_; - vsomeip_v3::event_t event_; - - // request service (single) - bool use_req_; - bool req_service_available; - std::mutex req_mutex_; - std::condition_variable req_condition_; - // SomeIPRequestConfig req_config_; - - vsomeip_v3::service_t req_service_; - vsomeip_v3::major_version_t req_service_major_; - vsomeip_v3::minor_version_t req_service_minor_; - vsomeip_v3::instance_t req_instance_; - vsomeip_v3::event_t req_method_; - - }; - - -/** - * @brief gets string name for vsomeip::message_type_e - * - * @param msg_type vsomeip::message_type_e value - * @return std::string description - */ -std::string message_type_to_string(vsomeip::message_type_e msg_type); - -/** - * @brief - * - * @param buf - * @param size - * @return std::string - */ -std::string hexdump(uint8_t *buf, size_t size); - -/** - * @brief Get an integer value from Environment variable - * - * @param envVar Environment variable name - * @param defaultValue if envVar was not set - * @return int result integer - */ -int getEnvironmentInt(const std::string &envVar, int defaultValue, bool dump=true); - -/** - * @brief Get std::string value from Environment variable - * - * @param envVar Environment variable name - * @param defaultValue if envVar was not set - * @return std::string result string - */ -std::string getEnvironmentStr(const std::string &envVar, const std::string &defaultValue, bool dump=true); - -} // namespace someip -} // namespace sdv - -#endif // VSOMEIP_WIPER_CLIENT_H diff --git a/someip2val/src/lib/wiper_poc/CMakeLists.txt b/someip2val/src/lib/wiper_poc/CMakeLists.txt deleted file mode 100644 index 4fc43348..00000000 --- a/someip2val/src/lib/wiper_poc/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ -#******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -#*******************************************************************************/ - -project(wiper_poc) - -cmake_minimum_required(VERSION 3.11) - -# Wiper POC -add_library(wiper_poc - EXCLUDE_FROM_ALL - STATIC - wiper_poc.cc -) - -target_include_directories(wiper_poc - PUBLIC - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} -) - -install(TARGETS wiper_poc - PRIVATE_HEADER - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} -) \ No newline at end of file diff --git a/someip2val/src/lib/wiper_poc/wiper-ids.h b/someip2val/src/lib/wiper_poc/wiper-ids.h deleted file mode 100644 index d92d3f37..00000000 --- a/someip2val/src/lib/wiper_poc/wiper-ids.h +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************** -* Copyright (c) 2022 Contributors to the Eclipse Foundation -* -* See the NOTICE file(s) distributed with this work for additional -* information regarding copyright ownership. -* -* This program and the accompanying materials are made available under the -* terms of the Apache License 2.0 which is available at -* http://www.apache.org/licenses/LICENSE-2.0 -* -* SPDX-License-Identifier: Apache-2.0 -********************************************************************************/ - -#ifndef SOMEIP_WIPER_IDS_H -#define SOMEIP_WIPER_IDS_H - -#include - -#define SAMPLE_SERVICE_ID 0x60d0 -#define SAMPLE_INSTANCE_ID 0x0001 -#define SAMPLE_METHOD_ID 0x8001 - -#define SAMPLE_METHOD_ID 0x8001 - -#define SAMPLE_EVENT_ID 0x8001 //0x8778 - -#define SAMPLE_EVENTGROUP_ID 0x0064 - -#define SAMPLE_SERVICE_MAJOR 0x01u -#define SAMPLE_SERVICE_MINOR 0x00u - - -/** - * @brief Example Wiper data structure - */ -typedef struct -{ - _Float32 ActualPosition; - _Float32 DriveCurrent; - vsomeip::byte_t TempGear; - vsomeip::byte_t isWiping; - vsomeip::byte_t isEndingWipeCycle; - vsomeip::byte_t isWiperError; - vsomeip::byte_t isPositionReached; - vsomeip::byte_t isBlocked; - vsomeip::byte_t isOverheated; - vsomeip::byte_t ECUTemp; - vsomeip::byte_t LINError; - vsomeip::byte_t isOverVoltage; - vsomeip::byte_t isUnderVoltage; -} t_EventData; - - -// wiper event structure -typedef struct -{ - vsomeip::byte_t sequenceCounter; - t_EventData data; -} t_Event; - -#endif // SOMEIP_WIPER_IDS_H diff --git a/someip2val/src/lib/wiper_poc/wiper_poc.cc b/someip2val/src/lib/wiper_poc/wiper_poc.cc deleted file mode 100644 index fb77608e..00000000 --- a/someip2val/src/lib/wiper_poc/wiper_poc.cc +++ /dev/null @@ -1,321 +0,0 @@ -/******************************************************************************** -* Copyright (c) 2022 Contributors to the Eclipse Foundation -* -* See the NOTICE file(s) distributed with this work for additional -* information regarding copyright ownership. -* -* This program and the accompanying materials are made available under the -* terms of the Apache License 2.0 which is available at -* http://www.apache.org/licenses/LICENSE-2.0 -* -* SPDX-License-Identifier: Apache-2.0 -********************************************************************************/ - -#include - -#include -#include -#include "wiper_poc.h" - -namespace sdv { -namespace someip { -namespace wiper { - - -void float_to_bytes(float val, uint8_t* data) { - // Create union of shared memory space - union { - float float_variable; - uint8_t temp_array[4]; - } u; - // Overite byte s of union with float variable - u.float_variable = val; - // Assign bytes to input array - memcpy(data, u.temp_array, 4); -} - -void bytes_to_float(const uint8_t* data, float* val) { - // Create union of shared memory space - union { - float float_variable; - uint8_t temp_array[4]; - } u; - - // Overite float of union with byte array - memcpy(u.temp_array, data, 4); - // copy union float to val - *val = u.float_variable; -} - -bool deserialize_event(const uint8_t *payload, size_t payload_size, t_Event& event) { - uint8_t tmp[4]; - - memset(&event, 0, sizeof(event)); - if (payload_size < WIPER_EVENT_PAYLOAD_SIZE) { - std::cerr << __func__ << " Payload size " << payload_size << " is too small!" << std::endl; - return false; - } - event.sequenceCounter = payload[0]; - - tmp[0] = payload[1]; - tmp[1] = payload[2]; - tmp[2] = payload[3]; - tmp[3] = payload[4]; - bytes_to_float(tmp, &event.data.ActualPosition); - - tmp[0] = payload[5]; - tmp[1] = payload[6]; - tmp[2] = payload[7]; - tmp[3] = payload[8]; - bytes_to_float(tmp, &event.data.DriveCurrent); - - event.data.TempGear = payload[9]; - event.data.isWiping = payload[10]; - event.data.isEndingWipeCycle = payload[11]; - event.data.isWiperError = payload[12]; - event.data.isPositionReached = payload[13]; - event.data.isBlocked = payload[14]; - event.data.isOverheated = payload[15]; - event.data.ECUTemp = payload[16]; - event.data.LINError = payload[17]; - event.data.isOverVoltage = payload[18]; - event.data.isUnderVoltage = payload[19]; - return true; -} -bool serialize_wiper_event(const t_Event& event, uint8_t *payload, size_t payload_size) { - if (payload_size < WIPER_EVENT_PAYLOAD_SIZE) { - std::cerr << __func__ << " Payload size " << payload_size << " is too small!" << std::endl; - return false; - } - // serialize t_Event as someip payload - memset(payload, 0, payload_size); - payload[0] = event.sequenceCounter; - sdv::someip::wiper::float_to_bytes(event.data.ActualPosition, &payload[1]); - sdv::someip::wiper::float_to_bytes(event.data.DriveCurrent, &payload[5]); - payload[9] = event.data.TempGear; - payload[10] = event.data.isWiping; - payload[11] = event.data.isEndingWipeCycle; - payload[12] = event.data.isWiperError; - payload[13] = event.data.isPositionReached; - payload[14] = event.data.isBlocked; - payload[15] = event.data.isOverheated; - payload[16] = event.data.ECUTemp; - payload[17] = event.data.LINError; - payload[18] = event.data.isOverVoltage; - payload[19] = event.data.isUnderVoltage; - return true; -} - -#if 0 -bool serialize_wiper_event(const t_Event& event, std::vector &serialized) { - // serialize t_Event as someip payload - uint8_t tmp[4]; - serialized.push_back(event.sequenceCounter); - - sdv::someip::wiper::float_to_bytes(event.data.ActualPosition, tmp); - for (int i=0; i -#include -#include -#include - -///////////////////////////// -// someip wiper service ids -///////////////////////////// - -#define WIPER_SERVICE_ID 0x60D0 -#define WIPER_INSTANCE_ID 0x0001 -#define WIPER_METHOD_ID 0x8001 -#define WIPER_EVENT_ID 0x8001 -#define WIPER_EVENTGROUP_ID 0x0064 -#define WIPER_SERVICE_MAJOR 0x01 -#define WIPER_SERVICE_MINOR 0x00 - -#define WIPER_VSS_SERVICE_ID 0x6123 -#define WIPER_VSS_INSTANCE_ID 0x000b -#define WIPER_VSS_METHOD_ID 0x0007 -#define WIPER_VSS_SERVICE_MAJOR 0x01 -#define WIPER_VSS_SERVICE_MINOR 0x00 - - -namespace sdv { -namespace someip { -namespace wiper { - -#define WIPER_EVENT_PAYLOAD_SIZE 20 -#define WIPER_SET_PAYLOAD_SIZE 6 - -typedef struct -{ - _Float32 ActualPosition; - _Float32 DriveCurrent; - uint8_t TempGear; - uint8_t isWiping; - uint8_t isEndingWipeCycle; - uint8_t isWiperError; - uint8_t isPositionReached; - uint8_t isBlocked; - uint8_t isOverheated; - uint8_t ECUTemp; - uint8_t LINError; - uint8_t isOverVoltage; - uint8_t isUnderVoltage; -} t_EventData; - - -/** - * @brief Payload structure for Wiper Events - */ -typedef struct -{ - uint8_t sequenceCounter; - t_EventData data; -} t_Event; - -typedef enum -{ - PLANT_MODE = 0, - STOP_HOLD = 1, - WIPE = 2, - EMERGENCY_STOP = 3 -} e_WiperMode; - -/** - * @brief Payload structure for Wiper Set service - */ -typedef struct -{ - uint8_t Frequency; - _Float32 TargetPosition; - e_WiperMode Mode; -} t_WiperRequest; - -void float_to_bytes(float val, uint8_t* data); -void bytes_to_float(const uint8_t* data, float* val); - -/*************************************/ -/** Wiper Event service **/ -/*************************************/ -std::string event_to_string(const t_Event &event); -std::string bytes_to_string(const uint8_t *payload, size_t payload_size); - -bool deserialize_event(const uint8_t *payload, size_t payload_size, t_Event& event); -bool serialize_wiper_event(const t_Event& event, uint8_t *payload, size_t payload_size); - -// print with new line -void print_status(const std::string &prefix, const t_Event &event); -// print on the same line -void print_status_r(const std::string &prefix, const t_Event &event); - -/*************************************/ -/** Wiper Request service helpers **/ -/*************************************/ - -bool serialize_vss_request(uint8_t *payload, size_t payload_size, const t_WiperRequest &request); -bool deserialize_vss_request(const uint8_t *payload, size_t payload_size, t_WiperRequest &request); -bool wiper_mode_parse(const std::string &str, e_WiperMode &mode); -std::string wiper_mode_to_string(e_WiperMode mode); -std::string vss_request_to_string(const t_WiperRequest &request); - - -} // namespace wiper -} // namespace someip -} // namespace sdv - - -#endif // VSOMEIP_WIPER_POC_H diff --git a/someip2val/src/someip_feeder/CMakeLists.txt b/someip2val/src/someip_feeder/CMakeLists.txt deleted file mode 100644 index 347e226c..00000000 --- a/someip2val/src/someip_feeder/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -#******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -#*******************************************************************************/ - -cmake_minimum_required (VERSION 3.11) - -# Project -project(SomeIp2ValFeeder CXX) - -# external dependencies -if (NOT vsomeip3_POPULATED) - find_package(vsomeip3) -endif() - -find_package(Threads REQUIRED) - -find_package(gRPC REQUIRED) -find_package(Protobuf REQUIRED) - -add_executable(someip_feeder - "someip_kuksa_adapter.cc" - "main.cc" -) - -target_link_libraries(someip_feeder -PRIVATE - data_broker_feeder - someip_client - wiper_poc - vsomeip3 -) - -install( - TARGETS someip_feeder - RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" -) - diff --git a/someip2val/src/someip_feeder/main.cc b/someip2val/src/someip_feeder/main.cc deleted file mode 100644 index 21d72af1..00000000 --- a/someip2val/src/someip_feeder/main.cc +++ /dev/null @@ -1,261 +0,0 @@ -/******************************************************************************** -* Copyright (c) 2022 Contributors to the Eclipse Foundation -* -* See the NOTICE file(s) distributed with this work for additional -* information regarding copyright ownership. -* -* This program and the accompanying materials are made available under the -* terms of the Apache License 2.0 which is available at -* http://www.apache.org/licenses/LICENSE-2.0 -* -* SPDX-License-Identifier: Apache-2.0 -********************************************************************************/ - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "someip_kuksa_adapter.h" - -#include "data_broker_feeder.h" -#include "someip_client.h" -#include "wiper_poc.h" - -#define SELF "[main] " - -using sdv::databroker::v1::Datapoint; -using sdv::databroker::v1::DataType; -using sdv::databroker::v1::ChangeType; -using sdv::databroker::v1::Datapoint_Failure; - -static sdv::adapter::SomeipFeederAdapter adapter; - -// Self pipe (for signal handling) -int pipefd[2]; - -void signal_handler(int signal) { - char sig = signal; - while (write(pipefd[1], &sig, sizeof(sig)) < 0) { - if (errno == EINTR) { - // If write was interupted by a signal, try again. - } else { - // Otherwise it doesn't make much sense to try again. - break; - } - } -} - -int setup_signal_handler() { - // Setup signal handler (using a self pipe) - if (pipe(pipefd) == -1) { - std::cout << SELF "Failed to setup signal handler (self pipe)" << std::endl; - std::exit(1); - } - - auto pipe_read_fd = pipefd[0]; - auto pipe_write_fd = pipefd[1]; - - // Set write end of pipe to non-blocking in order for it to work reliably in - // the signal handler. We _do_ want the read end to remain blocking so we - // can block while waiting for a signal. - int flags = fcntl(pipe_write_fd, F_GETFL) | O_NONBLOCK; - if (fcntl(pipe_write_fd, F_SETFL, flags) != 0) { - std::cout << SELF "Failed to set self pipe to non blocking" << std::endl; - std::exit(1); - } - std::signal(SIGINT, signal_handler); - std::signal(SIGTERM, signal_handler); - - return pipe_read_fd; // return read end of pipe -} - -// Blocks until signal is received -void wait_for_signal(int fd) { - char buf; - auto res = read(fd, &buf, sizeof(buf)); - if (res < 0) { - perror(SELF"[wait_for_signal] read() error"); - } else if (res == 1) { - std::cerr << SELF "[wait_for_signal] Received signal: " << std::dec << (int) buf << std::endl; - } else { - std::cerr << SELF "[wait_for_signal] unexpected EOF" << std::endl; - } -} - -void AdapterRun() { - // Setup signal handler & wait for signal - auto fd = setup_signal_handler(); - - // std::atexit(atExitHandler); - - // Runs both databroker feeder and someip threads - adapter.Start(); - - std::cout << std::endl << SELF "Running adapter... (Press Ctrl+C to stop.)" << std::endl << std::endl; - wait_for_signal(fd); - - std::cerr << "\n" << SELF "Shutting down from signal handler..\n" << std::endl; - adapter.Shutdown(); - - // Optional: Delete all global objects allocated by libprotobuf. - google::protobuf::ShutdownProtobufLibrary(); -} - -bool get_file_size(std::string fname, size_t& fsize) { - struct stat statbuf; - if (::stat(fname.c_str(), &statbuf) == -1) { - perror("[get_file_size] Error accessing"); - fsize = 0; - return false; - } - fsize = statbuf.st_size; - return true; -} - - - -std::string read_file(std::string fname) { - // FIXME: Check for maximum file size before allocating memory! - std::fstream fs(fname); - std::stringstream ss; - ss << fs.rdbuf(); - return ss.str(); -} - -void print_help(const char* application) { - std::cout - << "Usage: " << application << " \n" - << "\nOPTIONS:\n" - << " --target=: Databroker address. [Default: localhost:55555].'\n" - << " --someip-cfg Specify vsomeip json configuration file.\n" - << " --someip-app Specify vsomeip Application name.\n" - << " --dummy-feeder Feed some dummy data to Databroker and exit.\n" - << " --token Use token from specified file to authorize with Databroker.\n" - << " --help This message.\n" - << "\n\nEnvironment variables (if not set by command line arguments):\n" - << " BROKER_ADDR Override Databroker address (host:port)\n" - << " BROKER_TOKEN_FILE Use token from specified file to authorize with Databroker.\n" - << " BROKER_TOKEN Use value as token to authorize with Databroker.\n" - << " VSOMEIP_CONFIGURATION Specify vsomeip json configuration file.\n" - << " VSOMEIP_APPLICATION_NAME Specify vsomeip application name.\n" - << " SOMEIP_CLI_DEBUG SOME/IP Client debug level [0=OFF, 1=INFO, 2=DEBUG, 3=TRACE]\n" - << " DBF_DEBUG Databroker Feeder debug levels [0=OFF, 1=INFO, 2=DEBUG, 3=TRACE]\n" - << " KUKSA_DEBUG Kuksa/GRPC debug levels [0=OFF, 1=INFO, 2=DEBUG, 3=TRACE]\n" - << " WIPER_STATUS 0=disable printing of Wiper event status lines, 1=normal printing (default), 2=same line printing.\n" - << std::endl; -} - -/** - * @brief main Instantiate the feeder. It requires a channel, out of which the actual RPCs - * are created. This channel models a connection to an endpoint specified by - * the argument "--target=". - * We indicate that the channel isn't authenticated (use of InsecureChannelCredentials()). - */ -int main(int argc, char** argv) { - - std::string target_str = sdv::someip::getEnvironmentStr("BROKER_ADDR", "localhost:55555"); - std::string token_file_str = sdv::someip::getEnvironmentStr("BROKER_TOKEN_FILE", {}); - std::string token_str; - std::string someip_config; - std::string someip_app; - bool use_dummy_feeder = false; - - std::string arg_target("--target"); - std::string arg_someip_cfg("--someip-cfg"); - std::string arg_someip_app("--someip-app"); - std::string arg_dummy_feeder("--dummy-feeder"); - std::string arg_token("--token"); - std::string arg_help("--help"); - - std::cout << "WARNING: SOMEIP Provider has migrated to a new repository" << std::endl; - std::cout << "INFO: Consider using SOMEIP provider in https://github.com/eclipse-kuksa/kuksa-someip-provider instead" << std::endl; - - // FIXME: update someip settings from command line! - for (int i = 1; i < argc; i++) { - std::string arg_val = argv[i]; - if (arg_help == arg_val) { - print_help(argv[0]); - exit(0); - } else if (arg_someip_cfg == arg_val && i < argc - 1) { - someip_config = argv[++i]; - continue; - } else if (arg_someip_app == arg_val && i < argc - 1) { - someip_app = argv[++i]; - continue; - } else if (arg_token == arg_val && i < argc - 1) { - token_file_str = argv[++i]; - continue; - } else { - size_t start_pos = arg_val.find(arg_target); - if (start_pos != std::string::npos) { - start_pos += arg_target.size(); - if (arg_val[start_pos] == '=') { - target_str = arg_val.substr(start_pos + 1); - continue; - } else { - std::cout << "Target argument syntax is --target=:" << std::endl; - exit(1); - } - } - // fallback for unknown arg / missing option - std::cerr << "Invalid argument: " << arg_val << std::endl; - print_help(argv[0]); - exit(1); - } - } - - if (!token_file_str.empty()) { - // sanity check for token filesize - size_t token_size; - if (!get_file_size(token_file_str, token_size)) { - std::cerr << "Can't read token from: " << token_file_str << std::endl; - exit(1); - } - std::cout << "# Reading token from " << token_file_str << ", size:" << token_size << std::endl; - if (token_size == 0 || token_size > 16000) { - std::cerr << "Invliad token file size!" << std::endl; - exit(1); - } - token_str = read_file(token_file_str); - } - - if (vsomeip::DEFAULT_MAJOR != 0) { - std::cout << "# Warning: compiled with vsomeip::DEFAULT_MAJOR=" << std::dec << (int)vsomeip::DEFAULT_MAJOR << std::endl; - } - - // create generic SomeIPClient settings using SOMEIP_CLI_* environment variables (dumps used env vars!) - sdv::someip::SomeIPConfig config = sdv::someip::SomeIPClient::createEnvConfig(); - // override config with cmdline args - if (!someip_config.empty()) { - config.app_config = someip_config.c_str(); - ::setenv("VSOMEIP_CONFIGURATION", someip_config.c_str(), true); - } - if (!someip_app.empty()) { - config.app_name = someip_app.c_str(); - ::setenv("VSOMEIP_APPLICATION_NAME", someip_app.c_str(), true); - } - - - - // Initialize Databroker Feeder - adapter.InitDataBrokerFeeder(target_str, token_str); - - // Crete Some/IP client instance, chek required env. variables and fallback to dummy feeder on problems - if (!adapter.InitSomeipClient(config)) { - std::cout << "SOME/IP not available. feeding some dummy data..." << std::endl; - use_dummy_feeder = true; - } - if (use_dummy_feeder) { - // no sighandler for dummy feeder... - adapter.FeedDummyData(); - } else { - AdapterRun(); - } - return 0; -} diff --git a/someip2val/src/someip_feeder/someip_kuksa_adapter.cc b/someip2val/src/someip_feeder/someip_kuksa_adapter.cc deleted file mode 100644 index 808fa654..00000000 --- a/someip2val/src/someip_feeder/someip_kuksa_adapter.cc +++ /dev/null @@ -1,501 +0,0 @@ -/******************************************************************************** -* Copyright (c) 2022 Contributors to the Eclipse Foundation -* -* See the NOTICE file(s) distributed with this work for additional -* information regarding copyright ownership. -* -* This program and the accompanying materials are made available under the -* terms of the Apache License 2.0 which is available at -* http://www.apache.org/licenses/LICENSE-2.0 -* -* SPDX-License-Identifier: Apache-2.0 -********************************************************************************/ - -#include -#include -#include -#include -#include -#include // access() - -#include "someip_kuksa_adapter.h" -#include "data_broker_feeder.h" -#include "create_datapoint.h" - -#include "someip_client.h" -#include "wiper_poc.h" - -using sdv::databroker::v1::Datapoint; -using sdv::databroker::v1::DataType; -using sdv::databroker::v1::ChangeType; -using sdv::databroker::v1::Datapoint_Failure; - - -namespace sdv { -namespace adapter { - -/*** LOG helpers */ -#define LEVEL_TRC 3 -#define LEVEL_DBG 2 -#define LEVEL_INF 1 -#define LEVEL_ERR 0 -#define MODULE_PREFIX "# SomeipFeederAdapter::" - -#define LOG_TRACE if (log_level_ >= LEVEL_TRC) std::cout << MODULE_PREFIX << __func__ << ": [trace] " -#define LOG_DEBUG if (log_level_ >= LEVEL_DBG) std::cout << MODULE_PREFIX << __func__ << ": [debug] " -#define LOG_INFO if (log_level_ >= LEVEL_INF) std::cout << MODULE_PREFIX << __func__ << ": [info] " -#define LOG_ERROR if (log_level_ >= LEVEL_ERR) std::cerr << MODULE_PREFIX << __func__ << ": [error] " - -// if WIPER_STATUS=0, disables printing of wiper status lines -static int print_status = sdv::someip::getEnvironmentInt("WIPER_STATUS", 1, false); - -/*** VSS Paths for WIPER */ -const std::string WIPER_MODE = WIPER_VSS_PATH + ".Mode"; -const std::string WIPER_FREQUENCY = WIPER_VSS_PATH + ".Frequency"; -const std::string WIPER_TARGET_POSITION = WIPER_VSS_PATH + ".TargetPosition"; -const std::string WIPER_DRIVE_CURRENT = WIPER_VSS_PATH + ".DriveCurrent"; -const std::string WIPER_ACTUAL_POSITION = WIPER_VSS_PATH + ".ActualPosition"; -const std::string WIPER_IS_WIPING = WIPER_VSS_PATH + ".IsWiping"; -const std::string WIPER_IS_ENDING_WIPE_CYCLE = WIPER_VSS_PATH + ".IsEndingWipeCycle"; -const std::string WIPER_IS_WIPER_ERROR = WIPER_VSS_PATH + ".IsWiperError"; -const std::string WIPER_IS_POSITION_REACHED = WIPER_VSS_PATH + ".IsPositionReached"; -const std::string WIPER_IS_BLOCKED = WIPER_VSS_PATH + ".IsBlocked"; -const std::string WIPER_IS_OVERHEATED = WIPER_VSS_PATH + ".IsOverheated"; - -std::array SUBSCRIBE_ACTUATORS = { - WIPER_MODE, - WIPER_FREQUENCY, - WIPER_TARGET_POSITION -}; - - -SomeipFeederAdapter::SomeipFeederAdapter(): - feeder_active_(false), - databroker_addr_(), - databroker_feeder_(nullptr), - feeder_thread_(nullptr), - subscriber_thread_(nullptr), - someip_active_(false), - someip_thread_(nullptr), - someip_client_(nullptr), - someip_use_tcp_(false), - shutdown_requested_(false) -{ - log_level_ = sdv::someip::getEnvironmentInt("SOMEIP_CLI_DEBUG", 1, false); -} - -SomeipFeederAdapter::~SomeipFeederAdapter() { - LOG_TRACE << "called." << std::endl; - Shutdown(); - LOG_TRACE << "done." << std::endl; -} - -bool SomeipFeederAdapter::InitDataBrokerFeeder(const std::string &databroker_addr, const std::string& auth_token) { - - sdv::broker_feeder::DatapointConfiguration metadata = { - {WIPER_MODE, - DataType::STRING, - ChangeType::ON_CHANGE, - sdv::broker_feeder::createNotAvailableValue(), - "Requested mode of wiper system. ['STOP_HOLD', 'WIPE', 'PLANT_MODE', 'EMERGENCY_STOP']" - }, - {WIPER_FREQUENCY, - DataType::UINT8, - ChangeType::ON_CHANGE, - sdv::broker_feeder::createNotAvailableValue(), - "Wiping frequency/speed, measured in cycles per minute." - }, - {WIPER_TARGET_POSITION, - DataType::FLOAT, - ChangeType::ON_CHANGE, - sdv::broker_feeder::createNotAvailableValue(), - "Requested position of main wiper blade for the wiper system relative to reference position." - }, - {WIPER_ACTUAL_POSITION, - DataType::FLOAT, - ChangeType::ON_CHANGE, - sdv::broker_feeder::createNotAvailableValue(), - "Actual position of main wiper blade for the wiper system relative to reference position." - }, - {WIPER_DRIVE_CURRENT, - DataType::FLOAT, - ChangeType::ON_CHANGE, - sdv::broker_feeder::createNotAvailableValue(), - "Actual current used by wiper drive." - }, - {WIPER_IS_WIPING, - DataType::BOOL, - ChangeType::ON_CHANGE, - sdv::broker_feeder::createNotAvailableValue(), - "True if wiper blades are moving." - }, - {WIPER_IS_ENDING_WIPE_CYCLE, - DataType::BOOL, - ChangeType::ON_CHANGE, - sdv::broker_feeder::createNotAvailableValue(), - "Indicates if current wipe movement is completed or near completion." - }, - {WIPER_IS_WIPER_ERROR, - DataType::BOOL, - ChangeType::ON_CHANGE, - sdv::broker_feeder::createNotAvailableValue(), - "Indicates system failure." - }, - {WIPER_IS_POSITION_REACHED, - DataType::BOOL, - ChangeType::ON_CHANGE, - sdv::broker_feeder::createNotAvailableValue(), - "Indicates if a requested position has been reached." - }, - {WIPER_IS_BLOCKED, - DataType::BOOL, - ChangeType::ON_CHANGE, - sdv::broker_feeder::createNotAvailableValue(), - "Indicates if wiper movement is blocked." - }, - {WIPER_IS_OVERHEATED, - DataType::BOOL, - ChangeType::ON_CHANGE, - sdv::broker_feeder::createNotAvailableValue(), - "Indicates if wiper system is overheated." - // NOTE: evaluate someip event: TempGear and ECUTemp - } - }; - - LOG_INFO << "Connecting to " << databroker_addr << std::endl; - - // debug: KUKSA_DEBUG - collector_client_ = sdv::broker_feeder::CollectorClient::createInstance(databroker_addr, auth_token); - // debug: DBF_DEBUG - databroker_feeder_ = sdv::broker_feeder::DataBrokerFeeder::createInstance(collector_client_, std::move(metadata)); - // debug: KUKSA_DEBUG - actuator_subscriber_ = sdv::broker_feeder::kuksa::ActuatorSubscriber::createInstance(collector_client_); - actuator_subscriber_->Init( - std::vector(SUBSCRIBE_ACTUATORS.begin(), SUBSCRIBE_ACTUATORS.end()), - std::bind(&SomeipFeederAdapter::on_actuator_change, this, std::placeholders::_1) - ); - - return true; -} - -bool SomeipFeederAdapter::InitSomeipClient(sdv::someip::SomeIPConfig _config) { - - someip_use_tcp_ = _config.use_tcp; - - auto someip_app = ::getenv("VSOMEIP_APPLICATION_NAME"); - auto someip_config = ::getenv("VSOMEIP_CONFIGURATION"); - - bool someip_ok = true; - if (!someip_app) { - LOG_ERROR << "VSOMEIP_APPLICATION_NAME not set in environment, someip disabled!" << std::endl; - someip_ok = false; - } - if (someip_config == nullptr) { - LOG_ERROR << "VSOMEIP_CONFIGURATION not set in environment, someip disabled!" << std::endl; - someip_ok = false; - } else { - if (::access(someip_config, F_OK) == -1) { - LOG_ERROR << "env VSOMEIP_CONFIGURATION file is missing: " << someip_config << std::endl; - someip_ok = false; - } - } - - if (someip_ok) { - std::stringstream ss; - ss << "\n" - << "### VSOMEIP_APPLICATION_NAME=" << someip_app << "\n" - << "### VSOMEIP_CONFIGURATION=" << someip_config << "\n" - << "$ cat " << someip_config << std::endl; - LOG_INFO << ss.str(); - - std::string cmd; - cmd = "cat " + std::string(someip_config); - int rc = ::system(cmd.c_str()); - std::cout << std::endl; - - someip_client_ = sdv::someip::SomeIPClient::createInstance( - _config, - std::bind(&SomeipFeederAdapter::on_someip_message, - this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5)); - } - someip_active_ = someip_ok; - return someip_ok; -} - -void SomeipFeederAdapter::on_actuator_change(sdv::broker_feeder::kuksa::ActuatorValues target_values) { - LOG_INFO << "updated target_values: " << target_values.size() << std::endl; - if (log_level_ >= LEVEL_DBG) { - std::stringstream ss; - ss << "{\n"; - for (auto a: target_values) { - ss << " - " << a.first << ": " - << a.second.ShortDebugString() << "\n"; - } - ss << "}"; - LOG_DEBUG << ss.str() << std::endl; - } - - if (target_values.find(WIPER_MODE) == target_values.end() || - target_values.find(WIPER_FREQUENCY) == target_values.end() || - target_values.find(WIPER_TARGET_POSITION) == target_values.end()) { - LOG_ERROR << "Required target values are missing!" << std::endl; - return; - } - - auto wiper_mode = target_values.at(WIPER_MODE); - - // TODO: handle ValueCase.VALUE_NOT_SET withot errors - - if (wiper_mode.value_case() != ::kuksa::val::v1::Datapoint::ValueCase::kString) { - LOG_ERROR << "wrong value type [" - << wiper_mode.value_case() - << "] for " << WIPER_MODE << std::endl; - return; - } - auto wiper_freq = target_values.at(WIPER_FREQUENCY); - if (wiper_freq.value_case() != ::kuksa::val::v1::Datapoint::ValueCase::kUint32) { - LOG_ERROR << "wrong value type [" - << wiper_freq.value_case() - << "] for " << WIPER_FREQUENCY << std::endl; - return; - } - - auto wiper_target_position = target_values.at(WIPER_TARGET_POSITION); - if (wiper_target_position.value_case() != ::kuksa::val::v1::Datapoint::ValueCase::kFloat) { - LOG_ERROR << "wrong value type [" - << wiper_target_position.value_case() - << "] for " << WIPER_TARGET_POSITION << std::endl; - return; - } - - auto wiper_mode_value = wiper_mode.string(); - auto wiper_freq_value = wiper_freq.uint32(); - auto wiper_target_position_value = wiper_target_position.float_(); - LOG_DEBUG << "wiper_mode_value: " << wiper_mode_value << std::endl; - LOG_DEBUG << "wiper_freq_value: " << std::dec << (int)wiper_freq_value << std::endl; - LOG_DEBUG << "wiper_target_position: " << wiper_target_position_value << std::endl; - - sdv::someip::wiper::e_WiperMode mode; - if (!sdv::someip::wiper::wiper_mode_parse(wiper_mode_value, mode)) { - LOG_ERROR << "Invalid WiperMode value: " << wiper_mode_value << std::endl; - return; - } - sdv::someip::wiper::t_WiperRequest req = { (uint8_t)wiper_freq_value, wiper_target_position_value, mode }; - uint8_t vss_payload[WIPER_SET_PAYLOAD_SIZE]; - if (!sdv::someip::wiper::serialize_vss_request(vss_payload, sizeof(vss_payload), req)) { - LOG_ERROR << "Failed to serialize WiperRequest: " - << sdv::someip::wiper::vss_request_to_string(req) << std::endl; - return; - } - - // Send SOME/IP request - if (someip_client_) { - std::vector payload; - payload.insert(payload.end(), &vss_payload[0], &vss_payload[sizeof(vss_payload)]); - LOG_INFO << "Sending " << sdv::someip::wiper::vss_request_to_string(req) << std::endl; - someip_client_->SendRequest( - WIPER_VSS_SERVICE_ID, - WIPER_VSS_INSTANCE_ID, - WIPER_VSS_METHOD_ID, - payload); - } - -} - -void SomeipFeederAdapter::Start() { - LOG_INFO << "Starting adapter..." << std::endl; - if (databroker_feeder_) { - // start databropker feeder thread - feeder_thread_ = std::make_shared (&sdv::broker_feeder::DataBrokerFeeder::Run, databroker_feeder_); - int rc = pthread_setname_np(feeder_thread_->native_handle(), "broker_feeder"); - if (rc != 0) { - LOG_ERROR << "Failed setting datafeeder thread name:" << rc << std::endl; - } - } - if (actuator_subscriber_) { - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - // start target actuator subscription - subscriber_thread_ = std::make_shared ( - &sdv::broker_feeder::kuksa::ActuatorSubscriber::Run, actuator_subscriber_); - int rc = pthread_setname_np(subscriber_thread_->native_handle(), "target_subscr"); - if (rc != 0) { - LOG_ERROR << "Failed setting someip thread name:" << rc << std::endl; - } - } - if (someip_active_ && someip_client_) { - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - // start vsomeip app "main" thread - someip_thread_ = std::make_shared (&sdv::someip::SomeIPClient::Run, someip_client_); - int rc = pthread_setname_np(someip_thread_->native_handle(), "someip_main"); - if (rc != 0) { - LOG_ERROR << "Failed setting someip thread name:" << rc << std::endl; - } - } - feeder_active_ = true; -} - -void SomeipFeederAdapter::Shutdown() { - std::lock_guard its_lock(shutdown_mutex_); - LOG_DEBUG << "feeder_active_=" << feeder_active_ - << ", shutdown_requested_=" << shutdown_requested_<< std::endl; - if (shutdown_requested_) { - return; - } - shutdown_requested_ = true; - feeder_active_ = false; - - if (subscriber_thread_ && actuator_subscriber_) { - LOG_INFO << "Stopping actuator subscriber..." << std::endl; - actuator_subscriber_->Shutdown(); - } - if (feeder_thread_ && databroker_feeder_) { - LOG_INFO << "Stopping databroker feeder..." << std::endl; - databroker_feeder_->Shutdown(); - } - if (someip_client_) { - LOG_INFO << "Stopping someip client..." << std::endl; - someip_client_->Shutdown(); - if (someip_thread_ && someip_thread_->joinable()) { - if (someip_thread_->get_id() != std::this_thread::get_id()) { - LOG_TRACE << "Joining someip thread..." << std::endl; - someip_thread_->join(); - LOG_TRACE << "someip thread joined." << std::endl; - } else { - LOG_ERROR << "WARNING! Skipped joining someip from the same thread..." << std::endl; - someip_thread_->detach(); - } - } - } - // join feeder after stopping someip - if (feeder_thread_ && feeder_thread_->joinable()) { - LOG_TRACE << "Joining datafeeder thread..." << std::endl; - feeder_thread_->join(); - LOG_TRACE << "datafeeder thread joined." << std::endl; - } - - if (subscriber_thread_ && subscriber_thread_->joinable()) { - LOG_TRACE << "Joining subscriber thread..." << std::endl; - subscriber_thread_->join(); - LOG_TRACE << "subscriber thread joined." << std::endl; - } - LOG_TRACE << "done." << std::endl; -} - -void SomeipFeederAdapter::FeedDummyData() { - auto vss = WIPER_VSS_PATH + ".ActualPosition"; - auto vss_target = WIPER_VSS_PATH + ".ActualPosition"; - float target_pos = 110; - - if (!databroker_feeder_) { - return; - } - LOG_INFO << "Starting dummy feeder" << std::endl; - for (float pos=0.0; feeder_active_ && posset_seconds(tv.tv_sec); - ts->set_nanos(tv.tv_nsec); - } - } - databroker_feeder_->FeedValue(vss, datapoint); - } - { // feed TargetPosition - LOG_INFO << "Feed Value " << target_pos << " to '" << vss_target << "'" << std::endl; - sdv::databroker::v1::Datapoint datapoint; - datapoint.set_float_value(target_pos); - databroker_feeder_->FeedValue(vss_target, datapoint); - } - - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - } -} - -int SomeipFeederAdapter::on_someip_message( - vsomeip::service_t service_id, vsomeip::instance_t instance_id, vsomeip::method_t method_id, - const uint8_t *payload, size_t payload_length) -{ - // TODO: Handle VSS Set response result from payload - if (service_id == WIPER_VSS_SERVICE_ID && - instance_id == WIPER_VSS_INSTANCE_ID && - method_id == WIPER_VSS_METHOD_ID) - { - if (log_level_ >= LEVEL_INF) { - std::stringstream ss; - ss << "Received Response from [" - << std::setw(4) << std::setfill('0') << std::hex - << service_id << "." - << std::setw(4) << std::setfill('0') << std::hex - << instance_id << "." - << std::setw(4) << std::setfill('0') << std::hex - << method_id << "], payload [" - << sdv::someip::hexdump((uint8_t*)payload, payload_length) << "]"; - LOG_INFO << ss.str() << std::endl; - } - return 0; - } - // ignore incoming non-wiper events - if (service_id != WIPER_SERVICE_ID || - instance_id != WIPER_INSTANCE_ID || - method_id != WIPER_EVENT_ID) - { - - LOG_ERROR << "Ignored non-wiper event [" - << std::setw(4) << std::setfill('0') << std::hex - << service_id << "." - << std::setw(4) << std::setfill('0') << std::hex - << instance_id << "." - << std::setw(4) << std::setfill('0') << std::hex - << method_id << "]" << std::endl; - return -1; - } - - sdv::someip::wiper::t_Event event; - if (sdv::someip::wiper::deserialize_event(payload, payload_length, event)) { - // multiline dump - if (someip_client_->GetConfig().debug >= 2) { - LOG_DEBUG << "Received " - << sdv::someip::wiper::event_to_string(event) << std::endl; - } - // print_status == 0: no printing - if (print_status == 1) { - sdv::someip::wiper::print_status(std::string("### "), event); - } else if (print_status > 1) { - sdv::someip::wiper::print_status_r(std::string("### "), event); - } - - // feed values to kuksa databroker - sdv::broker_feeder::DatapointValues values = { - { WIPER_ACTUAL_POSITION, - sdv::broker_feeder::createDatapoint(event.data.ActualPosition) }, - { WIPER_DRIVE_CURRENT, - sdv::broker_feeder::createDatapoint(event.data.DriveCurrent) }, - { WIPER_IS_WIPING, - sdv::broker_feeder::createDatapoint((bool)event.data.isWiping) }, - { WIPER_IS_BLOCKED, - sdv::broker_feeder::createDatapoint((bool)event.data.isBlocked) }, - { WIPER_IS_ENDING_WIPE_CYCLE, - sdv::broker_feeder::createDatapoint((bool)event.data.isEndingWipeCycle) }, - { WIPER_IS_OVERHEATED, - sdv::broker_feeder::createDatapoint((bool)event.data.isOverheated) }, - { WIPER_IS_POSITION_REACHED, - sdv::broker_feeder::createDatapoint((bool)event.data.isPositionReached) }, - { WIPER_IS_WIPER_ERROR, - sdv::broker_feeder::createDatapoint((bool)event.data.isWiperError) } - }; - databroker_feeder_->FeedValues(values); - return 0; - } - LOG_ERROR << "Deserializaton failed!" << std::endl; - return -2; // deserialize failed -} - - -} // namespace adapter -} // namespace sdv diff --git a/someip2val/src/someip_feeder/someip_kuksa_adapter.h b/someip2val/src/someip_feeder/someip_kuksa_adapter.h deleted file mode 100644 index 7f276a9f..00000000 --- a/someip2val/src/someip_feeder/someip_kuksa_adapter.h +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************** -* Copyright (c) 2022 Contributors to the Eclipse Foundation -* -* See the NOTICE file(s) distributed with this work for additional -* information regarding copyright ownership. -* -* This program and the accompanying materials are made available under the -* terms of the Apache License 2.0 which is available at -* http://www.apache.org/licenses/LICENSE-2.0 -* -* SPDX-License-Identifier: Apache-2.0 -********************************************************************************/ - -#ifndef SOMEIP_KUKSA_ADAPTER_H -#define SOMEIP_KUKSA_ADAPTER_H - -#include -#include -#include - - -#include "someip_client.h" -#include "data_broker_feeder.h" -#include "actuator_subscriber.h" - -namespace sdv { -namespace adapter { - -/** - * @brief Base path for Wiper data in VSS 3.0 - */ -const std::string WIPER_VSS_PATH = "Vehicle.Body.Windshield.Front.Wiping.System"; - -class SomeipFeederAdapter { - -public: - SomeipFeederAdapter(); - virtual ~SomeipFeederAdapter(); - - bool InitDataBrokerFeeder(const std::string &databroker_addr, const std::string& auth_token); - bool InitSomeipClient(sdv::someip::SomeIPConfig _config); - - /** - * @brief Starts someip and databroker feeder threads - */ - void Start(); - - /** - * @brief Terminates someip and databroker feeder threads - */ - void Shutdown(); - - /** - * @brief Sends dummy data to databroker feeder (someip not used) - */ - void FeedDummyData(); - -protected: - int on_someip_message( - vsomeip::service_t service, - vsomeip::instance_t instance, - vsomeip::method_t event, - const uint8_t *payload, - size_t payload_length); - - void on_actuator_change(sdv::broker_feeder::kuksa::ActuatorValues datapoints); - -private: - std::atomic feeder_active_; - - std::string databroker_addr_; - std::shared_ptr collector_client_; - - // Feeder - std::shared_ptr databroker_feeder_; - std::shared_ptr feeder_thread_; - - // Actuator target subscriber - std::shared_ptr actuator_subscriber_; - std::shared_ptr subscriber_thread_; - - // SOME/IP client - bool someip_use_tcp_; - std::shared_ptr someip_client_; - std::shared_ptr someip_thread_; - std::atomic someip_active_; - - std::mutex shutdown_mutex_; - std::atomic shutdown_requested_; - int log_level_; -}; - -} // namespace adapter -} // namespace sdv - -#endif // SOMEIP_KUKSA_ADAPTER_H diff --git a/someip2val/toolchains/target_aarch64_Debug b/someip2val/toolchains/target_aarch64_Debug deleted file mode 100644 index 2858aa61..00000000 --- a/someip2val/toolchains/target_aarch64_Debug +++ /dev/null @@ -1,25 +0,0 @@ -toolchain=/usr/bin/aarch64-linux-gnu-aarch64-linux-gnu -target_host=aarch64-linux-gnu -cc_compiler=gcc -cxx_compiler=g++ - -[settings] -os=Linux -compiler=gcc -compiler.version=9 -compiler.libcxx=libstdc++11 - -arch=armv8 -build_type=Debug - -[env] -CONAN_CMAKE_FIND_ROOT_PATH=$toolchain # Optional, for CMake to find things in that folder -CONAN_CMAKE_SYSROOT=$toolchain # Optional, if we want to define sysroot -CHOST=$target_host -AR=$target_host-ar -AS=$target_host-as -RANLIB=$target_host-ranlib -CC=$target_host-$cc_compiler -CXX=$target_host-$cxx_compiler -STRIP=$target_host-strip -RC=$target_host-windres diff --git a/someip2val/toolchains/target_aarch64_Release b/someip2val/toolchains/target_aarch64_Release deleted file mode 100644 index 3273f91b..00000000 --- a/someip2val/toolchains/target_aarch64_Release +++ /dev/null @@ -1,25 +0,0 @@ -toolchain=/usr/bin/aarch64-linux-gnu-aarch64-linux-gnu -target_host=aarch64-linux-gnu -cc_compiler=gcc -cxx_compiler=g++ - -[settings] -os=Linux -compiler=gcc -compiler.version=9 -compiler.libcxx=libstdc++11 - -arch=armv8 -build_type=Release - -[env] -CONAN_CMAKE_FIND_ROOT_PATH=$toolchain # Optional, for CMake to find things in that folder -CONAN_CMAKE_SYSROOT=$toolchain # Optional, if we want to define sysroot -CHOST=$target_host -AR=$target_host-ar -AS=$target_host-as -RANLIB=$target_host-ranlib -CC=$target_host-$cc_compiler -CXX=$target_host-$cxx_compiler -STRIP=$target_host-strip -RC=$target_host-windres diff --git a/someip2val/toolchains/target_rpi_Debug b/someip2val/toolchains/target_rpi_Debug deleted file mode 100644 index 90ecce09..00000000 --- a/someip2val/toolchains/target_rpi_Debug +++ /dev/null @@ -1,9 +0,0 @@ -[settings] -os=Linux -compiler=gcc -compiler.version=8 -compiler.libcxx=libstdc++11 - -arch=armv8 -build_type=Debug - diff --git a/someip2val/toolchains/target_rpi_Release b/someip2val/toolchains/target_rpi_Release deleted file mode 100644 index 941553bf..00000000 --- a/someip2val/toolchains/target_rpi_Release +++ /dev/null @@ -1,9 +0,0 @@ -[settings] -os=Linux -compiler=gcc -compiler.version=8 -compiler.libcxx=libstdc++11 - -arch=armv8 -build_type=Release - diff --git a/someip2val/toolchains/target_x86_64_Debug b/someip2val/toolchains/target_x86_64_Debug deleted file mode 100644 index 7e9797a6..00000000 --- a/someip2val/toolchains/target_x86_64_Debug +++ /dev/null @@ -1,9 +0,0 @@ -[settings] -os=Linux -compiler=gcc -compiler.version=9 -compiler.libcxx=libstdc++11 - -arch=x86_64 -build_type=Debug - diff --git a/someip2val/toolchains/target_x86_64_Release b/someip2val/toolchains/target_x86_64_Release deleted file mode 100644 index d3a214bc..00000000 --- a/someip2val/toolchains/target_x86_64_Release +++ /dev/null @@ -1,9 +0,0 @@ -[settings] -os=Linux -compiler=gcc -compiler.version=9 -compiler.libcxx=libstdc++11 - -arch=x86_64 -build_type=Release - diff --git a/someip2val/vscode-conan.sh b/someip2val/vscode-conan.sh deleted file mode 100755 index 3b059c19..00000000 --- a/someip2val/vscode-conan.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash - -#******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License 2.0 which is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -#*******************************************************************************/ -# shellcheck disable=SC1090 -# shellcheck disable=SC1091 -# shellcheck disable=SC2181 - -# Script for vs code with initialized conan environment (debug) -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - -if [ "$1" = "-h" ] || [ "$1" == "--help" ]; then - echo "Usage: $0 {-h} {project_dir} {cmake_build_dir}" - echo - echo "Description:" - echo " Launcher script for vs.code with pre-initialized conan environment to work with cmake in vs.code" - echo - echo "Arguments:" - echo " project_dir vs.code project directory (default: ..)" - echo " cmake_build_dir vs.code cmake directory (default: ./build)" - echo - exit 0 -fi - -PROJ_DIR="$1" -[ -z "$PROJ_DIR" ] && PROJ_DIR="$SCRIPT_DIR" - -BUILD_DIR="$2" -[ -z "$BUILD_DIR" ] && BUILD_DIR="$PROJ_DIR/build" - -# conan setup -export CONAN_REVISIONS_ENABLED=1 -echo "########## Conan Info #########" -conan --version -conan info . -echo "###############################" - -conan install -if="$BUILD_DIR" --build=missing --profile:build=default --profile:host="$SCRIPT_DIR/toolchains/target_x86_64_Debug" "$SCRIPT_DIR" -[ $? -ne 0 ] && echo "conan install failed!" && exit 1 - -if [ -f "$BUILD_DIR/activate.sh" ]; then - source "$BUILD_DIR/activate.sh" - echo - echo "Executing: code $PROJ_DIR with cmake/conan environment..." - echo - code "$PROJ_DIR" -else - echo "Can't find $BUILD_DIR/activate.sh !" - exit 1 -fi