1
0
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:
Harald Barth 2022-08-16 19:22:19 +02:00
parent 5d415366d8
commit 9633e77c0a
6 changed files with 20 additions and 16 deletions

View File

@ -69,13 +69,28 @@ void CommandDistributor::parse(byte clientId,byte * buffer, RingStream * stream
clients[clientId]=WITHROTTLE_TYPE; clients[clientId]=WITHROTTLE_TYPE;
} }
// mark buffer that is sent to parser
ring->mark(clientId);
// When type is known, send the string // When type is known, send the string
// to the right parser // to the right parser
if (clients[clientId] == COMMAND_TYPE) if (clients[clientId] == COMMAND_TYPE) {
DCCEXParser::parse(stream, buffer, ring); DCCEXParser::parse(stream, buffer, ring);
else if (clients[clientId] == WITHROTTLE_TYPE) } else if (clients[clientId] == WITHROTTLE_TYPE) {
WiThrottle::getThrottle(clientId)->parse(ring, buffer); 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) { void CommandDistributor::forget(byte clientId) {
@ -111,7 +126,7 @@ void CommandDistributor::broadcastToClients(clientType type) {
ring->commit(); ring->commit();
} }
} }
if (ring->peekTargetMark()!=RingStream::NO_CLIENT) { if (ring->peekTargetMark() == RingStream::NO_CLIENT) {
//DIAG(F("CD postmark client %d"), rememberClient); //DIAG(F("CD postmark client %d"), rememberClient);
ring->mark(rememberClient); ring->mark(rememberClient);
} }

View File

@ -163,9 +163,7 @@ void EthernetInterface::loop()
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
outboundRing->mark(socket);
CommandDistributor::parse(socket,buffer,outboundRing); CommandDistributor::parse(socket,buffer,outboundRing);
outboundRing->commit();
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.
} }
} }

View File

@ -1 +1 @@
#define GITHUB_SHA "PORTX-HAL-20220813" #define GITHUB_SHA "PORTX-HAL-20220816"

View File

@ -264,10 +264,7 @@ void WifiESP::loop() {
cmd[i]=clients[clientId].wifi.read(); cmd[i]=clients[clientId].wifi.read();
} }
cmd[len]=0; cmd[len]=0;
outboundRing->mark(clientId);
CommandDistributor::parse(clientId,cmd,outboundRing); CommandDistributor::parse(clientId,cmd,outboundRing);
if (outboundRing->peekTargetMark()!=RingStream::NO_CLIENT)
outboundRing->commit();
} }
} }
} // all clients } // all clients

View File

@ -84,13 +84,7 @@ void WifiInboundHandler::loop1() {
cmd[count]=0; cmd[count]=0;
if (Diag::WIFI) DIAG(F("%e"),cmd); if (Diag::WIFI) DIAG(F("%e"),cmd);
outboundRing->mark(clientId); // remember start of outbound data
CommandDistributor::parse(clientId,cmd,outboundRing); 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; return;
} }
} }

View File

@ -4,7 +4,7 @@
#include "StringFormatter.h" #include "StringFormatter.h"
#define VERSION "4.2.1 rc1" #define VERSION "4.2.2 rc1"
// 4.2.1 ESP32 alpha // 4.2.1 ESP32 alpha
// Ready for alpha test on ESP32. Track switching with <=> untested // Ready for alpha test on ESP32. Track switching with <=> untested
// Send DCC signal on MAIN // Send DCC signal on MAIN