Skip to content

Commit 405d901

Browse files
Update smoltcp to v0.6.0
1 parent 8e0ee76 commit 405d901

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ volatile-register = "0.2"
2222
aligned = "0.3"
2323
stm32f4xx-hal = "0.5"
2424

25-
smoltcp = { version = "0.5.0", default-features = false, features = ["proto-ipv4", "proto-ipv6", "socket-icmp", "socket-udp", "socket-tcp", "log", "verbose"], optional = true }
25+
smoltcp = { version = "0.6.0", default-features = false, features = ["proto-ipv4", "proto-ipv6", "socket-icmp", "socket-udp", "socket-tcp", "log", "verbose", "ethernet"], optional = true }
2626
log = { version = "0.4", optional = true }
2727

2828
[features]

src/rx.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use core::ops::Deref;
1+
use core::ops::{Deref, DerefMut};
22
use core::default::Default;
33
use stm32f4xx_hal::stm32::ETHERNET_DMA;
44

@@ -151,6 +151,12 @@ impl<'a> Deref for RxPacket<'a> {
151151
}
152152
}
153153

154+
impl<'a> DerefMut for RxPacket<'a> {
155+
fn deref_mut(&mut self) -> &mut Self::Target {
156+
&mut self.entry.as_mut_slice()[0..self.length]
157+
}
158+
}
159+
154160
impl<'a> Drop for RxPacket<'a> {
155161
fn drop(&mut self) {
156162
self.entry.desc_mut().set_owned();

src/smoltcp_phy.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use core::intrinsics::transmute;
2-
use core::ops::Deref;
32
use smoltcp::Error;
43
use smoltcp::time::Instant;
54
use smoltcp::phy::{DeviceCapabilities, Device, RxToken, TxToken};
@@ -45,10 +44,10 @@ pub struct EthRxToken<'a> {
4544
}
4645

4746
impl<'a> RxToken for EthRxToken<'a> {
48-
fn consume<R, F>(self, _timestamp: Instant, f: F) -> Result<R, Error>
49-
where F: FnOnce(&[u8]) -> Result<R, Error>
47+
fn consume<R, F>(mut self, _timestamp: Instant, f: F) -> Result<R, Error>
48+
where F: FnOnce(&mut [u8]) -> Result<R, Error>
5049
{
51-
let result = f(self.packet.deref());
50+
let result = f(&mut self.packet);
5251
self.packet.free();
5352
result
5453
}

0 commit comments

Comments
 (0)