-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup-someip2val-proxy.sh
executable file
·90 lines (76 loc) · 3.31 KB
/
setup-someip2val-proxy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/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