Skip to content

Commit

Permalink
Update to latest embassy and embedded-io 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasKoch committed Aug 31, 2023
1 parent 8370f56 commit 0e92703
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 30 deletions.
9 changes: 4 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ smoltcp = { version = "0.9.1", default-features = false, optional = true }
atomic-polyfill = "1.0.2"

defmt = { version = "0.3" }
embedded-hal = "=1.0.0-alpha.11"
embedded-hal = "=1.0.0-rc.1"
# embedded-nal = "0.6.0"
embassy-time = "0.1"
embassy-sync = "0.2"
embassy-futures = "0.1"
embassy-hal-common = "0.1"
embassy-net-driver = "0.1"

embedded-nal-async = { version = "0.4", optional = true }
embedded-nal-async = { version = "0.5", optional = true }
futures = { version = "0.3.17", default-features = false, features = [
"async-await",
] }

embedded-io = "0.4"
embedded-io = "0.5"
embedded-io-async = "0.5"

[features]
default = ["async", "odin_w2xx", "ublox-sockets", "socket-tcp"]
Expand Down Expand Up @@ -74,4 +74,3 @@ atat = { path = "../atat/atat" }
ublox-sockets = { path = "../ublox-sockets" }
no-std-net = { path = "../no-std-net" }
embassy-net-driver = { path = "../embassy/embassy-net-driver" }
embassy-hal-common = { path = "../embassy/embassy-hal-common" }
4 changes: 2 additions & 2 deletions examples/rpi-pico/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7.0"
futures = { version = "0.3.17", default-features = false, features = ["async-await", "cfg-target-has-atomic", "unstable"] }

embedded-io = { version = "0.4.0", features = ["async", "defmt"] }
embedded-io-async = { version = "0.5.0" }
heapless = "0.7.15"


Expand All @@ -36,7 +36,7 @@ heapless = "0.7.15"


embassy-executor = { path = "../../../embassy/embassy-executor" }
embassy-hal-common = { path = "../../../embassy/embassy-hal-common" }
embassy-hal-internal = { path = "../../../embassy/embassy-hal-internal" }
embassy-time = { path = "../../../embassy/embassy-time" }
embassy-futures = { path = "../../../embassy/embassy-futures" }
embassy-sync = { path = "../../../embassy/embassy-sync" }
Expand Down
8 changes: 4 additions & 4 deletions examples/rpi-pico/src/bin/embassy-async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use embassy_rp::peripherals::{PIN_26, UART1};
use embassy_rp::uart::BufferedInterruptHandler;
use embassy_rp::{bind_interrupts, uart};
use embassy_time::{Duration, Timer};
use embedded_io::asynch::Write;
use embedded_io_async::Write;
use no_std_net::{Ipv4Addr, SocketAddr};
use static_cell::make_static;
use ublox_short_range::asynch::runner::Runner;
Expand All @@ -29,12 +29,12 @@ use ublox_short_range::command::edm::urc::EdmEvent;
use ublox_short_range::embedded_nal_async::AddrType;
use {defmt_rtt as _, panic_probe as _};

const RX_BUF_LEN: usize = 1024;
const RX_BUF_LEN: usize = 4096;
const URC_CAPACITY: usize = 3;

type AtClient = ublox_short_range::atat::asynch::Client<
'static,
common::TxWrap<uart::BufferedUartTx<'static, UART1>>,
uart::BufferedUartTx<'static, UART1>,
RX_BUF_LEN,
>;

Expand Down Expand Up @@ -165,7 +165,7 @@ async fn main(spawner: Spawner) {

let buffers = &*make_static!(atat::Buffers::new());
let (ingress, client) = buffers.split(
common::TxWrap(tx),
tx,
EdmDigester::default(),
atat::Config::new(),
);
Expand Down
18 changes: 9 additions & 9 deletions examples/rpi-pico/src/common.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
use embassy_rp::uart;
use ublox_short_range::atat;

pub struct TxWrap<TX: embedded_io::asynch::Write>(pub TX);
// pub struct TxWrap<TX: embedded_io::asynch::Write>(pub TX);

impl<TX: embedded_io::asynch::Write> embedded_io::Io for TxWrap<TX> {
type Error = <TX as embedded_io::Io>::Error;
}
// impl<TX: embedded_io::asynch::Write> embedded_io::Io for TxWrap<TX> {
// type Error = <TX as embedded_io::Io>::Error;
// }

impl<TX: embedded_io::asynch::Write> embedded_io::asynch::Write for TxWrap<TX> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
self.0.write(buf).await
}
}
// impl<TX: embedded_io::asynch::Write> embedded_io::asynch::Write for TxWrap<TX> {
// async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
// self.0.write(buf).await
// }
// }

// impl<T: embassy_rp::uart::Instance> atat::UartExt for TxWrap<uart::BufferedUartTx<'static, T>> {
// type Error = ();
Expand Down
20 changes: 10 additions & 10 deletions src/asynch/ublox_stack/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,17 +306,17 @@ mod embedded_io_impls {
}
}

impl<'d> embedded_io::Io for TcpSocket<'d> {
impl<'d> embedded_io::ErrorType for TcpSocket<'d> {
type Error = Error;
}

impl<'d> embedded_io::asynch::Read for TcpSocket<'d> {
impl<'d> embedded_io_async::Read for TcpSocket<'d> {
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
self.io.read(buf).await
}
}

impl<'d> embedded_io::asynch::Write for TcpSocket<'d> {
impl<'d> embedded_io_async::Write for TcpSocket<'d> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
self.io.write(buf).await
}
Expand All @@ -326,21 +326,21 @@ mod embedded_io_impls {
}
}

impl<'d> embedded_io::Io for TcpReader<'d> {
impl<'d> embedded_io::ErrorType for TcpReader<'d> {
type Error = Error;
}

impl<'d> embedded_io::asynch::Read for TcpReader<'d> {
impl<'d> embedded_io_async::Read for TcpReader<'d> {
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
self.io.read(buf).await
}
}

impl<'d> embedded_io::Io for TcpWriter<'d> {
impl<'d> embedded_io::ErrorType for TcpWriter<'d> {
type Error = Error;
}

impl<'d> embedded_io::asynch::Write for TcpWriter<'d> {
impl<'d> embedded_io_async::Write for TcpWriter<'d> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
self.io.write(buf).await
}
Expand Down Expand Up @@ -457,21 +457,21 @@ pub mod client {
}
}

impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> embedded_io::Io
impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> embedded_io::ErrorType
for TcpConnection<'d, N, TX_SZ, RX_SZ>
{
type Error = Error;
}

impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> embedded_io::asynch::Read
impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> embedded_io_async::Read
for TcpConnection<'d, N, TX_SZ, RX_SZ>
{
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
self.socket.read(buf).await
}
}

impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> embedded_io::asynch::Write
impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> embedded_io_async::Write
for TcpConnection<'d, N, TX_SZ, RX_SZ>
{
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
Expand Down

0 comments on commit 0e92703

Please sign in to comment.