mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-22 23:56:13 +01:00
move mark/commit into CommandDistributor::parse()
This commit is contained in:
parent
5d415366d8
commit
9633e77c0a
|
@ -69,13 +69,28 @@ void CommandDistributor::parse(byte clientId,byte * buffer, RingStream * stream
|
|||
clients[clientId]=WITHROTTLE_TYPE;
|
||||
}
|
||||
|
||||
// mark buffer that is sent to parser
|
||||
ring->mark(clientId);
|
||||
|
||||
// When type is known, send the string
|
||||
// to the right parser
|
||||
if (clients[clientId] == COMMAND_TYPE)
|
||||
if (clients[clientId] == COMMAND_TYPE) {
|
||||
DCCEXParser::parse(stream, buffer, ring);
|
||||
else if (clients[clientId] == WITHROTTLE_TYPE)
|
||||
} else if (clients[clientId] == WITHROTTLE_TYPE) {
|
||||
WiThrottle::getThrottle(clientId)->parse(ring, buffer);
|
||||
}
|
||||
|
||||
if (ring->peekTargetMark()!=RingStream::NO_CLIENT) {
|
||||
// The commit call will either write the length bytes
|
||||
// OR rollback to the mark because the reply is empty
|
||||
// or the command generated more output than fits in
|
||||
// the buffer
|
||||
if (!ring->commit()) {
|
||||
DIAG(F("OUTBOUND FULL processing cmd:%s"),buffer);
|
||||
}
|
||||
} else {
|
||||
DIAG(F("CD parse: was alredy committed")); //XXX Could have been committed by broadcastClient?!
|
||||
}
|
||||
}
|
||||
|
||||
void CommandDistributor::forget(byte clientId) {
|
||||
|
@ -111,7 +126,7 @@ void CommandDistributor::broadcastToClients(clientType type) {
|
|||
ring->commit();
|
||||
}
|
||||
}
|
||||
if (ring->peekTargetMark()!=RingStream::NO_CLIENT) {
|
||||
if (ring->peekTargetMark() == RingStream::NO_CLIENT) {
|
||||
//DIAG(F("CD postmark client %d"), rememberClient);
|
||||
ring->mark(rememberClient);
|
||||
}
|
||||
|
|
|
@ -163,9 +163,7 @@ void EthernetInterface::loop()
|
|||
buffer[count] = '\0'; // terminate the string properly
|
||||
if (Diag::ETHERNET) DIAG(F(",count=%d:%e"), socket,buffer);
|
||||
// execute with data going directly back
|
||||
outboundRing->mark(socket);
|
||||
CommandDistributor::parse(socket,buffer,outboundRing);
|
||||
outboundRing->commit();
|
||||
return; // limit the amount of processing that takes place within 1 loop() cycle.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
#define GITHUB_SHA "PORTX-HAL-20220813"
|
||||
#define GITHUB_SHA "PORTX-HAL-20220816"
|
||||
|
|
|
@ -264,10 +264,7 @@ void WifiESP::loop() {
|
|||
cmd[i]=clients[clientId].wifi.read();
|
||||
}
|
||||
cmd[len]=0;
|
||||
outboundRing->mark(clientId);
|
||||
CommandDistributor::parse(clientId,cmd,outboundRing);
|
||||
if (outboundRing->peekTargetMark()!=RingStream::NO_CLIENT)
|
||||
outboundRing->commit();
|
||||
}
|
||||
}
|
||||
} // all clients
|
||||
|
|
|
@ -84,13 +84,7 @@ void WifiInboundHandler::loop1() {
|
|||
cmd[count]=0;
|
||||
if (Diag::WIFI) DIAG(F("%e"),cmd);
|
||||
|
||||
outboundRing->mark(clientId); // remember start of outbound data
|
||||
CommandDistributor::parse(clientId,cmd,outboundRing);
|
||||
// The commit call will either write the lenbgth bytes
|
||||
// OR rollback to the mark because the reply is empty or commend generated more than fits the buffer
|
||||
if (!outboundRing->commit()) {
|
||||
DIAG(F("OUTBOUND FULL processing cmd:%s"),cmd);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user