forked from eclipse-score/communication
-
Notifications
You must be signed in to change notification settings - Fork 0
refactor examples structure #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+170
−1
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # ******************************************************************************* | ||
| # Copyright (c) 2026 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 Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* | ||
|
|
||
| alias( | ||
| name = "com_api_example", | ||
| actual = "//score/mw/com/example/com-api-example:com-api-example", | ||
| visibility = ["//visibility:public"], | ||
| ) | ||
|
|
||
| alias( | ||
| name = "ipc_bridge_cpp", | ||
| actual = "//score/mw/com/example/ipc_bridge:ipc_bridge_cpp", | ||
| visibility = ["//visibility:public"], | ||
| ) | ||
|
|
||
| alias( | ||
| name = "ipc_bridge_rs", | ||
| actual = "//score/mw/com/example/ipc_bridge:ipc_bridge_rs", | ||
| visibility = ["//visibility:public"], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| # Examples | ||
|
|
||
| This directory contains aliases to example applications demonstrating the S-CORE Communication middleware API. | ||
|
|
||
| ## Available Examples | ||
|
|
||
| - **[COM-API-Example](#com-api-example)**: Rust-based producer-consumer pattern demonstrating the Communication API with tire pressure data | ||
| - **[IPC Bridge](#ipc-bridge)**: C++/Rust application demonstrating IPC communication with skeleton/proxy pattern | ||
|
|
||
| ## COM-API-Example | ||
|
|
||
| ### Standard Build (Host Platform) | ||
|
|
||
| ```bash | ||
| bazel build //examples/com-api-example:com-api-example | ||
| ``` | ||
|
|
||
| ### QNX Cross-Compilation | ||
|
|
||
| ```bash | ||
| bazel build --config=x86_64-qnx //examples/com-api-example:com-api-example | ||
| ``` | ||
|
|
||
| ### Running | ||
|
|
||
| After building, the binary will be in `bazel-bin/score/mw/com/example/com-api-example/com-api-example`. | ||
|
|
||
| ### Quick Start | ||
|
|
||
| To see the COM API in action, run the example from the repo root: | ||
|
|
||
| ```bash | ||
| ./bazel-bin/score/mw/com/example/com-api-example/com-api-example | ||
| ``` | ||
|
|
||
| The application demonstrates a producer-consumer pattern where: | ||
|
|
||
| - A `VehicleOfferedProducer` publishes tire pressure data | ||
| - A `VehicleConsumer` subscribes to and receives tire pressure updates | ||
| - Five samples are sent with incrementing tire pressure values (5.0, 6.0, 7.0, 8.0, 9.0) | ||
| - Each sample is read back and validated | ||
|
|
||
| You should see output showing tire data being sent and received, demonstrating the complete publish-subscribe workflow. | ||
|
|
||
| ### Code Structure | ||
|
|
||
| The example demonstrates several key patterns: | ||
|
|
||
| ### VehicleMonitor Struct | ||
|
|
||
| A composite structure that combines: | ||
|
|
||
| - `VehicleConsumer`: Subscribes to vehicle data | ||
| - `VehicleOfferedProducer`: Publishes vehicle data | ||
| - `Subscription`: Active subscription to tire data | ||
|
|
||
| ### Producer-Consumer Pattern | ||
|
|
||
| ```rust | ||
| // Create producer | ||
| let producer = create_producer(runtime, service_id.clone()); | ||
|
|
||
| // Create consumer | ||
| let consumer = create_consumer(runtime, service_id); | ||
|
|
||
| // Create monitor combining both | ||
| let monitor = VehicleMonitor::new(consumer, producer).unwrap(); | ||
|
|
||
| // Write data | ||
| monitor.write_tire_data(Tire { pressure: 5.0 }).unwrap(); | ||
|
|
||
| // Read data | ||
| let tire_data = monitor.read_tire_data().unwrap(); | ||
| ``` | ||
|
|
||
| ## IPC Bridge | ||
|
|
||
| ### Standard Build (Host Platform) | ||
|
|
||
| ```bash | ||
| bazel build //examples:ipc_bridge_cpp | ||
| ``` | ||
|
|
||
| ### QNX Cross-Compilation | ||
|
|
||
| ```bash | ||
| bazel build --config=x86_64-qnx //examples:ipc_bridge_cpp | ||
| ``` | ||
|
|
||
| ### Running | ||
|
|
||
| After building the binary will be in `bazel-bin/score/mw/com/example/ipc_bridge/ipc_bridge_cpp`. | ||
|
|
||
| #### Quick Start (Two Terminals) | ||
|
|
||
| To see the IPC communication in action, open two terminals in the repo root: | ||
|
|
||
| **Terminal 1 - Start Skeleton (Publisher):** | ||
|
|
||
| ```bash | ||
| ./bazel-bin/score/mw/com/example/ipc_bridge/ipc_bridge_cpp \ | ||
| --mode skeleton \ | ||
| --cycle-time 1000 \ | ||
| --num-cycles 10 \ | ||
| --service_instance_manifest score/mw/com/example/ipc_bridge/etc/mw_com_config.json | ||
| ``` | ||
|
|
||
| **Terminal 2 - Start Proxy (Subscriber):** | ||
|
|
||
| ```bash | ||
| ./bazel-bin/score/mw/com/example/ipc_bridge/ipc_bridge_cpp \ | ||
| --mode proxy \ | ||
| --cycle-time 500 \ | ||
| --num-cycles 20 \ | ||
| --service_instance_manifest score/mw/com/example/ipc_bridge/etc/mw_com_config.json | ||
| ``` | ||
|
|
||
| You should see the proxy discover the skeleton service, subscribe, and receive `MapApiLanesStamped` samples. The proxy validates data integrity and ordering for each received sample. | ||
|
|
||
| #### Command-Line Options | ||
|
|
||
| | Option | Description | Required | | ||
| | ------ | ----------- | -------- | | ||
| | `--mode, -m` | Operation mode: `skeleton`/`send` or `proxy`/`recv` | Yes | | ||
| | `--cycle-time, -t` | Cycle time in milliseconds for sending/polling | Yes | | ||
| | `--num-cycles, -n` | Number of cycles to execute (0 = infinite) | Yes | | ||
| | `--service_instance_manifest, -s` | Path to communication config JSON | Optional | | ||
| | `--disable-hash-check, -d` | Skip sample hash validation in proxy mode | Optional | | ||
|
|
||
| ## Configuration | ||
|
|
||
| The communication behavior is configured via `score/mw/com/example/ipc_bridge/etc/mw_com_config.json`: | ||
|
|
||
| - Service type definitions and bindings | ||
| - Event definitions with IDs | ||
| - Instance-specific configuration (shared memory settings, subscriber limits) | ||
| - ASIL level and process ID restrictions | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Documentation] The build commands documented here point to a package (
//examples/com-api-example:com-api-example) that does not exist in this refactor. The aliases you added inexamples/BUILDare exposed as//examples:com_api_example, so users who copy these commands will getno such package 'examples/com-api-example'. Update the host and QNX build instructions to use the alias label (or the original//score/...label) so the commands actually work, e.g.:Context for Agents
Chain of Thought
//examples/com-api-exampledoes not exist (no BUILD file at that path). Any user copying the documented command will get an immediate build error.Reasoning
The comment is accurate and actionable:
The
examples/BUILDfile defines aliases:com_api_example→//score/mw/com/example/com-api-example:com-api-example,ipc_bridge_cpp→//score/mw/com/example/ipc_bridge:ipc_bridge_cpp, etc.There is no
examples/com-api-example/BUILDfile in the repository, so the Bazel package//examples/com-api-exampledoes not exist.The README (lines 15, 21) documents
bazel build //examples/com-api-example:com-api-examplewhich will fail with "no such package".The correct command should be
bazel build //examples:com_api_example(using the alias).Notably, the IPC Bridge section (lines 81, 87) correctly uses
//examples:ipc_bridge_cpp, showing this is an inconsistency within the same new file.This is entirely new content introduced by this PR (the file was empty before), so this is clearly a PR-introduced issue.
The comment provides a specific fix with corrected commands. This is valid and actionable.
Evidence Summary
1. File Snapshot (HEAD)
examples/BUILD2. File Lookup
BUILD103. File Lookup
com-api-example104. File Lookup
BUILD10