1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-23 16:16:13 +01:00

Compare commits

..

5 Commits

Author SHA1 Message Date
Harald Barth
cfd04ad5c7 version 2024-04-02 00:03:07 +02:00
Harald Barth
501238d894 ESP32 Bugfix: Uninitialized stack variable. Will bite you with infinite loop if no tracks are defined 2024-04-02 00:02:09 +02:00
Harald Barth
dd2a916c83 version 2024-04-01 22:13:03 +02:00
Harald Barth
d21aef533b Make Z21 diag selectable from DCCEXParser 2024-04-01 22:12:05 +02:00
Harald Barth
7ebbe8bed2 ifdef NetworkClientUDP.h as well 2024-04-01 21:02:20 +02:00
8 changed files with 45 additions and 12 deletions

View File

@ -1117,6 +1117,21 @@ bool DCCEXParser::parseD(Print *stream, int16_t params, int16_t p[])
return true; return true;
#ifdef HAS_ENOUGH_MEMORY #ifdef HAS_ENOUGH_MEMORY
#ifdef Z21_PROTOCOL
case "Z21THROTTLE"_hk: // <D Z21THROTTLE ON/OFF>
case "Z21THR"_hk: // <D Z21THR ON/OFF>
Diag::Z21THROTTLE = onOff;
return true;
case "Z21THROTTLEVERBOSE"_hk: // <D Z21THROTTLEVERBOSE ON/OFF>
case "Z21THRV"_hk: // <D Z21THV ON/OFF>
Diag::Z21THROTTLEVERBOSE = onOff;
return true;
case "Z21THROTTLEDATA"_hk: // <D Z21THROTTLEDATA ON/OFF>
case "Z21THRD"_hk: // <D Z21THD ON/OFF>
Diag::Z21THROTTLEDATA = onOff;
return true;
#endif // Z21_PROTOCOL
case "WIFI"_hk: // <D WIFI ON/OFF> case "WIFI"_hk: // <D WIFI ON/OFF>
Diag::WIFI = onOff; Diag::WIFI = onOff;
return true; return true;

View File

@ -294,7 +294,7 @@ void DCCWaveform::schedulePacket(const byte buffer[], byte byteCount, byte repea
// The resets will be zero not only now but as well repeats packets into the future // The resets will be zero not only now but as well repeats packets into the future
clearResets(repeats+1); clearResets(repeats+1);
{ {
int ret; int ret = 0;
do { do {
if(isMainTrack) { if(isMainTrack) {
if (rmtMainChannel != NULL) if (rmtMainChannel != NULL)

View File

@ -1 +1 @@
#define GITHUB_SHA "devel-z21-202404011058Z" #define GITHUB_SHA "devel-z21-202404012202Z"

View File

@ -17,6 +17,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with CommandStation. If not, see <https://www.gnu.org/licenses/>. * along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
*/ */
#ifdef Z21_PROTOCOL
#include <WiFi.h> #include <WiFi.h>
#include <WiFiClient.h> #include <WiFiClient.h>
@ -35,3 +36,4 @@ public:
static WiFiUDP client; static WiFiUDP client;
}; };
#endif

View File

@ -25,9 +25,9 @@ bool Diag::ACK=false;
bool Diag::CMD=false; bool Diag::CMD=false;
bool Diag::WIFI=false; bool Diag::WIFI=false;
bool Diag::WITHROTTLE=false; bool Diag::WITHROTTLE=false;
bool Diag::Z21THROTTLE=true; bool Diag::Z21THROTTLE=false;
bool Diag::Z21THROTTLEVERBOSE=true; bool Diag::Z21THROTTLEVERBOSE=false;
bool Diag::Z21THROTTLEDATA=true; bool Diag::Z21THROTTLEDATA=false;
bool Diag::ETHERNET=false; bool Diag::ETHERNET=false;
bool Diag::LCN=false; bool Diag::LCN=false;

View File

@ -123,7 +123,6 @@
return true; return true;
} }
#define DIAG_IO
// Static setClosed function is invoked from close(), throw() etc. to perform the // Static setClosed function is invoked from close(), throw() etc. to perform the
// common parts of the turnout operation. Code which is specific to a turnout // common parts of the turnout operation. Code which is specific to a turnout
// type should be placed in the virtual function setClosedInternal(bool) which is // type should be placed in the virtual function setClosedInternal(bool) which is

View File

@ -707,27 +707,43 @@ bool Z21Throttle::parse(byte *networkPacket, int len) {
int lengthData = GETINT16(p); int lengthData = GETINT16(p);
l -= lengthData; l -= lengthData;
// This is not an error, just several X bus packets in one UDP packet
if (Diag::Z21THROTTLEDATA) // only care if diag is on
if (p == networkPacket && lengthData != len) { if (p == networkPacket && lengthData != len) {
diagPacket(networkPacket, len); diagPacket(networkPacket, len);
} }
// This is a client error, report always
if (l < 0) { if (l < 0) {
DIAG(F("ERROR: Xbus data exceeds UDP packet size: l < 0 pos=%d, l=%d"), p-networkPacket, l); DIAG(F("ERROR: Xbus data exceeds UDP packet size: l < 0 pos=%d, l=%d"), p-networkPacket, l);
diagPacket(p, len); diagPacket(p, len);
return false; return false;
} }
// This is kinda client error but not harmful
// Report if diag and we are done with parsing this UDP packet
if (l > 0 && lengthData < 4) { if (l > 0 && lengthData < 4) {
// The client did send a too long UDP packet which was not filled with X bus packet(s)
// The Z21 App does this sometimes
if (Diag::Z21THROTTLEDATA) {
DIAG(F("WARNING: Xbus data does not fill UDP packet size: l > 0 pos=%d, l=%d, lengthData=%d"), DIAG(F("WARNING: Xbus data does not fill UDP packet size: l > 0 pos=%d, l=%d, lengthData=%d"),
p-networkPacket, l, lengthData); p-networkPacket, l, lengthData);
diagPacket(p, len); diagPacket(p, len);
}
return true; return true;
} }
// length of the data = total length - length of length (!) - length of header // length of the data = total length - length of length (!) - length of header
// Error, this should not happen
lengthData -= 4; lengthData -= 4;
if (lengthData < 0) { if (lengthData < 0) {
DIAG(F("ERROR: lengthData < 0 SHOULD NOT GET HERE")); DIAG(F("ERROR: lengthData < 0 SHOULD NOT GET HERE"));
diagPacket(networkPacket, len); diagPacket(networkPacket, len);
return false; return false;
} }
// All checks done, start looking at packet content
p += 2; p += 2;
Header = GETINT16(p); Header = GETINT16(p);
p += 2; p += 2;

View File

@ -4,6 +4,7 @@
#include "StringFormatter.h" #include "StringFormatter.h"
#define VERSION "5.X.Y" #define VERSION "5.X.Y"
// Make Z21 diag selectable from DCCEXParser
// Z21 error fix for turnout feedback // Z21 error fix for turnout feedback
// Z21 add turnout and sensor broadcasts // Z21 add turnout and sensor broadcasts
// Z21: report the (unchanged) loco mode back after every attempted change // Z21: report the (unchanged) loco mode back after every attempted change