Skip to content

Commit 46b6edf

Browse files
committed
fix topic check
1 parent 40b0426 commit 46b6edf

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

booster_sdk/examples/x5_camera_rpc_check.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ use booster_sdk::dds::{RpcClientOptions, X5_CAMERA_CONTROL_API_TOPIC};
1515

1616
#[tokio::main]
1717
async fn main() -> Result<(), Box<dyn std::error::Error>> {
18-
tracing_subscriber::fmt().with_env_filter("info").init();
18+
let env_filter = tracing_subscriber::EnvFilter::try_from_default_env()
19+
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("error"));
20+
tracing_subscriber::fmt().with_env_filter(env_filter).init();
1921

2022
let domain_id = std::env::var("BOOSTER_DOMAIN_ID")
2123
.ok()
@@ -37,6 +39,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
3739
service_topic: X5_CAMERA_CONTROL_API_TOPIC.to_owned(),
3840
})?;
3941

42+
// Give DDS discovery a moment to settle before the first RPC call.
43+
tokio::time::sleep(Duration::from_millis(500)).await;
44+
4045
let started = Instant::now();
4146
match client.get_status().await {
4247
Ok(resp) => {

booster_sdk/src/dds/rpc.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,20 @@ impl RpcClient {
284284
Ok(Some(sample)) => {
285285
let response = sample.into_value();
286286

287+
if response.uuid != request_id {
288+
if debug_enabled {
289+
tracing::debug!(
290+
target: "booster_sdk::rpc",
291+
service_topic = %service_topic,
292+
api_id,
293+
request_uuid = %request_id,
294+
response_uuid = %response.uuid,
295+
"ignoring response for a different request uuid"
296+
);
297+
}
298+
continue;
299+
}
300+
287301
let status_code = parse_status_from_header(&response.header).unwrap_or(0);
288302
if debug_enabled {
289303
tracing::debug!(

booster_sdk/src/dds/topics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub fn rpc_response_topic(service_topic: &str) -> TopicSpec {
6262
TopicSpec {
6363
name: format!("{service_topic}Resp"),
6464
type_name: TYPE_RPC_RESP,
65-
qos: qos_best_effort_keep_last(10),
65+
qos: qos_reliable_keep_last(10),
6666
kind: TopicKind::NoKey,
6767
}
6868
}

0 commit comments

Comments
 (0)