[vsomeip] How to make vsomeip run on dual systems—-(1)

Article directory

  • Preface
  • 1. Verify that vsomeip comes with the helloworld routine
    • 1. First run the server APP
    • 2. Run the client APP again
  • 2. Create helloworld Service and client configuration files
    • 1. Modify the code
    • 2. Run the test APP
  • Summarize

Foreword

Verify that vsomeip can communicate between Host Linux and Guest Linux in LXC.

  1. Verify that vsomeip comes with helloworld routine
  2. Create helloworld Service and client configuration files
  3. Verify vsomeip communication in dual-machine situation
  4. Verify vsomeip communication between LXC internal and external systems

1. Verify that vsomeip comes with helloworld routine

{<!-- -->
    "unicast":"127.0.0.1",
    "logging":
    {<!-- -->
        "level":"debug",
        "console":"true"
    },

    "applications":
    [
        {<!-- -->
            "name":"hello_world_service",
            "id":"0x4444"
        },

        {<!-- -->
            "name":"hello_world_client",
            "id":"0x5555"
        }
    ],

    "services":
    [
        {<!-- -->
            "service":"0x1111",
            "instance":"0x2222",
            "unreliable":"30509"
        }
    ],

    "routing":"hello_world_service",
    "service-discovery":
    {<!-- -->
        "enable":"false"
    }
}

The unicast address needs to be changed to 127.0.0.1, which means it is running inside the machine.

will@will-OptiPlex-7050:~/work/vsomeip/examples/hello_world/build$ VSOMEIP_CONFIGURATION=../helloworld-local.json \
> VSOMEIP_APPLICATION_NAME=hello_world_client \
> ./hello_world_client
1 Configuration module could not be loaded!


Error fix:
will@will-OptiPlex-7050:~/work/vsomeip/examples/hello_world/build$ sudo ldconfig

According to the instructions in the readme, directly copy the execution command to run. What needs to be explained is that
1. The configuration of vsomeip requires importing your own JSON file, otherwise the default configuration that comes with the system will be used;
2. During the first execution, you will encounter the problem that the configuration module cannot be loaded. This can be solved by executing sudo ldconfig.

1. Run the server APP first

Run vsompip server side first:
will@will-OptiPlex-7050:~/work/vsomeip/examples/hello_world/build$ VSOMEIP_CONFIGURATION=../helloworld-local.json \
> VSOMEIP_APPLICATION_NAME=hello_world_service \
> ./hello_world_service

The log will be printed as follows

2023-11-01 11:11:42.288696 [info] Using configuration file: "../helloworld-local.json".
2023-11-01 11:11:42.289278 [info] Parsed vsomeip configuration in 0ms
2023-11-01 11:11:42.289336 [info] Configuration module loaded.
2023-11-01 11:11:42.289392 [info] Security disabled!
2023-11-01 11:11:42.289424 [info] Initializing vsomeip (3.4.9.1) application "hello_world_service".
2023-11-01 11:11:42.289804 [info] Instantiating routing manager [Host].
2023-11-01 11:11:42.290299 [info] create_routing_root: Routing root @ /tmp/vsomeip-0
2023-11-01 11:11:42.290997 [info] Application(hello_world_service, 4444) is initialized (11, 100).
2023-11-01 11:11:42.291277 [info] Starting vsomeip application "hello_world_service" (4444) using 2 threads I/O nice 255
2023-11-01 11:11:42.291740 [info] Client [4444] routes unicast:134.86.56.94, netmask:255.255.255.0
2023-11-01 11:11:42.291761 [info] shutdown thread id from application: 4444 (hello_world_service) is: 7f2b3b98d700 TID: 19691
2023-11-01 11:11:42.291696 [info] main dispatch thread id from application: 4444 (hello_world_service) is: 7f2b3c18e700 TID: 19690
2023-11-01 11:11:42.293976 [info] Watchdog is disabled!
2023-11-01 11:11:42.294551 [info] io thread id from application: 4444 (hello_world_service) is: 7f2b3d234ec0 TID: 19687
2023-11-01 11:11:42.294549 [info] io thread id from application: 4444 (hello_world_service) is: 7f2b3a98b700 TID: 19693
2023-11-01 11:11:42.295082 [info] vSomeIP 3.4.9.1 | (default)
2023-11-01 11:11:42.295539 [info] create_local_server: Listening @ /tmp/vsomeip-4444
2023-11-01 11:11:42.295753 [info] OFFER(4444): [1111.2222:0.0] (true)
2023-11-01 11:11:52.297733 [info] vSomeIP 3.4.9.1 | (default)
2023-11-01 11:11:54.804669 [info] Application/Client 5555 is registering.
2023-11-01 11:11:54.805463 [info] Client [4444] is connecting to [5555] at /tmp/vsomeip-5555
2023-11-01 11:11:54.806854 [info] REGISTERED_ACK(5555)
2023-11-01 11:11:54.909201 [info] REQUEST(5555): [1111.2222:255.4294967295]
2023-11-01 11:11:54.924016 [info] RELEASE(5555): [1111.2222]
2023-11-01 11:11:54.925872 [info] Application/Client 5555 is deregistering.
2023-11-01 11:11:54.937450 [info] local_uds_client_endpoint_impl::receive_cbk Error: End of file
2023-11-01 11:11:54.029515 [info] Client [4444] is closing connection to [5555]
2023-11-01 11:11:59.923047 [info] STOP OFFER(4444): [1111.2222:0.0] (true)
2023-11-01 11:11:59.924874 [info] Stopping vsomeip application "hello_world_service" (4444).

