socket.c sendto() ignores SOCK_IO_NONBLOCK flag?
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Share projects and connect with makers.
Joined before the site update? first.
New to WIZnet Makers?
We sent a verification link to your address. Open it to activate your account, then log in.
Accounts from this email provider are reviewed by an administrator after verification. Approval usually takes one business day.
Already have an account?
Enter your email address. If it belongs to an account, we'll send a link to set a new password. Members who joined before the site update use this to set their password.
If an account uses that address, we sent a link to set a new password. The link works once and expires in 30 minutes.
Know your password?
Need an account?
RE: socket.c sendto() ignores SOCK_IO_NONBLOCK flag?
by Eugeny ·
The code is correct from WIZnet chip workflow sequence, but you raised interesting issue. Under normal circumstances data sending is performed very quickly, here we have the issue with sending timing out. Can you please check what arguments you supply to
send()? Because if send command does not complete using interrupts usually means misconfiguration (something wrong in registers, specific interrupts are disabled in Sn_IMR) or hardware issue.RE: RE: socket.c sendto() ignores SOCK_IO_NONBLOCK flag?
by ghorth ·
Thanks for the quick response!
The sendto() call is from check_DHCPv4_leasedIP() in dhcpv4.c:
I’m guessing from the comments that it’s sending a packet to the DHCP server supplied IP address to check for an IP conflict. So in this case there should be no reply - hence the timeout? I can see how this is normal and required/expected behaviour.
I have a TCP client connection running too (partly copied from loopback_tcpc() in loopback.c), but I see that this uses send() rather than sendto(). This works fine it seems, but then my server application to receive the connection will always be available.
I’m not sure what you mean about interrupts. Should I be using hardware interrupts to a pin on my micro? And therefore I need some ISR to run and do something when the WizNet chip asserts its interrupt output pin?
I’m in the process of trying to split the sendto() function into two, so that I can call a first function to send the data, then repeatedly call a second function which will check the status of the send. Eventually this would return either the SOCKERR_TIMEOUT, or the length of data sent. Crucially though, it would not block, so I’ll probably return BUSY until either SENDOK or TIMEOUT occurs. I’ll see how far I get with this!
RE: socket.c sendto() ignores SOCK_IO_NONBLOCK flag?
by Eugeny ·
No. In the code you provided the chip (and software) is doing sending only. It is SEND command which is not being performed properly, there’s no receive involved.
The code you cited checks for two bits -
Sn_IR_SENDOKandSn_IR_TIMEOUT, and blocks until each of them gets set. Normally SENDOK is the first, informing software that data was sent. In your case it is TIMEOUT, and it means either sending is experiences the problems or Sn_IMR register for this socket has bit SENDOK reset (and therefore SENDOK interrupt does not happen, while SEND command is completed properly). Further research is needed on what value Sn_IMR (as well as IMR in common register block) are having when problem occurs.No, no need for hardware changes, a least for this problem. No MCU IST needed, you have code which, for some reason, does not work as expected, and we must sort it out.
Normally the code you provided does NOT block, sending is performer relatively quickly. In your case something prohibits sending.