aboutsummaryrefslogtreecommitdiff
path: root/examples/std/src
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2022-05-04 20:48:37 +0200
committerDario Nieuwenhuis <[email protected]>2022-05-07 01:45:54 +0200
commit931a137f8c5a760c2e06c437c98d14eff3e3a587 (patch)
tree7b79ba8397c3eff730f634cbaf77aa5571337191 /examples/std/src
parentfc32b3750c448a81b7dd44cf9de98723b8eb4fcf (diff)
Replace embassy::io with embedded_io.
Diffstat (limited to 'examples/std/src')
-rw-r--r--examples/std/src/bin/net.rs5
-rw-r--r--examples/std/src/bin/serial.rs14
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
3use clap::Parser; 3use clap::Parser;
4use embassy::executor::{Executor, Spawner}; 4use embassy::executor::{Executor, Spawner};
5use embassy::io::AsyncWriteExt;
6use embassy::util::Forever; 5use embassy::util::Forever;
6use embassy_net::tcp::TcpSocket;
7use embassy_net::{ 7use embassy_net::{
8 Config, Configurator, DhcpConfigurator, Ipv4Address, Ipv4Cidr, StackResources, 8 Config, Configurator, DhcpConfigurator, Ipv4Address, Ipv4Cidr, StackResources,
9 StaticConfigurator, TcpSocket, 9 StaticConfigurator,
10}; 10};
11use embedded_io::asynch::Write;
11use heapless::Vec; 12use heapless::Vec;
12use log::*; 13use 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
6use async_io::Async; 6use async_io::Async;
7use embassy::executor::Executor; 7use embassy::executor::Executor;
8use embassy::io::AsyncBufReadExt;
9use embassy::util::Forever; 8use embassy::util::Forever;
9use embedded_io::asynch::Read;
10use log::*; 10use log::*;
11use nix::sys::termios; 11use 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