2. Run the client APP again

Run vsompip client side:
will@will-OptiPlex-7050:~/work/vsomeip/examples/hello_world/build$ VSOMEIP_CONFIGURATION=../helloworld-local.json VSOMEIP_APPLICATION_NAME=hello_world_client ./hello_world_client

The corresponding log is as follows

2023-11-01 15:53:15.523921 [info] Using configuration file: "../helloworld-local.json".
2023-11-01 15:53:15.524468 [info] Parsed vsomeip configuration in 0ms
2023-11-01 15:53:15.524524 [info] Configuration module loaded.
2023-11-01 15:53:15.524576 [info] Security disabled!
2023-11-01 15:53:15.524608 [info] Initializing vsomeip (3.4.9.1) application "hello_world_client".
2023-11-01 15:53:15.524642 [info] Instantiating routing manager [Proxy].
2023-11-01 15:53:15.524799 [info] Client [5555] is connecting to [0] at /tmp/vsomeip-0
2023-11-01 15:53:15.524844 [info] Application(hello_world_client, 5555) is initialized (11, 100).
2023-11-01 15:53:15.524954 [info] Starting vsomeip application "hello_world_client" (5555) using 2 threads I/O nice 255
2023-11-01 15:53:15.526023 [info] main dispatch thread id from application: 5555 (hello_world_client) is: 7fb002dab700 TID: 23920
2023-11-01 15:53:15.526727 [info] io thread id from application: 5555 (hello_world_client) is: 7fb002e50000 TID: 23919
2023-11-01 15:53:15.526179 [info] shutdown thread id from application: 5555 (hello_world_client) is: 7fb0025aa700 TID: 23921
2023-11-01 15:53:15.526751 [info] io thread id from application: 5555 (hello_world_client) is: 7faffbfff700 TID: 23922
2023-11-01 15:53:15.528288 [info] create_local_server: Listening @ /tmp/vsomeip-5555
2023-11-01 15:53:15.528654 [info] Client 5555 (hello_world_client) successfully connected to routing ~> registering..
2023-11-01 15:53:15.528712 [info] Registering to routing manager @ vsomeip-0
2023-11-01 15:53:15.530923 [info] Application/Client 5555 (hello_world_client) is registered.
2023-11-01 15:53:15.634773 [info] ON_AVAILABLE(5555): [1111.2222:0.0]
Sending: World
2023-11-01 15:53:15.635725 [info] Client [5555] is connecting to [4444] at /tmp/vsomeip-4444
Received: Hello World
2023-11-01 15:53:15.639340 [info] Stopping vsomeip application "hello_world_client" (5555).
2023-11-01 15:53:15.641279 [info] Application/Client 5555 (hello_world_client) is deregistered.
2023-11-01 15:53:15.641723 [info] local_uds_client_endpoint_impl::receive_cbk Error: Operation canceled
2023-11-01 15:53:15.641806 [info] Client [5555] is closing connection to [4444]
2023-11-01 15:53:15.641830 [info] local_uds_client_endpoint_impl::receive_cbk Error: Operation canceled

There are some errors in the log backend, “local_uds_client_endpoint_impl::receive_cbk Error: Operation canceled”. After searching for a long time, I still can’t find the reason, but it should not affect the verification of vsomeip.

