Skip to content
Open
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
1 change: 1 addition & 0 deletions examples/com-api-example
1 change: 1 addition & 0 deletions examples/ipc_bridge
134 changes: 134 additions & 0 deletions score/mw/com/example/com-api-example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# COM-API-EXAMPLE

## Building

### 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/examples/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/examples/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.

### Running Tests

```bash
bazel test //examples/com-api-example:com-api-example-test
```

The test suite includes:

- **Integration test**: Basic producer-consumer workflow with synchronous operations
- **Async test**: Multi-threaded async producer-consumer using Tokio runtime

## Configuration

The communication behavior is configured via `examples/com-api-example/etc/config.json`:

- Service interface definitions (`VehicleInterface`)
- Event definitions for data types (`Tire`)
- Instance-specific configuration
- Shared memory settings and transport configuration

## Project Structure

```text
examples/
├── com-api-example/
│ ├── basic-consumer-producer.rs # Main example and integration tests
│ ├── BUILD # Bazel build configuration
│ ├── etc/
│ │ └── config.json # Communication configuration
│ └── com-api-gen/
│ ├── com_api_gen.rs # Generated Rust bindings
│ ├── vehicle_gen.cpp # Generated C++ implementation
│ └── vehicle_gen.h # Generated C++ headers
```

## 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();
```

### Async Multi-Threading (Test)

The async test demonstrates:

- Concurrent producer and consumer tasks using Tokio
- Asynchronous data sending at 2ms intervals
- Asynchronous data processing with buffering
- Proper lifecycle management (offer/unoffer)

## Troubleshooting

### Build Warnings

You may see deprecation warnings during compilation related to the COM API. These are intentional warnings from the S-CORE libraries and do not prevent successful builds.

### QNX Builds

QNX cross-compilation requires:

- QNX SDP installation and license
- Proper credential setup (see `.github/workflows/build_and_test_qnx.yml` for CI example)

### Configuration Path Issues

The example expects the configuration file at:

```text
score/mw/com/example/com-api-example/etc/config.json
```

Ensure this path is accessible from your workspace root when running the binary.
1 change: 1 addition & 0 deletions score/mw/com/example/com-api-example/com-api-gen/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ rust_library(
features = ["link_std_cpp_lib"],
visibility = [
"//score/mw/com:__subpackages__",
"//examples:__subpackages__",
],
deps = [
":vehicle_gen_cpp",
Expand Down
127 changes: 127 additions & 0 deletions score/mw/com/example/ipc_bridge/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# IPC_BRIDGE

## Building

### Standard Build (Host Platform)

```bash
bazel build //examples/ipc_bridge:sample_sender_receiver
```

### QNX Cross-Compilation

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

## Running

After building the binary will be in `bazel-bin/examples/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/examples/ipc_bridge/ipc_bridge_cpp \
--mode skeleton \
--cycle-time 1000 \
--num-cycles 10 \
--service_instance_manifest examples/ipc_bridge/etc/mw_com_config.json
```

**Terminal 2 - Start Proxy (Subscriber):**

```bash
./bazel-bin/examples/ipc_bridge/ipc_bridge_cpp \
--mode proxy \
--cycle-time 500 \
--num-cycles 20 \
--service_instance_manifest examples/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.

### Start Skeleton (Publisher)

```bash
./bazel-bin/examples/ipc_bridge/ipc_bridge_cpp \
--mode skeleton \
--cycle-time 1000 \
--num-cycles 10 \
--service_instance_manifest examples/ipc_bridge/etc/mw_com_config.json
```

### Start Proxy (Subscriber)

```bash
./bazel-bin/src/scrample \
--mode proxy \
--cycle-time 500 \
--num-cycles 20 \
--service_instance_manifest examples/ipc_bridge/etc/mw_com_config.json
```

### 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 `examples/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

## Project Structure

``` text
examples/
├── ipc_bridge/
│ ├── main.cpp # Entry point and CLI argument parsing
│ ├── sample_sender_receiver.cpp # Core skeleton/proxy logic
│ ├── datatype.h # Data type definitions
│ ├── assert_handler.cpp # Custom assertion handling
│ └── etc/
│ ├── mw_com_config.json # Communication configuration
│ └── logging.json # Logging configuration
```

## Troubleshooting

### Runtime Warnings

When running the application, you may see:

```text
mw::log initialization error: Error No logging configuration files could be found.
Fallback to console logging.
```

This is expected and harmless. The application falls back to console logging when the optional logging configuration isn't found at the expected system location.

### Build Warnings

You may see deprecation warnings during compilation related to:

- `string_view` null-termination checks
- `InstanceSpecifier::Create()` API deprecations

These are intentional warnings from the S-CORE libraries and do not prevent successful builds. They are addressed in the `.bazelrc` configuration with `-Wno-error=deprecated-declarations`.

### QNX Builds

QNX cross-compilation requires:

- QNX SDP installation and license
- Proper credential setup (see `.github/workflows/build_and_test_qnx.yml` for CI example)
Loading