diff --git a/Cargo.toml b/Cargo.toml index cab540aa..d719f781 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,8 @@ [workspace] resolver = "2" members = [ - "example-utils/hello-world-protos", + "utils/hello-world-protos", + "utils/integration-test-utils", "up-linux-streamer", "up-streamer", "subscription-cache", "example-utils/usubscription-static-file"] diff --git a/README.md b/README.md index 0ded63c1..6e049ce4 100644 --- a/README.md +++ b/README.md @@ -21,69 +21,3 @@ Please reference the documentation for [vsomeip-sys](https://github.com/eclipse- * the build requirements for vsomeip in the linked documentation in the COVESA repo * the environment variables which must be set -## Running examples - -### Running the `up-linux-streamer` - -To run one of the examples below and see client and service communicate, you'll need to run the `up-linux-streamer` to bridge between the transports in a terminal: - -```bash -LD_LIBRARY_PATH=$LD_LIBRARY_PATH: cargo run -- --config up-linux-streamer/DEFAULT_CONFIG.json5 -``` - -### Mechatronics client to high compute service - -Launch the `uE_service` example in another terminal: - -```bash -LD_LIBRARY_PATH=$LD_LIBRARY_PATH: cargo run --example uE_service -``` - -Launch the `mE_client` example in another terminal: - -```bash -LD_LIBRARY_PATH=$LD_LIBRARY_PATH: cargo run --example mE_client -``` - -The service and client will run forever. Every second a new message is sent from the mE_client via vsomeip. That vsomeip message is caught and routed over Zenoh to the uE_service. The response makes the same journey in reverse. - -It's intended that you see the following in the terminal running the `mE_client`: - -> Sending Request message: -UMessage { attributes: MessageField(Some(UAttributes { id: MessageField(Some(UUID { msb: 112888656100425728, lsb: 9811577761723054400, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } })), type_: UMESSAGE_TYPE_REQUEST, source: MessageField(Some(UUri { authority_name: "me_authority", ue_id: 22136, ue_version_major: 1, resource_id: 0, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } })), sink: MessageField(Some(UUri { authority_name: "linux", ue_id: 4662, ue_version_major: 1, resource_id: 2198, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } })), priority: UPRIORITY_CS4, ttl: Some(1000), permission_level: None, commstatus: None, reqid: MessageField(None), token: None, traceparent: None, payload_format: UPAYLOAD_FORMAT_PROTOBUF, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } })), **payload: Some(b"\n\rme_client@i=3")**, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } } - -This is the request message we will send _from_ the mE_client over vsomeip. - -Note the payload is listed with `@i=3`. This number is incremented on each send so that we can trace the message back and forth over the `up-linux-streamer`. - -You should then see something like this in the `uE_service` terminal: - -> ServiceRequestResponder: Received a message: UMessage { attributes: MessageField(Some(UAttributes { id: MessageField(Some(UUID { msb: 112888656100622336, lsb: 10998499817480005337, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } })), type_: UMESSAGE_TYPE_REQUEST, source: MessageField(Some(UUri { authority_name: "me_authority", ue_id: 257, ue_version_major: 1, resource_id: 0, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } })), sink: MessageField(Some(UUri { authority_name: "linux", ue_id: 4662, ue_version_major: 1, resource_id: 2198, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } })), priority: UPRIORITY_CS4, ttl: Some(1000), permission_level: None, commstatus: None, reqid: MessageField(None), token: None, traceparent: None, payload_format: UPAYLOAD_FORMAT_UNSPECIFIED, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } })), **payload: Some(b"\n\rme_client@i=3")**, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } } - -Note that the message we received in the uE_service through the streamer still shows the payload with `@i=3`. - -If you again reference the terminal where `mE_client` is running you should see the the response message printed: - -> ServiceResponseListener: Received a message: UMessage { attributes: MessageField(Some(UAttributes { id: MessageField(Some(UUID { msb: 112888656101015552, lsb: 9811577761723054400, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } })), type_: UMESSAGE_TYPE_RESPONSE, source: MessageField(Some(UUri { authority_name: "linux", ue_id: 4662, ue_version_major: 1, resource_id: 2198, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } })), sink: MessageField(Some(UUri { authority_name: "me_authority", ue_id: 257, ue_version_major: 1, resource_id: 0, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } })), priority: UPRIORITY_CS4, ttl: None, permission_level: None, commstatus: Some(INTERNAL), reqid: MessageField(Some(UUID { msb: 112888656100425728, lsb: 9811577761723054400, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } })), token: None, traceparent: None, payload_format: UPAYLOAD_FORMAT_UNSPECIFIED, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } })), **payload: Some(b"\nThe response to the request: me_client@i=3")**, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } } - -Note that the response also contains `@i=3` showing that we have received a response for the original request containing that in the payload. - -Further, you will see printed the deserialized `HelloResponse` ProtoBuf object: - -> Here we received response: HelloResponse { message: "The response to the request: me_client@i=3", special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } } - -### High compute service to mechatronics client - -Launch the `mE_service` example in another terminal: - -```bash -LD_LIBRARY_PATH=$LD_LIBRARY_PATH: cargo run --example mE_service -``` - -Launch the `uE_client` example in another terminal: - -```bash -LD_LIBRARY_PATH=$LD_LIBRARY_PATH: cargo run --example uE_client -``` - -We omit a detail explanation of the expected terminal output as it's a mirror of the `Mechatronics client to high compute service` heading above. diff --git a/up-linux-streamer/Cargo.toml b/up-linux-streamer/Cargo.toml index 0ae923e3..e8018cff 100644 --- a/up-linux-streamer/Cargo.toml +++ b/up-linux-streamer/Cargo.toml @@ -30,4 +30,4 @@ usubscription-static-file = {path = "../example-utils/usubscription-static-file" chrono = "0.4" [dev-dependencies] -hello-world-protos = { path = "../example-utils/hello-world-protos" } +hello-world-protos = { path = "../utils/hello-world-protos" } diff --git a/up-linux-streamer/README.md b/up-linux-streamer/README.md index 19249f53..19f15833 100644 --- a/up-linux-streamer/README.md +++ b/up-linux-streamer/README.md @@ -11,3 +11,9 @@ Reference the `DEFAULT_CONFIG.json5` configuration file to understand configurat The default is to build a bundled version of vsomeip for use by the `up-transport-vsomeip` crate. If you wish to bring your own vsomeip install, you can use the flag `--no-default-features` flag when building with `cargo build`. For more details on required environment variables when building `up-transport-vsomeip-rust`, reference the README for [vsomeip-sys](https://github.com/eclipse-uprotocol/up-transport-vsomeip-rust/tree/main/vsomeip-sys). + +### Running the `up-linux-streamer` + +```bash +LD_LIBRARY_PATH=$LD_LIBRARY_PATH: cargo run -- --config up-linux-streamer/DEFAULT_CONFIG.json5 +``` diff --git a/up-linux-streamer/examples/README.md b/up-linux-streamer/examples/README.md new file mode 100644 index 00000000..cbac5161 --- /dev/null +++ b/up-linux-streamer/examples/README.md @@ -0,0 +1,64 @@ +# Examples + +## Running examples + +### Running the `up-linux-streamer` + +To run one of the examples below and see client and service communicate, you'll need to run the `up-linux-streamer` to bridge between the transports in a terminal. See `up-linux-streamer` README for details. + +### Mechatronics client to high compute service + +Launch the `uE_service` example in another terminal: + +```bash +LD_LIBRARY_PATH=$LD_LIBRARY_PATH: cargo run --example uE_service +``` + +Launch the `mE_client` example in another terminal: + +```bash +LD_LIBRARY_PATH=$LD_LIBRARY_PATH: cargo run --example mE_client +``` + +The service and client will run forever. Every second a new message is sent from the mE_client via vsomeip. That vsomeip message is caught and routed over Zenoh to the uE_service. The response makes the same journey in reverse. + +It's intended that you see the following in the terminal running the `mE_client`: + +> Sending Request message: +UMessage { attributes: MessageField(Some(UAttributes { id: MessageField(Some(UUID { msb: 112888656100425728, lsb: 9811577761723054400, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } })), type_: UMESSAGE_TYPE_REQUEST, source: MessageField(Some(UUri { authority_name: "me_authority", ue_id: 22136, ue_version_major: 1, resource_id: 0, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } })), sink: MessageField(Some(UUri { authority_name: "linux", ue_id: 4662, ue_version_major: 1, resource_id: 2198, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } })), priority: UPRIORITY_CS4, ttl: Some(1000), permission_level: None, commstatus: None, reqid: MessageField(None), token: None, traceparent: None, payload_format: UPAYLOAD_FORMAT_PROTOBUF, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } })), **payload: Some(b"\n\rme_client@i=3")**, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } } + +This is the request message we will send _from_ the mE_client over vsomeip. + +Note the payload is listed with `@i=3`. This number is incremented on each send so that we can trace the message back and forth over the `up-linux-streamer`. + +You should then see something like this in the `uE_service` terminal: + +> ServiceRequestResponder: Received a message: UMessage { attributes: MessageField(Some(UAttributes { id: MessageField(Some(UUID { msb: 112888656100622336, lsb: 10998499817480005337, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } })), type_: UMESSAGE_TYPE_REQUEST, source: MessageField(Some(UUri { authority_name: "me_authority", ue_id: 257, ue_version_major: 1, resource_id: 0, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } })), sink: MessageField(Some(UUri { authority_name: "linux", ue_id: 4662, ue_version_major: 1, resource_id: 2198, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } })), priority: UPRIORITY_CS4, ttl: Some(1000), permission_level: None, commstatus: None, reqid: MessageField(None), token: None, traceparent: None, payload_format: UPAYLOAD_FORMAT_UNSPECIFIED, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } })), **payload: Some(b"\n\rme_client@i=3")**, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } } + +Note that the message we received in the uE_service through the streamer still shows the payload with `@i=3`. + +If you again reference the terminal where `mE_client` is running you should see the the response message printed: + +> ServiceResponseListener: Received a message: UMessage { attributes: MessageField(Some(UAttributes { id: MessageField(Some(UUID { msb: 112888656101015552, lsb: 9811577761723054400, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } })), type_: UMESSAGE_TYPE_RESPONSE, source: MessageField(Some(UUri { authority_name: "linux", ue_id: 4662, ue_version_major: 1, resource_id: 2198, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } })), sink: MessageField(Some(UUri { authority_name: "me_authority", ue_id: 257, ue_version_major: 1, resource_id: 0, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } })), priority: UPRIORITY_CS4, ttl: None, permission_level: None, commstatus: Some(INTERNAL), reqid: MessageField(Some(UUID { msb: 112888656100425728, lsb: 9811577761723054400, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } })), token: None, traceparent: None, payload_format: UPAYLOAD_FORMAT_UNSPECIFIED, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } })), **payload: Some(b"\nThe response to the request: me_client@i=3")**, special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } } + +Note that the response also contains `@i=3` showing that we have received a response for the original request containing that in the payload. + +Further, you will see printed the deserialized `HelloResponse` ProtoBuf object: + +> Here we received response: HelloResponse { message: "The response to the request: me_client@i=3", special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } } + +### High compute service to mechatronics client + +Launch the `mE_service` example in another terminal: + +```bash +LD_LIBRARY_PATH=$LD_LIBRARY_PATH: cargo run --example mE_service +``` + +Launch the `uE_client` example in another terminal: + +```bash +LD_LIBRARY_PATH=$LD_LIBRARY_PATH: cargo run --example uE_client +``` + +We omit a detail explanation of the expected terminal output as it's a mirror of the `Mechatronics client to high compute service` heading above. diff --git a/up-linux-streamer/vsomeip-configs/point_to_point.json b/up-linux-streamer/vsomeip-configs/point_to_point.json index aecf2bd9..ff7c26f3 100644 --- a/up-linux-streamer/vsomeip-configs/point_to_point.json +++ b/up-linux-streamer/vsomeip-configs/point_to_point.json @@ -6,4 +6,4 @@ "id" : "0x1236" } ] -} \ No newline at end of file +} diff --git a/up-streamer/Cargo.toml b/up-streamer/Cargo.toml index d5648476..a556d6b4 100644 --- a/up-streamer/Cargo.toml +++ b/up-streamer/Cargo.toml @@ -37,4 +37,4 @@ usubscription-static-file = {path="../example-utils/usubscription-static-file"} [dev-dependencies] async-broadcast = { version = "0.7.0" } chrono = { version = "0.4.31", features = [] } -integration-test-utils = { path = "../example-utils/integration-test-utils" } +integration-test-utils = { path = "../utils/integration-test-utils" } diff --git a/example-utils/hello-world-protos/Cargo.toml b/utils/hello-world-protos/Cargo.toml similarity index 93% rename from example-utils/hello-world-protos/Cargo.toml rename to utils/hello-world-protos/Cargo.toml index 91559b0a..f557b996 100644 --- a/example-utils/hello-world-protos/Cargo.toml +++ b/utils/hello-world-protos/Cargo.toml @@ -18,7 +18,7 @@ edition = "2021" [dependencies] bytes = { version = "1.5" } -protobuf = { version = "3.3", features = ["with-bytes"] } +protobuf = { workspace = true } [build-dependencies] protobuf-codegen = { version = "3.3" } diff --git a/example-utils/hello-world-protos/build.rs b/utils/hello-world-protos/build.rs similarity index 97% rename from example-utils/hello-world-protos/build.rs rename to utils/hello-world-protos/build.rs index 8b27d2a1..b594e84e 100644 --- a/example-utils/hello-world-protos/build.rs +++ b/utils/hello-world-protos/build.rs @@ -24,7 +24,6 @@ fn main() -> std::io::Result<()> { // if let Err(err) = get_and_build_protos( if let Err(err) = get_and_build_protos( &[ - "https://raw.githubusercontent.com/protocolbuffers/protobuf/main/src/google/protobuf/descriptor.proto", "https://raw.githubusercontent.com/googleapis/googleapis/master/google/type/timeofday.proto", "https://raw.githubusercontent.com/eclipse-uprotocol/up-spec/main/up-core-api/uprotocol/uoptions.proto", "https://raw.githubusercontent.com/COVESA/uservices/main/src/main/proto/example/hello_world/v1/hello_world_topics.proto", diff --git a/example-utils/hello-world-protos/src/lib.rs b/utils/hello-world-protos/src/lib.rs similarity index 100% rename from example-utils/hello-world-protos/src/lib.rs rename to utils/hello-world-protos/src/lib.rs diff --git a/example-utils/integration-test-utils/Cargo.toml b/utils/integration-test-utils/Cargo.toml similarity index 100% rename from example-utils/integration-test-utils/Cargo.toml rename to utils/integration-test-utils/Cargo.toml diff --git a/example-utils/integration-test-utils/src/integration_test_listeners.rs b/utils/integration-test-utils/src/integration_test_listeners.rs similarity index 100% rename from example-utils/integration-test-utils/src/integration_test_listeners.rs rename to utils/integration-test-utils/src/integration_test_listeners.rs diff --git a/example-utils/integration-test-utils/src/integration_test_messages.rs b/utils/integration-test-utils/src/integration_test_messages.rs similarity index 100% rename from example-utils/integration-test-utils/src/integration_test_messages.rs rename to utils/integration-test-utils/src/integration_test_messages.rs diff --git a/example-utils/integration-test-utils/src/integration_test_utils.rs b/utils/integration-test-utils/src/integration_test_utils.rs similarity index 100% rename from example-utils/integration-test-utils/src/integration_test_utils.rs rename to utils/integration-test-utils/src/integration_test_utils.rs diff --git a/example-utils/integration-test-utils/src/integration_test_uuris.rs b/utils/integration-test-utils/src/integration_test_uuris.rs similarity index 100% rename from example-utils/integration-test-utils/src/integration_test_uuris.rs rename to utils/integration-test-utils/src/integration_test_uuris.rs diff --git a/example-utils/integration-test-utils/src/lib.rs b/utils/integration-test-utils/src/lib.rs similarity index 100% rename from example-utils/integration-test-utils/src/lib.rs rename to utils/integration-test-utils/src/lib.rs diff --git a/example-utils/integration-test-utils/src/up_client_foo.rs b/utils/integration-test-utils/src/up_client_foo.rs similarity index 100% rename from example-utils/integration-test-utils/src/up_client_foo.rs rename to utils/integration-test-utils/src/up_client_foo.rs