diff options
| author | Josh Junon <[email protected]> | 2023-09-28 18:28:46 +0200 |
|---|---|---|
| committer | Josh Junon <[email protected]> | 2023-09-28 18:28:46 +0200 |
| commit | fa2e63f74baf625b5547d5362a5237b279a643c7 (patch) | |
| tree | 0ea17488be6e1c6786a4d8b07d6212db86d38170 | |
| parent | a72a91ab069049f04cbf9e90ce9b178b3876558f (diff) | |
enc28j60: return packet length from receive() instead of mut slice
| -rw-r--r-- | embassy-net-enc28j60/src/lib.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/embassy-net-enc28j60/src/lib.rs b/embassy-net-enc28j60/src/lib.rs index b44cefaf2..72229dc08 100644 --- a/embassy-net-enc28j60/src/lib.rs +++ b/embassy-net-enc28j60/src/lib.rs | |||
| @@ -197,7 +197,7 @@ where | |||
| 197 | /// Flushes the transmit buffer, ensuring all pending transmissions have completed | 197 | /// Flushes the transmit buffer, ensuring all pending transmissions have completed |
| 198 | /// NOTE: The returned packet *must* be `read` or `ignore`-d, otherwise this method will always | 198 | /// NOTE: The returned packet *must* be `read` or `ignore`-d, otherwise this method will always |
| 199 | /// return `None` on subsequent invocations | 199 | /// return `None` on subsequent invocations |
| 200 | pub fn receive<'a>(&mut self, buf: &'a mut [u8]) -> Option<&'a mut [u8]> { | 200 | pub fn receive(&mut self, buf: &mut [u8]) -> Option<usize> { |
| 201 | if self.pending_packets() == 0 { | 201 | if self.pending_packets() == 0 { |
| 202 | // Errata #6: we can't rely on PKTIF so we check PKTCNT | 202 | // Errata #6: we can't rely on PKTIF so we check PKTCNT |
| 203 | return None; | 203 | return None; |
| @@ -241,7 +241,7 @@ where | |||
| 241 | 241 | ||
| 242 | self.next_packet = next_packet; | 242 | self.next_packet = next_packet; |
| 243 | 243 | ||
| 244 | Some(&mut buf[..len as usize]) | 244 | Some(len as usize) |
| 245 | } | 245 | } |
| 246 | 246 | ||
| 247 | fn wait_tx_ready(&mut self) { | 247 | fn wait_tx_ready(&mut self) { |
| @@ -642,9 +642,8 @@ where | |||
| 642 | fn receive(&mut self, cx: &mut core::task::Context) -> Option<(Self::RxToken<'_>, Self::TxToken<'_>)> { | 642 | fn receive(&mut self, cx: &mut core::task::Context) -> Option<(Self::RxToken<'_>, Self::TxToken<'_>)> { |
| 643 | let rx_buf = unsafe { &mut RX_BUF }; | 643 | let rx_buf = unsafe { &mut RX_BUF }; |
| 644 | let tx_buf = unsafe { &mut TX_BUF }; | 644 | let tx_buf = unsafe { &mut TX_BUF }; |
| 645 | if let Some(pkt) = self.receive(rx_buf) { | 645 | if let Some(n) = self.receive(rx_buf) { |
| 646 | let n = pkt.len(); | 646 | Some((RxToken { buf: &mut rx_buf[..n] }, TxToken { buf: tx_buf, eth: self })) |
| 647 | Some((RxToken { buf: &mut pkt[..n] }, TxToken { buf: tx_buf, eth: self })) | ||
| 648 | } else { | 647 | } else { |
| 649 | cx.waker().wake_by_ref(); | 648 | cx.waker().wake_by_ref(); |
| 650 | None | 649 | None |
