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
25 changes: 25 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,28 @@ jobs:
working-directory: ${{ matrix.example_directory }}
run: |
cargo clippy --locked

check-pico-de-gallo-examples:
runs-on: ubuntu-latest
# we use a matrix here just because env can't be used in job names
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
strategy:
fail-fast: false
matrix:
example_directory: ["examples/pico-de-gallo"]
name: ubuntu / check-examples
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install stable
uses: dtolnay/rust-toolchain@stable
- name: Download Cargo.lock files
if: ${{ inputs.download-lockfiles }}
uses: actions/download-artifact@v4
with:
name: updated-lock-files
- name: cargo clippy
working-directory: ${{ matrix.example_directory }}
run: |
cargo clippy --locked
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"Cargo.toml",
"examples/rt633/Cargo.toml",
"examples/rt685s-evk/Cargo.toml",
"examples/std/Cargo.toml"
"examples/std/Cargo.toml",
"examples/pico-de-gallo/Cargo.toml"
]
}
}
36 changes: 30 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ embassy-imxrt = { git = "https://github.com/OpenDevicePartnership/embassy-imxrt"
embassy-sync = "0.7.2"
embassy-time = "0.5.0"
embassy-time-driver = "0.2.1"
embedded-batteries-async = "0.2.0"
embedded-batteries-async = "0.3"
embedded-cfu-protocol = { git = "https://github.com/OpenDevicePartnership/embedded-cfu" }
embedded-hal = "1.0"
embedded-hal-async = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion battery-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ pub fn register_fuel_gauge(device: &'static device::Device) -> Result<(), embedd
}

/// Use the battery service endpoint to send data to other subsystems and services.
pub async fn comms_send(endpoint_id: EndpointID, data: &impl Any) -> Result<(), Infallible> {
pub async fn comms_send(endpoint_id: EndpointID, data: &(impl Any + Send + Sync)) -> Result<(), Infallible> {
SERVICE.endpoint.send(endpoint_id, data).await
}

Expand Down
12 changes: 6 additions & 6 deletions embedded-service/src/comms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,17 @@ impl From<External> for EndpointID {
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct Data<'a> {
contents: &'a dyn Any,
contents: &'a (dyn Any + Send + Sync),
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a breaking change, could you make sure to announce it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this necessary now?

}

impl<'a> Data<'a> {
/// Construct a Data portion of a Message from some data input
pub fn new(from: &'a impl Any) -> Self {
pub fn new(from: &'a (impl Any + Send + Sync)) -> Self {
Self { contents: from }
}

/// Attempt to retrieve data as type T -- None if incorrect type
pub fn get<T: Any>(&self) -> Option<&T> {
pub fn get<T: Any + Send + Sync>(&self) -> Option<&T> {
self.contents.downcast_ref()
}

Expand Down Expand Up @@ -143,7 +143,7 @@ impl<'a> Data<'a> {
/// if `data.is_a::<MessageClassA>() {}`
/// else if `data.is_a::<MessageClassB>() {}`
/// etc.
pub fn is_a<T: Any>(&self) -> bool {
pub fn is_a<T: Any + Send + Sync>(&self) -> bool {
self.type_id() == TypeId::of::<T>()
}
}
Expand Down Expand Up @@ -224,7 +224,7 @@ impl Endpoint {
}

/// Send a generic message to an endpoint
pub async fn send(&self, to: EndpointID, data: &impl Any) -> Result<(), Infallible> {
pub async fn send(&self, to: EndpointID, data: &(impl Any + Send + Sync)) -> Result<(), Infallible> {
send(self.id, to, data).await
}

Expand Down Expand Up @@ -304,7 +304,7 @@ fn get_list(target: EndpointID) -> &'static OnceLock<IntrusiveList> {
}

/// Send a generic message to an endpoint
pub async fn send(from: EndpointID, to: EndpointID, data: &impl Any) -> Result<(), Infallible> {
pub async fn send(from: EndpointID, to: EndpointID, data: &(impl Any + Send + Sync)) -> Result<(), Infallible> {
route(Message {
from,
to,
Expand Down
Loading