mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-23 16:16:13 +01:00
Compare commits
5 Commits
fdf6269477
...
6cdde5d3c6
Author | SHA1 | Date | |
---|---|---|---|
|
6cdde5d3c6 | ||
|
60fb30c0a7 | ||
|
dd5ab6c7fa | ||
|
4d3dffacb4 | ||
|
08c89f743f |
|
@ -213,21 +213,24 @@ void EthernetInterface::loop2() {
|
||||||
if (client)
|
if (client)
|
||||||
{
|
{
|
||||||
byte socket;
|
byte socket;
|
||||||
for (socket = 0; socket < MAX_SOCK_NUM; socket++)
|
bool sockfound = false;
|
||||||
{
|
for (socket = 0; socket < MAX_SOCK_NUM; socket++) {
|
||||||
if (clients[socket]) {
|
if (clients[socket] && (clients[socket] == client)) {
|
||||||
if (clients[socket] == client)
|
sockfound = true;
|
||||||
break;
|
if (Diag::ETHERNET) DIAG(F("Ethernet: Old client socket %d"),socket);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else //if (!clients[socket])
|
}
|
||||||
{
|
if (!sockfound) { // new client
|
||||||
if (Diag::ETHERNET) DIAG(F("Ethernet: New client "));
|
for (socket = 0; socket < MAX_SOCK_NUM; socket++) {
|
||||||
// On accept() the EthernetServer doesn't track the client anymore
|
if (!clients[socket]) {
|
||||||
// so we store it in our client array
|
// On accept() the EthernetServer doesn't track the client anymore
|
||||||
if (Diag::ETHERNET) DIAG(F("Socket %d"),socket);
|
// so we store it in our client array
|
||||||
clients[socket] = client;
|
clients[socket] = client;
|
||||||
break;
|
if (Diag::ETHERNET) DIAG(F("Ethernet: New client socket %d"),socket);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (socket==MAX_SOCK_NUM) DIAG(F("new Ethernet OVERFLOW"));
|
if (socket==MAX_SOCK_NUM) DIAG(F("new Ethernet OVERFLOW"));
|
||||||
}
|
}
|
||||||
|
@ -235,29 +238,28 @@ 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]) {
|
||||||
|
if (!clients[socket].connected()) { // stop any clients which disconnect
|
||||||
|
CommandDistributor::forget(socket);
|
||||||
|
clients[socket].stop();
|
||||||
|
clients[socket]=NULL;
|
||||||
|
//if (Diag::ETHERNET)
|
||||||
|
DIAG(F("Ethernet: disconnect %d "), socket);
|
||||||
|
return; // Trick: So that we do not continue in this loop with client that is NULL
|
||||||
|
}
|
||||||
|
|
||||||
int available=clients[socket].available();
|
int available=clients[socket].available();
|
||||||
if (available > 0) {
|
if (available > 0) {
|
||||||
if (Diag::ETHERNET) DIAG(F("Ethernet: available socket=%d,avail=%d"), socket, available);
|
if (Diag::ETHERNET) DIAG(F("Ethernet: available socket=%d,avail=%d"), socket, available);
|
||||||
// read bytes from a client
|
// read bytes from a client
|
||||||
int count = clients[socket].read(buffer, MAX_ETH_BUFFER);
|
int count = clients[socket].read(buffer, MAX_ETH_BUFFER);
|
||||||
buffer[count] = '\0'; // terminate the string properly
|
buffer[count] = '\0'; // terminate the string properly
|
||||||
if (Diag::ETHERNET) DIAG(F(",count=%d:%e"), socket,buffer);
|
if (Diag::ETHERNET) DIAG(F(",count=%d:%e"), socket,buffer);
|
||||||
// execute with data going directly back
|
// execute with data going directly back
|
||||||
CommandDistributor::parse(socket,buffer,outboundRing);
|
CommandDistributor::parse(socket,buffer,outboundRing);
|
||||||
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.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// stop any clients which disconnect
|
|
||||||
for (int socket = 0; socket<MAX_SOCK_NUM; socket++) {
|
|
||||||
if (clients[socket] && !clients[socket].connected()) {
|
|
||||||
clients[socket].stop();
|
|
||||||
CommandDistributor::forget(socket);
|
|
||||||
if (Diag::ETHERNET) DIAG(F("Ethernet: disconnect %d "), socket);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WiThrottle::loop(outboundRing);
|
WiThrottle::loop(outboundRing);
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
#define GITHUB_SHA "devel-202401202116Z"
|
#define GITHUB_SHA "devel-stm32EC 202401280047Z"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user