1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-22 23:56:13 +01:00

do not available, just try to read

This commit is contained in:
Harald Barth 2024-08-09 12:01:53 +02:00
parent 80c8b3ef62
commit 92288603bf

View File

@ -202,18 +202,18 @@ void EthernetInterface::loop2() {
// check for incoming data from all possible clients // check for incoming data from all possible clients
for (byte socket = 0; socket < MAX_SOCK_NUM; socket++) for (byte socket = 0; socket < MAX_SOCK_NUM; socket++)
{ {
if (clients[socket]) { if (clients[socket]) {
int available=clients[socket].available(); // read bytes from a client
if (available > 0) { int count = clients[socket].read(buffer, MAX_ETH_BUFFER);
if (Diag::ETHERNET) DIAG(F("Ethernet: available socket=%d,avail=%d"), socket, available); looptimer(8000, F("Ethloop2 read"));
// read bytes from a client if (count > 0) {
int count = clients[socket].read(buffer, MAX_ETH_BUFFER); if (Diag::ETHERNET) DIAG(F("Ethernet: available socket=%d,count=%d"), socket, count);
looptimer(8000, F("Ethloop2 read"));
buffer[count] = '\0'; // terminate the string properly buffer[count] = '\0'; // terminate the string properly
if (Diag::ETHERNET) DIAG(F(",count=%d:%e"), count, buffer); if (Diag::ETHERNET) DIAG(F("buffer:%e"), buffer);
// execute with data going directly back // execute with data going directly back
CommandDistributor::parse(socket,buffer,outboundRing); CommandDistributor::parse(socket,buffer,outboundRing);
looptimer(2000, F("Ethloop2 parse"));
return; // limit the amount of processing that takes place within 1 loop() cycle. return; // limit the amount of processing that takes place within 1 loop() cycle.
} }
} }