-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration test showing that the Crazyflie object cannot be sent…
… between threads
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Test that the Crazyflie object can be sent between threads | ||
|
||
use std::thread::spawn; | ||
use crazyflie_lib::Crazyflie; | ||
|
||
#[async_std::test] | ||
async fn crazyflie_can_be_sent_to_thread() -> Result<(), Box<dyn std::error::Error>> { | ||
let link_context = crazyflie_link::LinkContext::new(async_executors::AsyncStd); | ||
|
||
// Scan for Crazyflies on the default address | ||
let found = link_context.scan([0xE7; 5]).await?; | ||
|
||
if let Some(uri) = found.first() { | ||
// Connect to the first Crazyflie found | ||
let cf = crazyflie_lib::Crazyflie::connect_from_uri( | ||
async_executors::AsyncStd, | ||
&link_context, | ||
uri, | ||
) | ||
.await?; | ||
|
||
let _ = spawn(move || { | ||
cf | ||
}).join().unwrap(); | ||
} | ||
Ok(()) | ||
} |