diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-05-04 20:48:37 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-05-07 01:45:54 +0200 |
| commit | 931a137f8c5a760c2e06c437c98d14eff3e3a587 (patch) | |
| tree | 7b79ba8397c3eff730f634cbaf77aa5571337191 /examples/std/src/bin | |
| parent | fc32b3750c448a81b7dd44cf9de98723b8eb4fcf (diff) | |
Replace embassy::io with embedded_io.
Diffstat (limited to 'examples/std/src/bin')
| -rw-r--r-- | examples/std/src/bin/net.rs | 5 | ||||
| -rw-r--r-- | examples/std/src/bin/serial.rs | 14 |
2 files changed, 10 insertions, 9 deletions
diff --git a/examples/std/src/bin/net.rs b/examples/std/src/bin/net.rs index 3b4bc6fea..daedffb0f 100644 --- a/examples/std/src/bin/net.rs +++ b/examples/std/src/bin/net.rs | |||
| @@ -2,12 +2,13 @@ | |||
| 2 | 2 | ||
| 3 | use clap::Parser; | 3 | use clap::Parser; |
| 4 | use embassy::executor::{Executor, Spawner}; | 4 | use embassy::executor::{Executor, Spawner}; |
| 5 | use embassy::io::AsyncWriteExt; | ||
| 6 | use embassy::util::Forever; | 5 | use embassy::util::Forever; |
| 6 | use embassy_net::tcp::TcpSocket; | ||
| 7 | use embassy_net::{ | 7 | use embassy_net::{ |
| 8 | Config, Configurator, DhcpConfigurator, Ipv4Address, Ipv4Cidr, StackResources, | 8 | Config, Configurator, DhcpConfigurator, Ipv4Address, Ipv4Cidr, StackResources, |
| 9 | StaticConfigurator, TcpSocket, | 9 | StaticConfigurator, |
| 10 | }; | 10 | }; |
| 11 | use embedded_io::asynch::Write; | ||
| 11 | use heapless::Vec; | 12 | use heapless::Vec; |
| 12 | use log::*; | 13 | use log::*; |
| 13 | 14 | ||
diff --git a/examples/std/src/bin/serial.rs b/examples/std/src/bin/serial.rs index 129dc2090..b1e5b0142 100644 --- a/examples/std/src/bin/serial.rs +++ b/examples/std/src/bin/serial.rs | |||
| @@ -5,8 +5,8 @@ mod serial_port; | |||
| 5 | 5 | ||
| 6 | use async_io::Async; | 6 | use async_io::Async; |
| 7 | use embassy::executor::Executor; | 7 | use embassy::executor::Executor; |
| 8 | use embassy::io::AsyncBufReadExt; | ||
| 9 | use embassy::util::Forever; | 8 | use embassy::util::Forever; |
| 9 | use embedded_io::asynch::Read; | ||
| 10 | use log::*; | 10 | use log::*; |
| 11 | use nix::sys::termios; | 11 | use nix::sys::termios; |
| 12 | 12 | ||
| @@ -24,12 +24,12 @@ async fn run() { | |||
| 24 | // Essentially, async_io::Async converts from AsRawFd+Read+Write to futures's AsyncRead+AsyncWrite | 24 | // Essentially, async_io::Async converts from AsRawFd+Read+Write to futures's AsyncRead+AsyncWrite |
| 25 | let port = Async::new(port).unwrap(); | 25 | let port = Async::new(port).unwrap(); |
| 26 | 26 | ||
| 27 | // This implements futures's AsyncBufRead based on futures's AsyncRead | 27 | // We can then use FromStdIo to convert from futures's AsyncRead+AsyncWrite |
| 28 | let port = futures::io::BufReader::new(port); | 28 | // to embedded_io's async Read+Write. |
| 29 | 29 | // | |
| 30 | // We can then use FromStdIo to convert from futures's AsyncBufRead+AsyncWrite | 30 | // This is not really needed, you could write the code below using futures::io directly. |
| 31 | // to embassy's AsyncBufRead+AsyncWrite | 31 | // It's useful if you want to have portable code across embedded and std. |
| 32 | let mut port = embassy::io::FromStdIo::new(port); | 32 | let mut port = embedded_io::adapters::FromFutures::new(port); |
| 33 | 33 | ||
| 34 | info!("Serial opened!"); | 34 | info!("Serial opened!"); |
| 35 | 35 | ||
