From 931a137f8c5a760c2e06c437c98d14eff3e3a587 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 4 May 2022 20:48:37 +0200 Subject: Replace embassy::io with embedded_io. --- examples/std/src/bin/net.rs | 5 +++-- examples/std/src/bin/serial.rs | 14 +++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'examples/std/src/bin') 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 @@ use clap::Parser; use embassy::executor::{Executor, Spawner}; -use embassy::io::AsyncWriteExt; use embassy::util::Forever; +use embassy_net::tcp::TcpSocket; use embassy_net::{ Config, Configurator, DhcpConfigurator, Ipv4Address, Ipv4Cidr, StackResources, - StaticConfigurator, TcpSocket, + StaticConfigurator, }; +use embedded_io::asynch::Write; use heapless::Vec; use log::*; 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; use async_io::Async; use embassy::executor::Executor; -use embassy::io::AsyncBufReadExt; use embassy::util::Forever; +use embedded_io::asynch::Read; use log::*; use nix::sys::termios; @@ -24,12 +24,12 @@ async fn run() { // Essentially, async_io::Async converts from AsRawFd+Read+Write to futures's AsyncRead+AsyncWrite let port = Async::new(port).unwrap(); - // This implements futures's AsyncBufRead based on futures's AsyncRead - let port = futures::io::BufReader::new(port); - - // We can then use FromStdIo to convert from futures's AsyncBufRead+AsyncWrite - // to embassy's AsyncBufRead+AsyncWrite - let mut port = embassy::io::FromStdIo::new(port); + // We can then use FromStdIo to convert from futures's AsyncRead+AsyncWrite + // to embedded_io's async Read+Write. + // + // This is not really needed, you could write the code below using futures::io directly. + // It's useful if you want to have portable code across embedded and std. + let mut port = embedded_io::adapters::FromFutures::new(port); info!("Serial opened!"); -- cgit