From 18695888ddebe513b00467f29cef83bcbb34e97d Mon Sep 17 00:00:00 2001 From: Asbelos Date: Tue, 7 Dec 2021 00:24:48 +0000 Subject: [PATCH] Fixing broadcast --- CommandDistributor.cpp | 12 +++++------- DCCEXParser.cpp | 1 + SerialManager.cpp | 4 ++-- Turnouts.cpp | 3 +-- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/CommandDistributor.cpp b/CommandDistributor.cpp index 730d2c7..db93763 100644 --- a/CommandDistributor.cpp +++ b/CommandDistributor.cpp @@ -69,12 +69,7 @@ void CommandDistributor::broadcast() { for (byte clientId=0; clientIdmark(clientId); - - if (clients[clientId]==COMMAND_TYPE) broadcastBufferWriter->printBuffer(ring); - else if (clients[clientId]==WITHROTTLE_TYPE) { - // TODO... withrottle broadcasts? - } - + broadcastBufferWriter->printBuffer(ring); ring->commit(); } if (ringClient!=NO_CLIENT) ring->mark(ringClient); @@ -90,7 +85,10 @@ void CommandDistributor::broadcastSensor(int16_t id, bool on ) { void CommandDistributor::broadcastTurnout(int16_t id, bool isClosed ) { // For DCC++ classic compatibility, state reported to JMRI is 1 for thrown and 0 for closed; - StringFormatter::send(broadcastBufferWriter,F("\n"),id, !isClosed); + // The string below contains serial and Withrottle protocols which should + // be safe for both types. + StringFormatter::send(broadcastBufferWriter, + F("\nPTA%c%d\n"),id, !isClosed, isClosed?'2':'4', id); broadcast(); } diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index fdf3d17..e89e041 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -229,6 +229,7 @@ void DCCEXParser::setAtCommandCallback(AT_COMMAND_CALLBACK callback) // Parse an F() string void DCCEXParser::parse(const FSH * cmd) { + DIAG(F("SETUP(\"%S\")"),cmd); int size=strlen_P((char *)cmd)+1; char buffer[size]; strcpy_P(buffer,(char *)cmd); diff --git a/SerialManager.cpp b/SerialManager.cpp index 3c43289..1957dcc 100644 --- a/SerialManager.cpp +++ b/SerialManager.cpp @@ -44,14 +44,14 @@ void SerialManager::init() { } void SerialManager::broadcast(RingStream * ring) { - for (SerialManager * s;s;s=s->next) s->broadcast2(ring); + for (SerialManager * s=first;s;s=s->next) s->broadcast2(ring); } void SerialManager::broadcast2(RingStream * ring) { ring->printBuffer(serial); } void SerialManager::loop() { - for (SerialManager * s;s;s=s->next) s->loop2(); + for (SerialManager * s=first;s;s=s->next) s->loop2(); } void SerialManager::loop2() { diff --git a/Turnouts.cpp b/Turnouts.cpp index e6b7422..3b03b8d 100644 --- a/Turnouts.cpp +++ b/Turnouts.cpp @@ -136,8 +136,7 @@ bool ok = tt->setClosedInternal(closeFlag); if (ok) { - turnoutlistHash++; // let withrottle know something changed - + #ifndef DISABLE_EEPROM // Write byte containing new closed/thrown state to EEPROM if required. Note that eepromAddress // is always zero for LCN turnouts.