2020-05-24 17:07:16 +02:00
|
|
|
#include "DCC.h"
|
2020-05-24 00:02:54 +02:00
|
|
|
#include "DIAG.h"
|
2020-05-25 14:38:18 +02:00
|
|
|
#include "JMRIParser.h"
|
2020-05-24 00:22:12 +02:00
|
|
|
|
|
|
|
/* this code is here to test the waveforwe generator and reveal the issues involved in programming track operations.
|
|
|
|
*
|
|
|
|
* It tests the Waveform genartor and demonstrates how a DCC API function can be simply written
|
|
|
|
* to transmit and receive DCC data on the programming track.
|
|
|
|
*
|
|
|
|
* Important... DCCWaveform.h contains hardware specific confioguration settings
|
|
|
|
* that you will need to check.
|
|
|
|
*
|
|
|
|
* Notes: the waveform generator sends reset packets on progTrack when it has nothing better to do, this means that
|
|
|
|
* the decoder does not step out of service mode. (The main track sends idles).
|
|
|
|
* It also means that the API functions dont have to mess with reset packets.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2020-05-24 17:07:16 +02:00
|
|
|
|
2020-05-24 00:02:54 +02:00
|
|
|
const int cvnums[]={1,2,3,4,5,17,18,19,21,22,29};
|
|
|
|
|
|
|
|
void setup() {
|
|
|
|
Serial.begin(115200);
|
2020-05-24 17:07:16 +02:00
|
|
|
DCC::begin();
|
2020-05-24 00:22:12 +02:00
|
|
|
|
|
|
|
DIAG(F("\n===== CVReader begin ==============================\n"));
|
2020-05-24 00:02:54 +02:00
|
|
|
|
|
|
|
for (byte x=0;x<sizeof(cvnums)/sizeof(cvnums[0]);x++) {
|
2020-05-24 17:07:16 +02:00
|
|
|
int value=DCC::readCV(cvnums[x]);
|
2020-05-26 10:44:20 +02:00
|
|
|
DIAG(F("\nCV %d = %d 0x%x %s\n"),cvnums[x],value,value, value>=0?" VERIFIED OK":"FAILED VERIFICATION");
|
2020-05-24 00:02:54 +02:00
|
|
|
}
|
2020-05-26 00:03:11 +02:00
|
|
|
DIAG(F("\n===== CVReader done ==============================\n"));
|
|
|
|
DIAG(F("\nReady for JMRI commands\n"));
|
2020-05-24 00:02:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void loop() {
|
2020-05-26 00:03:11 +02:00
|
|
|
DCC::loop(); // required to keep locos running and check powwer
|
|
|
|
|
|
|
|
// This line passes input on Serial to the JMRIparser
|
|
|
|
StringParser::loop(Serial, JMRIParser::parse);
|
|
|
|
}
|
2020-05-25 14:38:18 +02:00
|
|
|
|