Hello,
I use EK-TM4C1294XL, and I want to make a stable TCP connection between the microcontroller and a computer.
I use Energia's example "TelnetClient" to do it, when the microcontroller is the client and the computer is the server using Telnet.
I succeed to make the connection, but there are a lot of problems with it.
1. Sometimes (I can't diagnose when it happens) the controller enter to infinite loop at tcp_out.c line 937:
for (; useg->next != NULL; useg = useg->next);
When it happens, useg == useg->next.
I try to solve it by change the row to:
for (; (useg->next != NULL)|(useg->next == useg); useg = useg->next);
It seems that the problem solved, but I don't know how it affect on other functions.
2. Sometimes, when i close the computer's listener, the function client.connect don't recognize that there is no connection. So, when the listener reurn, the microcontroller don't retry to connect.
3. Sometimes, the software enter to infinite loop at EthernetClient.cpp at line 216 (in EthernetClient::write(const uint8_t *buf, size_t size)).
i=0, size = 1, and its values don't change in the loop:
// Attempt to write in 1024-byte increments. while (i < size) { inc = (size - i) < 1024 ? size - i : 1024; err_t err = tcp_write(cpcb, buf + i, inc, TCP_WRITE_FLAG_COPY); if (err != ERR_MEM) { // Keep enqueueing the lwIP buffer until it's full... i += inc; stuffed_buffer = false; } else { if (!stuffed_buffer) { // Buffer full; force output if (cs->mode) tcp_output(cpcb); stuffed_buffer = true; } else { delay(1); // else wait a little bit for lwIP to flush its buffers } } }