I am using the socket interface provided by the ioLibrary_Driver in a non-blocking mode. I have a small problem which I can resolve by changing the code in the library but was wondering if there is another way to solve this.
I call send to send some data via a TCP socket.
I receive a SEND_OK interrupt which I use to notify the caller that the data has been sent successfully.
I then clear this interrupt as I am done with it.
I call send again to send more data via the same TCP socket.
I get a SOCK_BUSY status returned as the sock_is_sending bit corresponding to my socket is set. This bit would be cleared during the call to send if the Sn_IR_SENDOK was set in the sn_IR register but I have already cleared this interrupt so this bit is not set.
My workaround involves a call that clear the sock_is_sending bit corresponding to my socket when the SEND_OK interrupt has happened. This requires modifying the library and I rather not do that. Is there another way?
I don’t understand your words.
First, if you are using the socket.c file in ioLibrary, the SOCK_BUSY state is obtained in case that sock_is_sending is set and the SENDOK interrupt is not set in the Sn_IR register.
Also, our library already clears sock_is_sending if sock_is_sending is set and a SEND_OK interrupt has occurred at send time.
If I have a misunderstanding, let me tell you again.
I got the same problem.
The point is, send() clears sock_is_sending if SEND_OK occurred, ONLY SINCE THE SECOND TIME SEND() IS CALLED! There is no other way to clear sock_is_sending, unless you reopen the socket. But, SEND_OK is cleared by you before the second calling of send() so you never have the sock_is_sending cleared. If you don’t clear SEND_OK interrupt, you won’t get any more interrupt.
It seems modifying lib is the only way, if I want to use interrupt and don’t reopen the socket for each sending…
Maybe the INTLEVEL works? But for various length of data to send, it seems not very practical.
Please enlighten me if there is any other way. Thanks!
I think @tyx interpretation is correct, and it really seems to be a bug in the library. The assumption is that we would close the socket every time, but if the socket keeps open - the whole thing just fails.
Can someone from Wiznet team respond to this and clarify if there is a solution the situation that @tyx described? @becky