diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-10-03 22:15:02 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2023-10-04 00:10:55 +0200 |
| commit | 0324cee0ca9caf40a43583367fe7ff0448d0f35f (patch) | |
| tree | 782dcf67fa9b0dacd637c588d4160544d38fe6e5 /embassy-net-ppp | |
| parent | 8ac5c1a9635c72d80a173fbc4bc7d5753cbdbecd (diff) | |
update embedded-io, embedded-nal-async.
Diffstat (limited to 'embassy-net-ppp')
| -rw-r--r-- | embassy-net-ppp/Cargo.toml | 2 | ||||
| -rw-r--r-- | embassy-net-ppp/src/lib.rs | 17 |
2 files changed, 4 insertions, 15 deletions
diff --git a/embassy-net-ppp/Cargo.toml b/embassy-net-ppp/Cargo.toml index da09f780e..453da436a 100644 --- a/embassy-net-ppp/Cargo.toml +++ b/embassy-net-ppp/Cargo.toml | |||
| @@ -15,7 +15,7 @@ log = ["dep:log", "ppproto/log"] | |||
| 15 | defmt = { version = "0.3", optional = true } | 15 | defmt = { version = "0.3", optional = true } |
| 16 | log = { version = "0.4.14", optional = true } | 16 | log = { version = "0.4.14", optional = true } |
| 17 | 17 | ||
| 18 | embedded-io-async = { version = "0.5.0" } | 18 | embedded-io-async = { version = "0.6.0" } |
| 19 | embassy-net-driver-channel = { version = "0.1.0", path = "../embassy-net-driver-channel" } | 19 | embassy-net-driver-channel = { version = "0.1.0", path = "../embassy-net-driver-channel" } |
| 20 | embassy-futures = { version = "0.1.0", path = "../embassy-futures" } | 20 | embassy-futures = { version = "0.1.0", path = "../embassy-futures" } |
| 21 | ppproto = { version = "0.1.2"} | 21 | ppproto = { version = "0.1.2"} |
diff --git a/embassy-net-ppp/src/lib.rs b/embassy-net-ppp/src/lib.rs index 66496ee0a..54a98c95f 100644 --- a/embassy-net-ppp/src/lib.rs +++ b/embassy-net-ppp/src/lib.rs | |||
| @@ -11,7 +11,7 @@ use core::mem::MaybeUninit; | |||
| 11 | use embassy_futures::select::{select, Either}; | 11 | use embassy_futures::select::{select, Either}; |
| 12 | use embassy_net_driver_channel as ch; | 12 | use embassy_net_driver_channel as ch; |
| 13 | use embassy_net_driver_channel::driver::LinkState; | 13 | use embassy_net_driver_channel::driver::LinkState; |
| 14 | use embedded_io_async::{BufRead, Write, WriteAllError}; | 14 | use embedded_io_async::{BufRead, Write}; |
| 15 | use ppproto::pppos::{BufferFullError, PPPoS, PPPoSAction}; | 15 | use ppproto::pppos::{BufferFullError, PPPoS, PPPoSAction}; |
| 16 | pub use ppproto::{Config, Ipv4Status}; | 16 | pub use ppproto::{Config, Ipv4Status}; |
| 17 | 17 | ||
| @@ -49,23 +49,12 @@ pub enum RunError<E> { | |||
| 49 | Read(E), | 49 | Read(E), |
| 50 | /// Writing to the serial port failed. | 50 | /// Writing to the serial port failed. |
| 51 | Write(E), | 51 | Write(E), |
| 52 | /// Writing to the serial port wrote zero bytes, indicating it can't accept more data. | ||
| 53 | WriteZero, | ||
| 54 | /// Writing to the serial got EOF. | 52 | /// Writing to the serial got EOF. |
| 55 | Eof, | 53 | Eof, |
| 56 | /// PPP protocol was terminated by the peer | 54 | /// PPP protocol was terminated by the peer |
| 57 | Terminated, | 55 | Terminated, |
| 58 | } | 56 | } |
| 59 | 57 | ||
| 60 | impl<E> From<WriteAllError<E>> for RunError<E> { | ||
| 61 | fn from(value: WriteAllError<E>) -> Self { | ||
| 62 | match value { | ||
| 63 | WriteAllError::Other(e) => Self::Write(e), | ||
| 64 | WriteAllError::WriteZero => Self::WriteZero, | ||
| 65 | } | ||
| 66 | } | ||
| 67 | } | ||
| 68 | |||
| 69 | impl<'d> Runner<'d> { | 58 | impl<'d> Runner<'d> { |
| 70 | /// You must call this in a background task for the driver to operate. | 59 | /// You must call this in a background task for the driver to operate. |
| 71 | /// | 60 | /// |
| @@ -125,7 +114,7 @@ impl<'d> Runner<'d> { | |||
| 125 | buf[..pkt.len()].copy_from_slice(pkt); | 114 | buf[..pkt.len()].copy_from_slice(pkt); |
| 126 | rx_chan.rx_done(pkt.len()); | 115 | rx_chan.rx_done(pkt.len()); |
| 127 | } | 116 | } |
| 128 | PPPoSAction::Transmit(n) => rw.write_all(&tx_buf[..n]).await?, | 117 | PPPoSAction::Transmit(n) => rw.write_all(&tx_buf[..n]).await.map_err(RunError::Write)?, |
| 129 | } | 118 | } |
| 130 | 119 | ||
| 131 | let status = ppp.status(); | 120 | let status = ppp.status(); |
| @@ -148,7 +137,7 @@ impl<'d> Runner<'d> { | |||
| 148 | } | 137 | } |
| 149 | Either::Second(pkt) => { | 138 | Either::Second(pkt) => { |
| 150 | match ppp.send(pkt, &mut tx_buf) { | 139 | match ppp.send(pkt, &mut tx_buf) { |
| 151 | Ok(n) => rw.write_all(&tx_buf[..n]).await?, | 140 | Ok(n) => rw.write_all(&tx_buf[..n]).await.map_err(RunError::Write)?, |
| 152 | Err(BufferFullError) => unreachable!(), | 141 | Err(BufferFullError) => unreachable!(), |
| 153 | } | 142 | } |
| 154 | tx_chan.tx_done(); | 143 | tx_chan.tx_done(); |
