diff --git a/CVReader.ino b/CVReader.ino
index 9b2edd8..57f69cd 100644
--- a/CVReader.ino
+++ b/CVReader.ino
@@ -1,3 +1,24 @@
+/*
+ * © 2020, Chris Harlow. All rights reserved.
+ *
+ * This file is part of Asbelos DCC API
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * It is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CommandStation. If not, see .
+ */
+
+
+
#include "DCC.h"
#include "DIAG.h"
#include "DCCEXParser.h"
diff --git a/DCC.cpp b/DCC.cpp
index 7f2f88e..7051d35 100644
--- a/DCC.cpp
+++ b/DCC.cpp
@@ -1,3 +1,21 @@
+/*
+ * © 2020, Chris Harlow. All rights reserved.
+ *
+ * This file is part of Asbelos DCC API
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * It is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CommandStation. If not, see .
+ */
#include "DCC.h"
#include "DCCWaveform.h"
#include "DIAG.h"
diff --git a/DCC.h b/DCC.h
index b7d1a9b..9089a5f 100644
--- a/DCC.h
+++ b/DCC.h
@@ -1,3 +1,21 @@
+/*
+ * © 2020, Chris Harlow. All rights reserved.
+ *
+ * This file is part of Asbelos DCC API
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * It is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CommandStation. If not, see .
+ */
#ifndef DCC_h
#define DCC_h
#include
diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp
index f96cec8..f0991c9 100644
--- a/DCCEXParser.cpp
+++ b/DCCEXParser.cpp
@@ -1,3 +1,21 @@
+/*
+ * © 2020, Chris Harlow. All rights reserved.
+ *
+ * This file is part of Asbelos DCC API
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * It is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CommandStation. If not, see .
+ */
#include "StringFormatter.h"
#include "DCCEXParser.h"
#include "DCC.h"
diff --git a/DCCEXParser.h b/DCCEXParser.h
index 9408de9..71d9cc8 100644
--- a/DCCEXParser.h
+++ b/DCCEXParser.h
@@ -1,3 +1,21 @@
+/*
+ * © 2020, Chris Harlow. All rights reserved.
+ *
+ * This file is part of Asbelos DCC API
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * It is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CommandStation. If not, see .
+ */
#ifndef DCCEXParser_h
#define DCCEXParser_h
#include
diff --git a/DCCWaveform.cpp b/DCCWaveform.cpp
index 6081132..0613eee 100644
--- a/DCCWaveform.cpp
+++ b/DCCWaveform.cpp
@@ -1,3 +1,21 @@
+/*
+ * © 2020, Chris Harlow. All rights reserved.
+ *
+ * This file is part of Asbelos DCC API
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * It is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CommandStation. If not, see .
+ */
#include
#include "Hardware.h"
#include "DCCWaveform.h"
@@ -140,8 +158,11 @@ bool DCCWaveform::interrupt1() {
state = 0;
break;
}
- // ACK check is prog track only
+
+ // ACK check is prog track only and will only be checked if
+ // this is not case(0) which needs relatively expensive packet change code to be called.
if (ackPending) checkAck();
+
return false;
}
@@ -190,7 +211,11 @@ void DCCWaveform::interrupt2() {
if (sentResetsSincePacket<250) sentResetsSincePacket++;
}
}
+<<<<<<< HEAD
}
+=======
+ }
+>>>>>>> master
}
@@ -255,7 +280,7 @@ void DCCWaveform::checkAck() {
lastCurrent=Hardware::getCurrentRaw(false);
if (lastCurrent > ackMaxCurrent) ackMaxCurrent=lastCurrent;
- // An ACK is a pulse lasting between 4.5 and 8.5 mSecs (refer @haba)
+ // An ACK is a pulse lasting between MIN_ACK_PULSE_DURATION and MAX_ACK_PULSE_DURATION uSecs (refer @haba)
if (lastCurrent>ackThreshold) {
if (ackPulseStart==0) ackPulseStart=micros(); // leading edge of pulse detected
@@ -267,8 +292,13 @@ void DCCWaveform::checkAck() {
// detected trailing edge of pulse
ackPulseDuration=micros()-ackPulseStart;
+<<<<<<< HEAD
if (ackPulseDuration>3000 && ackPulseDuration<8500) {
+=======
+
+ if (ackPulseDuration>=MIN_ACK_PULSE_DURATION && ackPulseDuration<=MAX_ACK_PULSE_DURATION) {
+>>>>>>> master
ackCheckDuration=millis()-ackCheckStart;
ackDetected=true;
ackPending=false;
diff --git a/DCCWaveform.h b/DCCWaveform.h
index a42960a..537a05b 100644
--- a/DCCWaveform.h
+++ b/DCCWaveform.h
@@ -1,3 +1,21 @@
+/*
+ * © 2020, Chris Harlow. All rights reserved.
+ *
+ * This file is part of Asbelos DCC API
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * It is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CommandStation. If not, see .
+ */
#ifndef DCCWaveform_h
#define DCCWaveform_h
#include "Config.h"
@@ -6,7 +24,9 @@ const int POWER_SAMPLE_ON_WAIT = 100;
const int POWER_SAMPLE_OFF_WAIT = 1000;
const int POWER_SAMPLE_OVERLOAD_WAIT = 4000;
-
+const int MIN_ACK_PULSE_DURATION = 3000;
+const int MAX_ACK_PULSE_DURATION = 8500;
+
const int PREAMBLE_BITS_MAIN = 20;
const int PREAMBLE_BITS_PROG = 22;
diff --git a/DIAG.h b/DIAG.h
index 9fe8fd3..a00217c 100644
--- a/DIAG.h
+++ b/DIAG.h
@@ -1,3 +1,21 @@
+/*
+ * © 2020, Chris Harlow. All rights reserved.
+ *
+ * This file is part of Asbelos DCC API
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * It is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CommandStation. If not, see .
+ */
#ifndef DIAG_h
#define DIAG_h
diff --git a/EEStore.cpp b/EEStore.cpp
index fb052c9..f52d1a1 100644
--- a/EEStore.cpp
+++ b/EEStore.cpp
@@ -73,4 +73,4 @@ int EEStore::pointer(){
///////////////////////////////////////////////////////////////////////////////
EEStore *EEStore::eeStore=NULL;
-int EEStore::eeAddress=0;
\ No newline at end of file
+int EEStore::eeAddress=0;
diff --git a/EEStore.h b/EEStore.h
index c08fa0f..250d3d7 100644
--- a/EEStore.h
+++ b/EEStore.h
@@ -31,4 +31,4 @@ struct EEStore{
static void clear();
};
-#endif
\ No newline at end of file
+#endif
diff --git a/HTTPParser.cpp b/HTTPParser.cpp
index c3b7617..2d732e8 100644
--- a/HTTPParser.cpp
+++ b/HTTPParser.cpp
@@ -1,3 +1,21 @@
+/*
+ * © 2020, Chris Harlow. All rights reserved.
+ *
+ * This file is part of Asbelos DCC API
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * It is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CommandStation. If not, see .
+ */
#include "HTTPParser.h"
#include "StringFormatter.h"
diff --git a/HTTPParser.h b/HTTPParser.h
index 655b3ba..a1bfdbb 100644
--- a/HTTPParser.h
+++ b/HTTPParser.h
@@ -1,3 +1,21 @@
+/*
+ * © 2020, Chris Harlow. All rights reserved.
+ *
+ * This file is part of Asbelos DCC API
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * It is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CommandStation. If not, see .
+ */
#ifndef HTTPParser_h
#define HTTPParser_h
#include
diff --git a/Hardware.cpp b/Hardware.cpp
index 7643f32..336baeb 100644
--- a/Hardware.cpp
+++ b/Hardware.cpp
@@ -1,3 +1,21 @@
+/*
+ * © 2020, Chris Harlow. All rights reserved.
+ *
+ * This file is part of Asbelos DCC API
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * It is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CommandStation. If not, see .
+ */
#include
#include // use IDE menu Tools..Manage Libraries to locate and install TimerOne
#include "avdweb_AnalogReadFast.h"
diff --git a/Hardware.h b/Hardware.h
index 9f8bd0e..47a14d3 100644
--- a/Hardware.h
+++ b/Hardware.h
@@ -1,3 +1,21 @@
+/*
+ * © 2020, Chris Harlow. All rights reserved.
+ *
+ * This file is part of Asbelos DCC API
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * It is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CommandStation. If not, see .
+ */
#ifndef Hardware_h
#define Hardware_h
// Virtualised hardware Interface
diff --git a/Outputs.cpp b/Outputs.cpp
index 5675ae2..744b066 100644
--- a/Outputs.cpp
+++ b/Outputs.cpp
@@ -1,3 +1,21 @@
+/*
+ * © 2020, Chris Harlow. All rights reserved.
+ *
+ * This file is part of Asbelos DCC API
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * It is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CommandStation. If not, see .
+ */
/**********************************************************************
DCC++ BASE STATION supports optional OUTPUT control of any unused Arduino Pins for custom purposes.
diff --git a/Outputs.h b/Outputs.h
index 1b538d8..f46c34e 100644
--- a/Outputs.h
+++ b/Outputs.h
@@ -1,3 +1,21 @@
+/*
+ * © 2020, Chris Harlow. All rights reserved.
+ *
+ * This file is part of Asbelos DCC API
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * It is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CommandStation. If not, see .
+ */
#ifndef Outputs_h
#define Outputs_h
diff --git a/Sensors.cpp b/Sensors.cpp
index b406ea0..3423fbe 100644
--- a/Sensors.cpp
+++ b/Sensors.cpp
@@ -1,3 +1,21 @@
+/*
+ * © 2020, Chris Harlow. All rights reserved.
+ *
+ * This file is part of Asbelos DCC API
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * It is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CommandStation. If not, see .
+ */
/**********************************************************************
DCC++ BASE STATION supports Sensor inputs that can be connected to any Arduino Pin
diff --git a/Sensors.h b/Sensors.h
index 8104876..8bb44fc 100644
--- a/Sensors.h
+++ b/Sensors.h
@@ -1,3 +1,21 @@
+/*
+ * © 2020, Chris Harlow. All rights reserved.
+ *
+ * This file is part of Asbelos DCC API
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * It is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CommandStation. If not, see .
+ */
#ifndef Sensor_h
#define Sensor_h
diff --git a/StringFormatter.cpp b/StringFormatter.cpp
index cab55b5..29ae772 100644
--- a/StringFormatter.cpp
+++ b/StringFormatter.cpp
@@ -1,3 +1,21 @@
+/*
+ * © 2020, Chris Harlow. All rights reserved.
+ *
+ * This file is part of Asbelos DCC API
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * It is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CommandStation. If not, see .
+ */
#include "StringFormatter.h"
#include
@@ -29,6 +47,8 @@ void StringFormatter::send2(Print & stream,const __FlashStringHelper* format, va
case '%': stream.print('%'); break;
case 'c': stream.print((char) va_arg(args, int)); break;
case 's': stream.print(va_arg(args, char*)); break;
+ case 'e': printEscapes(stream,va_arg(args, char*)); break;
+ case 'E': printEscapes(stream,(const __FlashStringHelper*)va_arg(args, char*)); break;
case 'S': stream.print((const __FlashStringHelper*)va_arg(args, char*)); break;
case 'd': stream.print(va_arg(args, int), DEC); break;
case 'b': stream.print(va_arg(args, int), BIN); break;
@@ -39,3 +59,30 @@ void StringFormatter::send2(Print & stream,const __FlashStringHelper* format, va
}
va_end(args);
}
+
+void StringFormatter::printEscapes(Print & stream, char * input) {
+ for(int i=0; ; ++i) {
+ char c=input[i];
+ printEscape(stream,c);
+ if (c=='\0') return;
+ }
+}
+void StringFormatter::printEscapes(Print & stream, const __FlashStringHelper* input) {
+ char* flash=(char*)input;
+ for(int i=0; ; ++i) {
+ char c=pgm_read_byte_near(flash+i);
+ printEscape(stream,c);
+ if (c=='\0') return;
+ }
+}
+void StringFormatter::printEscape(Print & stream, char c) {
+ switch(c) {
+ case '\n': stream.print(F("\\n")); break;
+ case '\r': stream.print(F("\\r")); break;
+ case '\0': stream.print(F("\\0")); return;
+ case '\t': stream.print(F("\\t")); break;
+ case '\\': stream.print(F("\\")); break;
+ default: stream.print(c);
+ }
+ }
+
diff --git a/StringFormatter.h b/StringFormatter.h
index 76dd605..888eca9 100644
--- a/StringFormatter.h
+++ b/StringFormatter.h
@@ -1,15 +1,34 @@
+/*
+ * © 2020, Chris Harlow. All rights reserved.
+ *
+ * This file is part of Asbelos DCC API
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * It is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CommandStation. If not, see .
+ */
#ifndef StringFormatter_h
#define StringFormatter_h
#include
class StringFormatter
{
public:
- static int parse(const char * com, int result[], byte maxResults);
static void print( const __FlashStringHelper* input...);
static void send(Print & serial, const __FlashStringHelper* input...);
+ static void printEscapes(Print & stream, char * input);
+ static void printEscapes(Print & stream, const __FlashStringHelper* input);
+ static void printEscape(Print & stream, char c);
private:
static void send2(Print & serial, const __FlashStringHelper* input,va_list args);
-
};
#endif
diff --git a/Turnouts.cpp b/Turnouts.cpp
index 3d6fd29..f280f86 100644
--- a/Turnouts.cpp
+++ b/Turnouts.cpp
@@ -1,3 +1,21 @@
+/*
+ * © 2020, Chris Harlow. All rights reserved.
+ *
+ * This file is part of Asbelos DCC API
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * It is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CommandStation. If not, see .
+ */
#include "Turnouts.h"
#include "EEStore.h"
#include "StringFormatter.h"
diff --git a/Turnouts.h b/Turnouts.h
index 28fd528..7fbbbe0 100644
--- a/Turnouts.h
+++ b/Turnouts.h
@@ -1,3 +1,21 @@
+/*
+ * © 2020, Chris Harlow. All rights reserved.
+ *
+ * This file is part of Asbelos DCC API
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * It is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CommandStation. If not, see .
+ */
#ifndef Turnouts_h
#define Turnouts_h
diff --git a/WiThrottle.cpp b/WiThrottle.cpp
index 59f1fc9..7af7373 100644
--- a/WiThrottle.cpp
+++ b/WiThrottle.cpp
@@ -1,3 +1,21 @@
+/*
+ * © 2020, Chris Harlow. All rights reserved.
+ *
+ * This file is part of Asbelos DCC API
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * It is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CommandStation. If not, see .
+ */
/*
* Truncated JMRI WiThrottle server implementation for DCC-EX command station
* Credit is due to Valerie Valley RR https://sites.google.com/site/valerievalleyrr/
@@ -71,7 +89,7 @@ WiThrottle::~WiThrottle() {
void WiThrottle::parse(Print & stream, byte * cmd) {
heartBeat=millis();
- DIAG(F("\nWiThrottle parse (%d) %s"),clientid, cmd);
+ DIAG(F("\nWiThrottle(%d) [%e]"),clientid, cmd);
switch (cmd[0]) {
case '*': // heartbeat control
@@ -97,7 +115,7 @@ void WiThrottle::parse(Print & stream, byte * cmd) {
break;
case 'H': // hardware introduction....
break;
- case 'Q': // hardware introduction....
+ case 'Q': //
DIAG(F("\nWiThrottle Quit"));
delete this;
break;
diff --git a/WiThrottle.h b/WiThrottle.h
index f681b1f..94cf3c0 100644
--- a/WiThrottle.h
+++ b/WiThrottle.h
@@ -1,3 +1,21 @@
+/*
+ * © 2020, Chris Harlow. All rights reserved.
+ *
+ * This file is part of Asbelos DCC API
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * It is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CommandStation. If not, see .
+ */
#ifndef WiThrottle_h
#define WiTHrottle_h
diff --git a/WifiInterface.cpp b/WifiInterface.cpp
index 42c69e3..6cbefaf 100644
--- a/WifiInterface.cpp
+++ b/WifiInterface.cpp
@@ -1,3 +1,21 @@
+/*
+ * © 2020, Chris Harlow. All rights reserved.
+ *
+ * This file is part of Asbelos DCC API
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * It is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CommandStation. If not, see .
+ */
#include "WifiInterface.h"
#include "Config.h"
#include "DIAG.h"
@@ -56,16 +74,16 @@ bool WifiInterface::setup2(Stream & wifiStream, const __FlashStringHelper* SSid,
bool WifiInterface::checkForOK(Stream & wifiStream, const unsigned int timeout, const char * waitfor, bool echo) {
unsigned long startTime = millis();
char const *locator=waitfor;
- DIAG(F("\nWifi setup Check: %S\n"),waitfor);
+ DIAG(F("\nWifi Check: %E"),waitfor);
while( millis()-startTime < timeout) {
while(wifiStream.available()) {
int ch=wifiStream.read();
- if (echo) Serial.write(ch);
+ if (echo) StringFormatter::printEscape(Serial,ch); /// THIS IS A DIAG IN DISGUISE
if (ch!=pgm_read_byte_near(locator)) locator=waitfor;
if (ch==pgm_read_byte_near(locator)) {
locator++;
if (!pgm_read_byte_near(locator)) {
- DIAG(F("\nOK after %dms\n"),millis()-startTime);
+ DIAG(F("\nChecked after %dms"),millis()-startTime);
return true;
}
}
@@ -140,7 +158,7 @@ void WifiInterface::loop(Stream & wifiStream) {
if (loopstate!=99) return;
streamer.write('\0');
- DIAG(F("\nWifiRead:%d:%s\n"),connectionId,buffer);
+ DIAG(F("\nWifiRead:%d:%e\n"),connectionId,buffer);
streamer.setBufferContentPosition(0,0); // reset write position to start of buffer
// SIDE EFFECT WARNING:::
// We know that parser will read the entire buffer before starting to write to it.
@@ -159,7 +177,7 @@ void WifiInterface::loop(Stream & wifiStream) {
if (streamer.available()) { // there is a reply to send
streamer.write('\0');
- DIAG(F("WiFiInterface Responding client (%d) l(%d) %s\n"),connectionId,streamer.available()-1,buffer);
+ DIAG(F("WiFiInterface Responding client (%d) l(%d) %e\n"),connectionId,streamer.available()-1,buffer);
StringFormatter::send(wifiStream,F("AT+CIPSEND=%d,%d\r\n"),connectionId,streamer.available()-1);
if (checkForOK(wifiStream,1000,PROMPT_SEARCH,true)) wifiStream.print((char *) buffer);
diff --git a/WifiInterface.h b/WifiInterface.h
index 9210a46..41649ee 100644
--- a/WifiInterface.h
+++ b/WifiInterface.h
@@ -1,3 +1,21 @@
+/*
+ * © 2020, Chris Harlow. All rights reserved.
+ *
+ * This file is part of Asbelos DCC API
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * It is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CommandStation. If not, see .
+ */
#ifndef WifiInterface_h
#define WifiInterface_h