Skip to content
Closed
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
158774a
added a conversion function from uri to iceorxy2 addressing scheme + …
catappreciationhours2 Jul 13, 2025
aa94194
Update src/lib.rs
catappreciationhours2 Jul 16, 2025
966803d
modified compute_service_name to accept source and sink instead of UM…
catappreciationhours2 Jul 16, 2025
8fe6511
added oft spec workflow
catappreciationhours2 Jul 16, 2025
c1e66f1
created workflow check
catappreciationhours2 Jul 16, 2025
f5af7d1
allow new branch to run on
catappreciationhours2 Jul 16, 2025
8435769
modified file name
catappreciationhours2 Jul 16, 2025
9b2504d
allow dead code
catappreciationhours2 Jul 16, 2025
56c0cfe
allow dead code
catappreciationhours2 Jul 16, 2025
41020a0
removed unused imports
catappreciationhours2 Jul 16, 2025
7033c26
retry with fixed email
catappreciationhours2 Jul 16, 2025
ef9f7fb
added a conversion function from uri to iceorxy2 addressing scheme + …
catappreciationhours2 Jul 13, 2025
f0d3f04
Update src/lib.rs
catappreciationhours2 Jul 16, 2025
d99be0c
modified compute_service_name to accept source and sink instead of UM…
catappreciationhours2 Jul 16, 2025
0f05535
Update src/lib.rs
catappreciationhours2 Jul 20, 2025
d71293a
modified to use helper function and use match for more clear pattern …
catappreciationhours2 Jul 20, 2025
d29b055
modified compute service name to use custom helper to determine messa…
catappreciationhours2 Jul 20, 2025
bb007c9
removed unwrap
catappreciationhours2 Jul 20, 2025
8fa1894
trying to get rid of eol errors
vidishac2004 Jul 23, 2025
dc2bbac
trying to get rid of build errors due to Ustatus::invalid_argument
vidishac2004 Jul 24, 2025
a0eee80
replaced match with simple if/else statements and used the let else l…
vidishac2004 Jul 24, 2025
7ce6f0c
Normalize line endings to LF and add .gitattributes
vidishac2004 Jul 24, 2025
f88b6dd
Normalize line endings to LF
vidishac2004 Jul 24, 2025
b4be668
resolved build error
vidishac2004 Jul 25, 2025
c024126
Update .env.oft-latest
vidishac2004 Jul 26, 2025
aa2e4ab
Update src/lib.rs
vidishac2004 Jul 26, 2025
570bb2c
resolved formatting issues
vidishac2004 Jul 26, 2025
3bebd0e
OFT branch merged with main
vidishac2004 Jul 26, 2025
5cb7657
Merge branch 'main' into open_fast_trace
vidishac2004 Jul 26, 2025
544bf37
Merge branch 'open_fast_trace' of github.com:catappreciationhours2/up…
catappreciationhours2 Aug 27, 2025
552e6e0
updated spec yaml to mirror mqtt formatting
catappreciationhours2 Aug 27, 2025
668990b
modified gitignore to match main
catappreciationhours2 Aug 27, 2025
177d959
Merge branch 'main' into open_fast_trace
catappreciationhours2 Aug 27, 2025
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: 2 additions & 0 deletions .env.oft-latest
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
OFT_FILE_PATTERNS=src/**/*.rs
OFT_TAGS_=TransportLayerImpl
Comment thread
vidishac2004 marked this conversation as resolved.
Outdated
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
56 changes: 56 additions & 0 deletions .github/workflows/spec_compatibility.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: OpenFastTrace Validation

on:
pull_request:
push:
branches:
- main
- open_fast_trace
workflow_dispatch:

env:
RUST_TOOLCHAIN: stable
RUSTFLAGS: -Dwarnings
CARGO_TERM_COLOR: always

jobs:
requirements-tracing:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"

- name: Set up up-spec main branch
run: |
cd up-spec
git checkout main
git pull

- name: Read .env for OFT config
uses: xom9ikk/dotenv@v2.3.0
with:
mode: "oft-latest"
load-mode: strict

- name: Run OpenFastTrace
id: run-oft
uses: eclipse-uprotocol/ci-cd/.github/actions/run-oft@main
with:
file-patterns: "${{ env.OFT_FILE_PATTERNS }}"
tags: "${{ env.OFT_TAGS_ }}"

- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@nextest
- name: Run tests
run: |
cargo nextest run --all-features
cargo test --doc --all-features

- name: Check OpenFastTrace result
env:
OFT_EXIT_CODE: ${{ steps.run-oft.outputs.oft-exit-code }}
run: exit $OFT_EXIT_CODE
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "up-spec"]
path = up-spec
url = https://github.com/eclipse-uprotocol/up-spec
114 changes: 113 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use async_trait::async_trait;
use std::sync::Arc;
use up_rust::{UListener, UMessage, UStatus, UTransport, UUri};
use up_rust::{UListener, UMessage, UStatus, UTransport, UUri, UCode};

/// This will be the main struct for our uProtocol transport.
/// It will hold the state necessary to communicate with iceoryx2,
Expand Down Expand Up @@ -33,7 +33,119 @@ impl UTransport for Iceoryx2Transport {
}
}

