Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Udp sockets corrupt the w5500 device #44

Closed
elpiel opened this issue Apr 22, 2023 · 2 comments
Closed

Multiple Udp sockets corrupt the w5500 device #44

elpiel opened this issue Apr 22, 2023 · 2 comments

Comments

@elpiel
Copy link
Contributor

elpiel commented Apr 22, 2023

So, implementing some changes in #42 to the UDP and testing with multiple sockets at once makes me to believe that there is something wrong with the way the TX buffer (maybe even RX buffer) are used.

Pseudo code:

remote_addr = ...
socket_1 = w5500_device.socket().unwrap();
device.connect(socket_1, remote_addr)

socket_2 = w5500_device.socket().unwrap()
loop {
    socket_1.send(...);
   timeout(1/2 second)
   socket_2.send(...)
   timeout(1/2 second)
}

What ends up happening in this scenario is that the socket_2 gets into the infinite loop that waits for a SendOk or WriteTimeout and never receives one.

What I've managed to track so far is when I set the new TX write pointer and directly read it back before Command::Send, instead of having the newly set pointer it once again has 0.

Another (maybe unrelated to this one issue) is that at some point (even if I comment out the socket_2 code) I started to get WriteTimeout from the first socket_1.send().
This leads me to believe that it was left in an invalid state and flashing over and over didn't help with this issue either.
It did require a device reset (power down + up) to get it back working.

API improvement is needed

The main issues that were causing this problem were 2:

  1. When Device.connect is not called, Udp socket is not being opened #46
  2. When no destination is set and you call send - it should at least return an error if there's no destination remote address set
@ryan-summers
Copy link
Collaborator

@elpiel I think this issue is superceded by #46 and #59, is that correct? Multiple sockets works correctly after #57?

@elpiel
Copy link
Contributor Author

elpiel commented Jul 27, 2023

Yes, I've tested it with 2 sockets

@elpiel elpiel closed this as completed Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants