Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ communication/
### For Users
- [User Guide](score/mw/com/README.md) - Getting started with the API
- [API Reference](score/mw/com/design/README.md) - Detailed API documentation
- [Examples](score/mw/com/example/) - Code examples and tutorials
- [Examples](examples/) - Code examples and tutorials

### For Developers
- [Architecture Guide](score/mw/com/design/README.md) - System architecture overview
Expand Down
30 changes: 30 additions & 0 deletions examples/BUILD
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"],
)
137 changes: 137 additions & 0 deletions examples/README.md
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
```
Comment on lines +14 to +22

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

[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 in examples/BUILD are exposed as //examples:com_api_example, so users who copy these commands will get no 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.:

bazel build //examples:com_api_example
bazel build --config=x86_64-qnx //examples:com_api_example
Context for Agents
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 in `examples/BUILD` are exposed as `//examples:com_api_example`, so users who copy these commands will get `no 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.:

```bash
bazel build //examples:com_api_example
bazel build --config=x86_64-qnx //examples:com_api_example
```

File: examples/README.md
Line: 22
Chain of Thought
  • Validation Decision: accepted
  • Confidence: 0.97
  • Likelihood Score: 5/5
  • Likelihood Reason: The Bazel package //examples/com-api-example does not exist (no BUILD file at that path). Any user copying the documented command will get an immediate build error.
  • Suggested Action: keep
  • Tool Calls Used: 5

Reasoning

The comment is accurate and actionable:

  1. The examples/BUILD file 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.

  2. There is no examples/com-api-example/BUILD file in the repository, so the Bazel package //examples/com-api-example does not exist.

  3. The README (lines 15, 21) documents bazel build //examples/com-api-example:com-api-example which will fail with "no such package".

  4. The correct command should be bazel build //examples:com_api_example (using the alias).

  5. Notably, the IPC Bridge section (lines 81, 87) correctly uses //examples:ipc_bridge_cpp, showing this is an inconsistency within the same new file.

  6. 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)

  • File: examples/BUILD
1: # *******************************************************************************
2: # Copyright (c) 2026 Contributors to the Eclipse Foundation
3: #
4: # See the NOTICE file(s) distributed with this work for additional
5: # information regarding copyright ownership.
6: #
7: # This program and the accompanying materials are made available under the
8: # terms of the Apache License Version 2.0 which is available at
9: # https://www.apache.org/licenses/LICENSE-2.0
10: #
...

2. File Lookup

  • Filename: BUILD
  • Max Results: 10
Found 10 file(s) matching 'BUILD':
- bazel/rules/BUILD
- bazel/tools/BUILD
- BUILD
- quality/integration_testing/BUILD
- quality/integration_testing/environments/BUILD
- quality/integration_testing/environments/qnx8_qemu/BUILD
- quality/integration_testing/environments/ubuntu24_04_docker/BUILD
- quality/integration_testing/test/BUILD
- quality/sanitizer/BUILD
...

3. File Lookup

  • Filename: com-api-example
  • Max Results: 10
No files found matching 'com-api-example'

4. File Lookup

  • Filename: BUILD
  • Max Results: 10
Found 10 file(s) matching 'BUILD':
- bazel/rules/BUILD
- bazel/tools/BUILD
- BUILD
- quality/integration_testing/BUILD
- quality/integration_testing/environments/BUILD
- quality/integration_testing/environments/qnx8_qemu/BUILD
- quality/integration_testing/environments/ubuntu24_04_docker/BUILD
- quality/integration_testing/test/BUILD
- quality/sanitizer/BUILD
...

Fix in Cursor


### 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
2 changes: 2 additions & 0 deletions score/mw/com/example/ipc_bridge/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ cc_binary(
],
data = ["etc/mw_com_config.json"],
features = COMPILER_WARNING_FEATURES,
visibility = ["//examples:__pkg__"],
deps = [
":sample_sender_receiver",
"//score/mw/com",
Expand Down Expand Up @@ -82,6 +83,7 @@ rust_binary(
srcs = ["ipc_bridge.rs"],
data = ["etc/mw_com_config.json"],
features = ["link_std_cpp_lib"],
visibility = ["//examples:__pkg__"],
deps = [
":ipc_bridge_gen_rs",
"//score/mw/com/impl/rust:mw_com",
Expand Down