Closed rcamprodon closed 3 years ago
what is on server side?
Either a terminal program (YAT) i server mode, a Lazarus dummy server I wrote, or the real device which is controlled (STM32F4)with my server side software which is working well with desktop applications.
I did a very basic test with the bare Arduino IDE, and sending in a timed loop (say 10 messages/second) failed after a random amount of loops. Only worked after adding the client.write((byte)0);
add Ethernet.maintain() to loop() so the library can handle the network traffic. because you don't call the library functions frequently enough to handle everything. write(0) was one more call in which the library can handle things
I already tested this. I forgot to mention. I'll try to substitute write(0) for maintain().
I already tested this. I forgot to mention. I'll try to substitute write(0) for maintain().
call maintain in every loop, not in the if
write calls 'tick' repeatedly until timeout if it can't allocate space . maintain calls tick only once
Hi: I have a strange behaviour of EthernetClient client.write("somestring") returning zero bytes after a random number of calls. My application is running on a Nano Every and a Enc28J60 shield (lots of code ommited for clarity):
When a change is read in the encoder i send a message like this:
After several sendCmd I get a return SMALLER than the length of the buffer sent (strbuf, which is a big enough char array) and the next one is zero, forever. I cannot recover from this fail. The client.write("string") returns after the 2000ms timeout without sending data. I traced the error up to Enc28J60Network::allocBlock(UIP_SOCKET_DATALEN); which, apparently, returns NOBLOCK. The only solution is to continuously client.write((byte)0); on the main loop, which is not really elegant and very brute-force. I also tried to check client.availableForWrite() before sending a message, but no luck, it is always correct.
Any idea?