Merge tag 'v0.1.11' into main am: 8f346cf239 am: 8a7a95b9fd
Original change: https://android-review.googlesource.com/c/platform/external/rust/pica/+/3112266
Change-Id: Icdcf87283cf3373070d35937c201c2dcc8eb4c4c
Signed-off-by: Automerger Merge Worker <[email protected]>
diff --git a/Android.bp b/Android.bp
index 42d3c8b..19bdfb5 100644
--- a/Android.bp
+++ b/Android.bp
@@ -17,7 +17,7 @@
genrule {
name: "libpica_uci_packets",
- defaults: ["pdl_rust_generator_defaults"],
+ defaults: ["pdl_rust_legacy_generator_defaults"],
srcs: ["src/uci_packets.pdl"],
out: ["uci_packets.rs"],
}
diff --git a/Cargo.lock b/Cargo.lock
index 5658b08..2afdffa 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -491,9 +491,9 @@
[[package]]
name = "pdl-compiler"
-version = "0.2.3"
+version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d277c9e6a1869e95522f9bd532bc225f85c03434b48cd914524235910f9ccdbe"
+checksum = "6853e3b47aa4a5be1287e9115d6fae9b3118971eba855f4d60323d19a66c07cf"
dependencies = [
"argh",
"codespan-reporting",
@@ -510,9 +510,9 @@
[[package]]
name = "pdl-runtime"
-version = "0.2.3"
+version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ce05e0a116b0250bb41732e2858eada706aebdf311d7f832898c9256bb442abe"
+checksum = "a8684812e36689336c83de6033669573b33b6e59c831145ee496c38a71ed0d7c"
dependencies = [
"bytes",
"thiserror",
@@ -565,7 +565,7 @@
[[package]]
name = "pica"
-version = "0.1.10"
+version = "0.1.11"
dependencies = [
"anyhow",
"bytes",
diff --git a/Cargo.toml b/Cargo.toml
index 16a8b9d..24feebe 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "pica"
-version = "0.1.10"
+version = "0.1.11"
edition = "2021"
description = "Pica is a virtual UWB Controller implementing the FiRa UCI specification."
repository = "https://github.com/google/pica"
@@ -41,7 +41,7 @@
web = ["hyper", "tokio/rt-multi-thread"]
[build-dependencies]
-pdl-compiler = "0.2.3"
+pdl-compiler = "0.3.0"
[dependencies]
anyhow = "1.0.56"
@@ -55,7 +55,7 @@
env_logger = { version = "0.10.0", default-features = false }
num-derive = "0.3.3"
num-traits = "0.2.17"
-pdl-runtime = "0.2.2"
+pdl-runtime = "0.3.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "1.0.49"
diff --git a/METADATA b/METADATA
index 7efb27a..b94f89c 100644
--- a/METADATA
+++ b/METADATA
@@ -12,7 +12,7 @@
type: GIT
value: "https://github.com/google/pica.git"
}
- version: "v0.1.10"
+ version: "v0.1.11"
license_type: NOTICE
- last_upgrade_date { year: 2024 month: 5 day: 22 }
+ last_upgrade_date { year: 2024 month: 6 day: 3 }
}
diff --git a/build.rs b/build.rs
index 3535d03..c99bdd8 100644
--- a/build.rs
+++ b/build.rs
@@ -39,7 +39,7 @@
)
.expect("PDL parse failed");
let analyzed_file = pdl_compiler::analyzer::analyze(&parsed_file).expect("PDL analysis failed");
- let rust_source = pdl_compiler::backends::rust::generate(&sources, &analyzed_file);
+ let rust_source = pdl_compiler::backends::rust_legacy::generate(&sources, &analyzed_file);
out_file
.write_all(rust_source.as_bytes())
.expect("Could not write to output file");
diff --git a/src/device.rs b/src/device.rs
index eec1c7f..62f3ffc 100644
--- a/src/device.rs
+++ b/src/device.rs
@@ -19,6 +19,7 @@
use std::collections::HashMap;
use std::time::Duration;
+use pdl_runtime::Packet;
use tokio::sync::mpsc;
use tokio::time;
@@ -142,8 +143,13 @@
let tx = self.tx.clone();
tokio::spawn(async move {
time::sleep(Duration::from_millis(5)).await;
- tx.send(CoreDeviceStatusNtfBuilder { device_state }.build().into())
- .unwrap()
+ tx.send(
+ CoreDeviceStatusNtfBuilder { device_state }
+ .build()
+ .encode_to_vec()
+ .unwrap(),
+ )
+ .unwrap()
});
}
@@ -194,8 +200,13 @@
}
// Send a response or notification to the Host.
- fn send_control(&mut self, packet: impl Into<Vec<u8>>) {
- let _ = self.tx.send(packet.into());
+ fn send_raw_control(&mut self, packet: Vec<u8>) {
+ let _ = self.tx.send(packet);
+ }
+
+ // Send a response or notification to the Host.
+ fn send_control(&mut self, packet: impl Packet) {
+ self.send_raw_control(packet.encode_to_vec().unwrap());
}
// The fira norm specify to send a response, then reset, then
@@ -753,7 +764,8 @@
session_token: session_handle,
}
.build()
- .into(),
+ .encode_to_vec()
+ .unwrap(),
)
.unwrap()
});
@@ -1050,7 +1062,7 @@
1,
status.into(),
];
- self.send_control(response)
+ self.send_raw_control(response)
}
// Parsing success, ignore non command packets.
diff --git a/src/lib.rs b/src/lib.rs
index 4803656..ef9fdd6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -13,6 +13,7 @@
// limitations under the License.
use anyhow::Result;
+use pdl_runtime::Packet;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fmt::Display;
@@ -477,7 +478,8 @@
status: uci::Status::Ok,
}
.build()
- .into(),
+ .encode_to_vec()
+ .unwrap(),
)
.unwrap();
}
@@ -495,7 +497,8 @@
vendor_data: vec![],
}
.build()
- .into(),
+ .encode_to_vec()
+ .unwrap(),
)
.unwrap();
diff --git a/src/session.rs b/src/session.rs
index 2ee656a..e31a262 100644
--- a/src/session.rs
+++ b/src/session.rs
@@ -19,6 +19,7 @@
use crate::packets::uci::{self, *};
use crate::{AppConfig, MacAddress};
use bytes::BytesMut;
+use pdl_runtime::Packet;
use std::time::Duration;
use tokio::sync::mpsc;
use tokio::task::JoinHandle;
@@ -80,7 +81,8 @@
reason_code: reason_code.into(),
}
.build()
- .into(),
+ .encode_to_vec()
+ .unwrap(),
)
.unwrap()
});