#[allow(dead_code)]
impl Iceoryx2Transport {
fn encode_uuri_segments(uuri: &UUri) -> Vec<String> {
vec![
uuri.authority_name.clone(),
Self::encode_hex(uuri.uentity_type_id() as u32),
Self::encode_hex(uuri.uentity_instance_id() as u32),
Self::encode_hex(uuri.uentity_major_version() as u32),
Self::encode_hex(uuri.resource_id() as u32),
]
}

fn encode_hex(value: u32) -> String {
format!("{:X}", value)
}

fn compute_service_name(source: &UUri,sink: Option<&UUri>) -> Result<String, UStatus> {
let join_segments = |segments: Vec<String>| segments.join("/");

// [specitem,oft-sid="dsn~up-transport-iceoryx2-service-name~1",oft-needs="impl"]
Comment thread
vidishac2004 marked this conversation as resolved.
Outdated
// Handle RPC Request: source.resource_id == 0, valid sink (1<=sink.resource_id<=0x7FFF)
if (source.resource_id==0 )&& !(sink.is_none()){
if !((1<=sink.unwrap().resource_id && sink.unwrap().resource_id<=0x7FFF)){
UStatus::fail_with_code(UCode::INVALID_ARGUMENT, "Invalid sink URI for RPC request");
}
let segments = Self::encode_uuri_segments(sink.unwrap());
Ok(format!("up/{}", join_segments(segments)))
}
// [specitem,oft-sid="dsn~up-transport-iceoryx2-service-name~1",oft-needs="impl"]
// Handle Notification or RPC Response: sink.resource_id == 0, valid source(1<=source.resource_id<=0xFFFE)
else if (!(sink.is_none()))&&(sink.unwrap().resource_id==0){
if 1<=source.resource_id && source.resource_id <=0xFFFE{
let source_segments = Self::encode_uuri_segments(source);
let sink_segments = Self::encode_uuri_segments(sink.unwrap());
Ok(format!(
"up/{}/{}",
join_segments(source_segments),
join_segments(sink_segments)
))
}
else{
Err(UStatus::fail_with_code(UCode::INVALID_ARGUMENT, "Invalid sink and source URIs"))}
}
// [specitem,oft-sid="dsn~up-transport-iceoryx2-service-name~1",oft-needs="impl"]
// Handle Publish: 1 <= source.resource_id <= 0x7FFF
else if 1<=source.resource_id && source.resource_id<=0x7FFF {
let segments = Self::encode_uuri_segments(source);
Ok(format!("up/{}", join_segments(segments)))
} else {
Err(UStatus::fail_with_code(
UCode::INVALID_ARGUMENT,
"Unsupported UMessageType",
))
}

}
}

#[cfg(test)]
mod tests {
use super::*;

fn test_uri(authority: &str, instance: u16, typ: u16, version: u8, resource: u16) -> UUri {
let entity_id = ((instance as u32) << 16) | (typ as u32);
UUri::try_from_parts(authority, entity_id, version, resource).unwrap()
}

#[test]
// [specitem,oft-sid="dsn~up-transport-iceoryx2-service-name~1",oft-needs="utest"]
fn test_publish_service_name() {
let source = test_uri("device1", 0x0000, 0x10AB, 0x03, 0x7FFF);

let name = Iceoryx2Transport::compute_service_name(&source,None).unwrap();
assert_eq!(name, "up/device1/10AB/0/3/7FFF");
}

#[test]
// [specitem,oft-sid="dsn~up-transport-iceoryx2-service-name~1",oft-needs="utest"]
fn test_notification_service_name() {
let source = test_uri("device1", 0x0000, 0x10AB, 0x03, 0x80CD);
let sink = test_uri("device1", 0x0000, 0x30EF, 0x04, 0x0000);
let name = Iceoryx2Transport::compute_service_name(&source,Some(&sink)).unwrap();
assert_eq!(name, "up/device1/10AB/0/3/80CD/device1/30EF/0/4/0");
}

#[test]
// [specitem,oft-sid="dsn~up-transport-iceoryx2-service-name~1",oft-needs="utest"]
fn test_rpc_request_service_name() {
let sink = test_uri("device1", 0x0004, 0x03AB, 0x03, 0x0000);
let reply_to = test_uri("device1", 0x0000, 0x00CD, 0x04, 0xB);

let name = Iceoryx2Transport::compute_service_name(&sink,Some(&reply_to)).unwrap();
assert_eq!(name, "up/device1/CD/0/4/B");
}

#[test]
// [specitem,oft-sid="dsn~up-transport-iceoryx2-service-name~1",oft-needs="utest"]
fn test_rpc_response_service_name() {
let source = test_uri("device1", 0x0000, 0x00CD, 0x04, 0xB);
let sink = test_uri("device1", 0x0004, 0x3AB, 0x3, 0x0000);


let name = Iceoryx2Transport::compute_service_name(&source,Some(&sink)).unwrap();
assert_eq!(name, "up/device1/CD/0/4/B/device1/3AB/4/3/0");
}

#[test]
// [specitem,oft-sid="dsn~up-transport-iceoryx2-service-name~1",oft-needs="utest"]
fn test_missing_uri_error() {
let uuri = UUri::new();
let result = Iceoryx2Transport::compute_service_name(&uuri, None);

assert!(result.is_err());
assert_eq!(result.unwrap_err().get_code(), UCode::INVALID_ARGUMENT);
}
}
1 change: 1 addition & 0 deletions up-spec
Submodule up-spec added at ba0f3c
Loading