2. Create helloworld Service and client configuration files

1. Modify code

  1. hello_world_service.hpp
bool init(){<!-- -->
        
        setenv("VSOMEIP_CONFIGURATION", "../helloworld-service.json", 1);
        setenv("VSOMEIP_APPLICATION_NAME", "hello_world_service", 1);
  1. hello_world_client.hpp
bool init(){<!-- -->
        
        setenv("VSOMEIP_CONFIGURATION", "../helloworld-client.json", 1);
        setenv("VSOMEIP_APPLICATION_NAME", "hello_world_client", 1);

2. Run the test APP

4. Rebuild vsomeip source code and the run service side in advanced
will@will-OptiPlex-7050:~/work/vsomeip/examples/hello_world/build$ make clean
will@will-OptiPlex-7050:~/work/vsomeip/examples/hello_world/build$ make
Scanning dependencies of target hello_world_client
[25%] Building CXX object CMakeFiles/hello_world_client.dir/hello_world_client_main.cpp.o
[50%] Linking CXX executable hello_world_client
[50%] Built target hello_world_client
Scanning dependencies of target hello_world_service
[75%] Building CXX object CMakeFiles/hello_world_service.dir/hello_world_service_main.cpp.o
[100%] Linking CXX executable hello_world_service
[100%] Built target hello_world_service
will@will-OptiPlex-7050:~/work/vsomeip/examples/hello_world/build$ ./hello_world_service
5. Run client side app.
will@will-OptiPlex-7050:~/work/vsomeip/examples/hello_world/build$ ./hello_world_client
2023-11-01 18:08:23.197728 [info] Using configuration file: "../helloworld-client.json".
2023-11-01 18:08:23.198257 [info] Parsed vsomeip configuration in 0ms
2023-11-01 18:08:23.198311 [info] Configuration module loaded.
2023-11-01 18:08:23.198388 [info] Security disabled!
2023-11-01 18:08:23.198420 [info] Initializing vsomeip (3.4.9.1) application "hello_world_client".
2023-11-01 18:08:23.198451 [info] Instantiating routing manager [Proxy].
2023-11-01 18:08:23.198662 [info] Client [5555] is connecting to [0] at /tmp/vsomeip-0
2023-11-01 18:08:23.198743 [info] Application(hello_world_client, 5555) is initialized (11, 100).
2023-11-01 18:08:23.198853 [info] Starting vsomeip application "hello_world_client" (5555) using 2 threads I/O nice 255
2023-11-01 18:08:23.199727 [info] shutdown thread id from application: 5555 (hello_world_client) is: 7fae936bf700 TID: 27766
2023-11-01 18:08:23.199711 [info] main dispatch thread id from application: 5555 (hello_world_client) is: 7fae93ec0700 TID: 27765
2023-11-01 18:08:23.200185 [info] io thread id from application: 5555 (hello_world_client) is: 7fae93f65000 TID: 27764
2023-11-01 18:08:23.200226 [info] io thread id from application: 5555 (hello_world_client) is: 7fae8bfff700 TID: 27767
2023-11-01 18:08:23.202116 [info] create_local_server: Listening @ /tmp/vsomeip-5555
2023-11-01 18:08:23.202279 [info] Client 5555 (hello_world_client) successfully connected to routing ~> registering..
2023-11-01 18:08:23.202326 [info] Registering to routing manager @ vsomeip-0
2023-11-01 18:08:23.204803 [info] Application/Client 5555 (hello_world_client) is registered.
2023-11-01 18:08:23.308749 [info] ON_AVAILABLE(5555): [1111.2222:0.0]
Sending: World
2023-11-01 18:08:23.309505 [info] Client [5555] is connecting to [4444] at /tmp/vsomeip-4444
Received: Hello World
2023-11-01 18:08:23.313131 [info] Stopping vsomeip application "hello_world_client" (5555).
2023-11-01 18:08:23.315530 [info] Application/Client 5555 (hello_world_client) is deregistered.
2023-11-01 18:08:23.316107 [info] Client [5555] is closing connection to [4444]
2023-11-01 18:08:23.316457 [info] local_uds_client_endpoint_impl::receive_cbk Error: Operation canceled

Summary

To learn vsomeip, I can only rely on myself to collect some information on the Internet. Since the configuration instructions are not detailed enough, or it is difficult to explain my confusion, I spent a lot of time researching and trying. Due to limited space, I decided to divide the learning process into two articles to share with everyone.