mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-26 17:46:14 +01:00
Compare commits
4 Commits
e328ea5c5d
...
92288603bf
Author | SHA1 | Date | |
---|---|---|---|
|
92288603bf | ||
|
80c8b3ef62 | ||
|
127f3acce5 | ||
|
690c629e6d |
|
@ -30,6 +30,8 @@
|
||||||
#include "WiThrottle.h"
|
#include "WiThrottle.h"
|
||||||
#include "DCCTimer.h"
|
#include "DCCTimer.h"
|
||||||
|
|
||||||
|
extern void looptimer(unsigned long timeout, const FSH* message);
|
||||||
|
|
||||||
EthernetInterface * EthernetInterface::singleton=NULL;
|
EthernetInterface * EthernetInterface::singleton=NULL;
|
||||||
/**
|
/**
|
||||||
* @brief Setup Ethernet Connection
|
* @brief Setup Ethernet Connection
|
||||||
|
@ -125,6 +127,7 @@ void EthernetInterface::loop()
|
||||||
//nothing happened
|
//nothing happened
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
looptimer(8000, F("Ethloop after maintain"));
|
||||||
singleton->loop2();
|
singleton->loop2();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,21 +202,23 @@ 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);
|
||||||
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("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.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
looptimer(8000, F("Ethloop2 after incoming"));
|
||||||
|
|
||||||
// stop any clients which disconnect
|
// stop any clients which disconnect
|
||||||
for (int socket = 0; socket<MAX_SOCK_NUM; socket++) {
|
for (int socket = 0; socket<MAX_SOCK_NUM; socket++) {
|
||||||
|
@ -223,8 +228,10 @@ void EthernetInterface::loop2() {
|
||||||
if (Diag::ETHERNET) DIAG(F("Ethernet: disconnect %d "), socket);
|
if (Diag::ETHERNET) DIAG(F("Ethernet: disconnect %d "), socket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
looptimer(8000, F("Ethloop after disconnectcheck"));
|
||||||
|
|
||||||
WiThrottle::loop(outboundRing);
|
WiThrottle::loop(outboundRing);
|
||||||
|
looptimer(8000, F("Ethloop after Withrottleloop"));
|
||||||
|
|
||||||
// handle at most 1 outbound transmission
|
// handle at most 1 outbound transmission
|
||||||
int socketOut=outboundRing->read();
|
int socketOut=outboundRing->read();
|
||||||
|
@ -233,8 +240,17 @@ void EthernetInterface::loop2() {
|
||||||
} else if (socketOut >= 0) {
|
} else if (socketOut >= 0) {
|
||||||
int count=outboundRing->count();
|
int count=outboundRing->count();
|
||||||
if (Diag::ETHERNET) DIAG(F("Ethernet reply socket=%d, count=:%d"), socketOut,count);
|
if (Diag::ETHERNET) DIAG(F("Ethernet reply socket=%d, count=:%d"), socketOut,count);
|
||||||
for(;count>0;count--) clients[socketOut].write(outboundRing->read());
|
{
|
||||||
|
char tmpbuf[count+1]; // one extra for '\0'
|
||||||
|
for(int i=0;i<count;i++) {
|
||||||
|
tmpbuf[i] = outboundRing->read();
|
||||||
|
}
|
||||||
|
tmpbuf[count]=0;
|
||||||
|
clients[socketOut].write(tmpbuf,count);
|
||||||
|
}
|
||||||
clients[socketOut].flush(); //maybe
|
clients[socketOut].flush(); //maybe
|
||||||
}
|
}
|
||||||
|
looptimer(8000, F("Ethloop after outbound"));
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
#define GITHUB_SHA "devel-fozzie-202408080852Z"
|
#define GITHUB_SHA "devel-fozzie-202408090945Z"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user