mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-24 21:21:24 +01:00
Better diagnostics
This commit is contained in:
parent
a43db19cc0
commit
28be07610a
@ -28,7 +28,7 @@ void setup() {
|
|||||||
|
|
||||||
for (byte x=0;x<sizeof(cvnums)/sizeof(cvnums[0]);x++) {
|
for (byte x=0;x<sizeof(cvnums)/sizeof(cvnums[0]);x++) {
|
||||||
int value=DCC::readCV(cvnums[x]);
|
int value=DCC::readCV(cvnums[x]);
|
||||||
DIAG(F("\nCV %d = %d 0x%x %s"),cvnums[x],value,value, value>=0?" VERIFIED OK":"FAILED VERIFICATION");
|
DIAG(F("\nCV %d = %d 0x%x %s\n"),cvnums[x],value,value, value>=0?" VERIFIED OK":"FAILED VERIFICATION");
|
||||||
}
|
}
|
||||||
DIAG(F("\n===== CVReader done ==============================\n"));
|
DIAG(F("\n===== CVReader done ==============================\n"));
|
||||||
DIAG(F("\nReady for JMRI commands\n"));
|
DIAG(F("\nReady for JMRI commands\n"));
|
||||||
|
1
DCC.cpp
1
DCC.cpp
@ -182,6 +182,7 @@ byte DCC::cv2(int cv) {
|
|||||||
|
|
||||||
bool DCC::verifyCV(int cv, byte value) {
|
bool DCC::verifyCV(int cv, byte value) {
|
||||||
byte message[] = { cv1(0x74, cv), cv2(cv), value};
|
byte message[] = { cv1(0x74, cv), cv2(cv), value};
|
||||||
|
DIAG(F("\n\nVerifying cv %d = %d"),cv, value);
|
||||||
DCCWaveform::progTrack.schedulePacket(message, sizeof(message), 5);
|
DCCWaveform::progTrack.schedulePacket(message, sizeof(message), 5);
|
||||||
return DCCWaveform::progTrack.getAck();
|
return DCCWaveform::progTrack.getAck();
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ DCCWaveform::DCCWaveform(byte powerPinNo, byte directionPinNo, byte sensePinNo,
|
|||||||
void DCCWaveform::setPowerMode(POWERMODE mode) {
|
void DCCWaveform::setPowerMode(POWERMODE mode) {
|
||||||
powerMode=mode;
|
powerMode=mode;
|
||||||
digitalWrite2f(powerPin, mode==POWERMODE::ON ? HIGH:LOW);
|
digitalWrite2f(powerPin, mode==POWERMODE::ON ? HIGH:LOW);
|
||||||
if (mode==POWERMODE::ON) schedulePacket(resetMessage,2,20);
|
if (mode==POWERMODE::ON) delay(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -213,7 +213,7 @@ void DCCWaveform::checkRailcom() {
|
|||||||
// Wait until there is no packet pending, then make this pending
|
// Wait until there is no packet pending, then make this pending
|
||||||
void DCCWaveform::schedulePacket(const byte buffer[], byte byteCount, byte repeats) {
|
void DCCWaveform::schedulePacket(const byte buffer[], byte byteCount, byte repeats) {
|
||||||
if (byteCount>=MAX_PACKET_SIZE) return; // allow for chksum
|
if (byteCount>=MAX_PACKET_SIZE) return; // allow for chksum
|
||||||
while(packetPending) delay(1);
|
while(packetPending);
|
||||||
|
|
||||||
byte checksum=0;
|
byte checksum=0;
|
||||||
for (int b=0;b<byteCount; b++) {
|
for (int b=0;b<byteCount; b++) {
|
||||||
@ -233,7 +233,7 @@ bool DCCWaveform::getAck()
|
|||||||
|
|
||||||
if (isMainTrack) return false; // cant do this on main track
|
if (isMainTrack) return false; // cant do this on main track
|
||||||
|
|
||||||
while(packetPending) delay(1); // wait until transmitter has started transmitting the message
|
while(packetPending); // wait until transmitter has started transmitting the message
|
||||||
unsigned long timeout=millis()+ACK_TIMEOUT;
|
unsigned long timeout=millis()+ACK_TIMEOUT;
|
||||||
int maxCurrent=0;
|
int maxCurrent=0;
|
||||||
bool result=false;
|
bool result=false;
|
||||||
@ -257,6 +257,6 @@ bool DCCWaveform::getAck()
|
|||||||
}
|
}
|
||||||
// The following DIAG is really useful as it can show how long and how far the
|
// The following DIAG is really useful as it can show how long and how far the
|
||||||
// current changes during an ACK from the decoder.
|
// current changes during an ACK from the decoder.
|
||||||
// DIAG(F("\nack=%d max=%d, up=%d, down=%d "),result,maxCurrent, upsamples,downsamples);
|
DIAG(F("\nack=%d max=%d, up=%d, down=%d "),result,maxCurrent, upsamples,downsamples);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ const int POWER_SAMPLE_OVERLOAD_WAIT = 4000;
|
|||||||
|
|
||||||
// ACK current analogRead values (vary depending on motor shield and cpu voltage)
|
// ACK current analogRead values (vary depending on motor shield and cpu voltage)
|
||||||
const int ACK_TIMEOUT = 25 ; // millis getAck is prepared to wait for a signal
|
const int ACK_TIMEOUT = 25 ; // millis getAck is prepared to wait for a signal
|
||||||
const int ACK_MAX_NOT_PULSE = 10 ; // current below which this is NOT a pulse any more
|
const int ACK_MAX_NOT_PULSE = 40 ; // current below which this is NOT a pulse any more
|
||||||
const int ACK_MIN_PULSE = 50 ; // current above which a pulse is recognised
|
const int ACK_MIN_PULSE = 50 ; // current above which a pulse is recognised
|
||||||
|
|
||||||
const int PREAMBLE_BITS_MAIN = 20;
|
const int PREAMBLE_BITS_MAIN = 20;
|
||||||
|
Loading…
Reference in New Issue
Block a user