You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of 0.9.1 and current main 8b0c521, the "dhcp_client.rs" example, when it gets a Configured event, attempts to set the interface's IPv4 address as follows:
fnset_ipv4_addr(iface:&mutInterface,cidr:Ipv4Cidr){
iface.update_ip_addrs(|addrs| {let dest = addrs.iter_mut().next().unwrap();*dest = IpCidr::Ipv4(cidr);});}
This doesn't actually work in Smoltcp 0.9.1, because iter_mut() on a heapless::Vec iterates only over the existing items, and is incapable of adding one if the Vec is currently empty. It always panics unwrapping the error from next(). This code worked in 0.8.x because iter_mut() on a mutable slice (which is what ManagedSlice derefs to) does iterate over all elements (which were set to UNSPECIFIED if not currently in use).
For smoltcp 0.9.x, set_ipv4_addr should probably do something like:
@pdh11 thanks for making this issue! This probably saved me another 6 hours of troubleshooting while thinking this was a problem with my network switch. I made #905 to fix this, and have a piece of firmware based on those fixes running on a board now w/ IP address acquired successfully.
Everything works, despite smoltcp-rs/smoltcp#783
Git stm32-eth is needed for now (but presumably smoltcp-0.9 support will
be in its next release).
With smoltcp 0.8 it wasn't possible to write send_with correctly: we only
know how big the packet will be when f() returns, which is too late for
udp::Socket::send; we need the new udp::Socket::send_with.
As of 0.9.1 and current main 8b0c521, the "dhcp_client.rs" example, when it gets a Configured event, attempts to set the interface's IPv4 address as follows:
This doesn't actually work in Smoltcp 0.9.1, because iter_mut() on a heapless::Vec iterates only over the existing items, and is incapable of adding one if the Vec is currently empty. It always panics unwrapping the error from next(). This code worked in 0.8.x because iter_mut() on a mutable slice (which is what ManagedSlice derefs to) does iterate over all elements (which were set to UNSPECIFIED if not currently in use).
For smoltcp 0.9.x, set_ipv4_addr should probably do something like:
and likewise on a Deconfigured event it should do addrs.clear().
The text was updated successfully, but these errors were encountered: