1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-23 21:01:25 +01:00

lots of diag

This commit is contained in:
Harald Barth 2022-08-15 10:49:56 +02:00
parent 8cff51b913
commit 60d91eef9d
3 changed files with 22 additions and 4 deletions

View File

@ -97,17 +97,24 @@ void CommandDistributor::broadcastToClients(clientType type) {
// If we are broadcasting from a wifi/eth process we need to complete its output // If we are broadcasting from a wifi/eth process we need to complete its output
// before merging broadcasts in the ring, then reinstate it in case // before merging broadcasts in the ring, then reinstate it in case
// the process continues to output to its client. // the process continues to output to its client.
if (ringClient!=NO_CLIENT) ring->commit(); if (ringClient!=NO_CLIENT) {
DIAG(F("CD precommit client %d"), ringClient);
ring->commit();
}
/* loop through ring clients */ /* loop through ring clients */
for (byte clientId=0; clientId<sizeof(clients); clientId++) { for (byte clientId=0; clientId<sizeof(clients); clientId++) {
if (clients[clientId]==type) { if (clients[clientId]==type) {
DIAG(F("CD mark client %d"), clientId);
ring->mark(clientId); ring->mark(clientId);
ring->print(broadcastBufferWriter->getString()); ring->print(broadcastBufferWriter->getString());
DIAG(F("CD commit client %d"), clientId);
ring->commit(); ring->commit();
} }
} }
if (ringClient!=NO_CLIENT) ring->mark(ringClient); if (ringClient!=NO_CLIENT) {
DIAG(F("CD postmark client %d"), ringClient);
ring->mark(ringClient);
}
#endif #endif
} }

View File

@ -143,6 +143,7 @@ int RingStream::freeSpace() {
// mark start of message with client id (0...9) // mark start of message with client id (0...9)
void RingStream::mark(uint8_t b) { void RingStream::mark(uint8_t b) {
DIAG(F("RS mark client %d at %d"), b, _pos_write);
_mark=_pos_write; _mark=_pos_write;
write(b); // client id write(b); // client id
write((uint8_t)0); // count MSB placemarker write((uint8_t)0); // count MSB placemarker
@ -170,6 +171,7 @@ bool RingStream::commit() {
return false; // commit failed return false; // commit failed
} }
if (_count==0) { if (_count==0) {
DIAG(F("RS commit count=0 rewind back to %d"), _mark);
// ignore empty response // ignore empty response
_pos_write=_mark; _pos_write=_mark;
return true; // true=commit ok return true; // true=commit ok
@ -181,6 +183,11 @@ bool RingStream::commit() {
_mark++; _mark++;
if (_mark==_len) _mark=0; if (_mark==_len) _mark=0;
_buffer[_mark]=lowByte(_count); _buffer[_mark]=lowByte(_count);
{ char s[_count+2];
strncpy(s, (const char*)&(_buffer[_mark+1]), _count-2);
s[_count-1]=0;
DIAG(F("RS commit count=%d %s"), _count, s);
}
return true; // commit worked return true; // commit worked
} }
void RingStream::flush() { void RingStream::flush() {

View File

@ -610,10 +610,12 @@ byte WiThrottle::stashClient;
char WiThrottle::stashThrottleChar; char WiThrottle::stashThrottleChar;
void WiThrottle::getLocoCallback(int16_t locoid) { void WiThrottle::getLocoCallback(int16_t locoid) {
DIAG(F("LocoCallback mark client %d"), stashClient);
stashStream->mark(stashClient); stashStream->mark(stashClient);
if (locoid<=0) { if (locoid<=0) {
StringFormatter::send(stashStream,F("HMNo loco found on prog track\n")); StringFormatter::send(stashStream,F("HMNo loco found on prog track\n"));
DIAG(F("LocoCallback commit (noloco)"));
stashStream->commit(); // done here, commit and return stashStream->commit(); // done here, commit and return
return; return;
} }
@ -624,6 +626,7 @@ void WiThrottle::getLocoCallback(int16_t locoid) {
locoid = locoid ^ LONG_ADDR_MARKER; // remove marker bit to get real long addr locoid = locoid ^ LONG_ADDR_MARKER; // remove marker bit to get real long addr
if (locoid <= HIGHEST_SHORT_ADDR ) { // out of range for long addr if (locoid <= HIGHEST_SHORT_ADDR ) { // out of range for long addr
StringFormatter::send(stashStream,F("HMLong addr %d <= %d unsupported\n"), locoid, HIGHEST_SHORT_ADDR); StringFormatter::send(stashStream,F("HMLong addr %d <= %d unsupported\n"), locoid, HIGHEST_SHORT_ADDR);
DIAG(F("LocoCallback commit (error)"));
stashStream->commit(); // done here, commit and return stashStream->commit(); // done here, commit and return
return; return;
} }
@ -637,6 +640,7 @@ void WiThrottle::getLocoCallback(int16_t locoid) {
stashInstance->multithrottle(stashStream, (byte *)addcmd); stashInstance->multithrottle(stashStream, (byte *)addcmd);
TrackManager::setMainPower(POWERMODE::ON); TrackManager::setMainPower(POWERMODE::ON);
TrackManager::setJoin(true); // <1 JOIN> so we can drive loco away TrackManager::setJoin(true); // <1 JOIN> so we can drive loco away
DIAG(F("LocoCallback commit success"));
stashStream->commit(); stashStream->commit();
CommandDistributor::broadcastPower(); CommandDistributor::broadcastPower();