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

<* *> wrapped diags

And lots of \n cleanups.
This commit is contained in:
Asbelos 2021-03-25 14:23:38 +00:00
parent dd2260709d
commit 85a2b9231b
16 changed files with 91 additions and 94 deletions

26
DCC.cpp
View File

@ -49,7 +49,7 @@ byte DCC::joinRelay=UNUSED_PIN;
void DCC::begin(const FSH * motorShieldName, MotorDriver * mainDriver, MotorDriver* progDriver) {
shieldName=(FSH *)motorShieldName;
DIAG(F("<iDCC-EX V-%S / %S / %S G-%S>\n"), F(VERSION), F(ARDUINO_TYPE), shieldName, F(GITHUB_SHA));
DIAG(F("DCC-EX V-%S / %S / %S G-%S"), F(VERSION), F(ARDUINO_TYPE), shieldName, F(GITHUB_SHA));
// Load stuff from EEprom
(void)EEPROM; // tell compiler not to warn this is unused
@ -77,7 +77,7 @@ void DCC::setThrottle2( uint16_t cab, byte speedCode) {
uint8_t b[4];
uint8_t nB = 0;
// DIAG(F("\nsetSpeedInternal %d %x"),cab,speedCode);
// DIAG(F("setSpeedInternal %d %x"),cab,speedCode);
if (cab > 127)
b[nB++] = highByte(cab) | 0xC0; // convert train number into a two-byte address
@ -89,7 +89,7 @@ void DCC::setThrottle2( uint16_t cab, byte speedCode) {
}
void DCC::setFunctionInternal(int cab, byte byte1, byte byte2) {
// DIAG(F("\nsetFunctionInternal %d %x %x"),cab,byte1,byte2);
// DIAG(F("setFunctionInternal %d %x %x"),cab,byte1,byte2);
byte b[4];
byte nB = 0;
@ -566,7 +566,7 @@ bool DCC::issueReminder(int reg) {
switch (loopStatus) {
case 0:
// DIAG(F("\nReminder %d speed %d"),loco,speedTable[reg].speedCode);
// DIAG(F("Reminder %d speed %d"),loco,speedTable[reg].speedCode);
setThrottle2(loco, speedTable[reg].speedCode);
break;
case 1: // remind function group 1 (F0-F4)
@ -624,7 +624,7 @@ int DCC::lookupSpeedTable(int locoId) {
}
if (reg == MAX_LOCOS) reg = firstEmpty;
if (reg >= MAX_LOCOS) {
DIAG(F("\nToo many locos\n"));
DIAG(F("Too many locos"));
return -1;
}
if (reg==firstEmpty){
@ -703,7 +703,7 @@ void DCC::ackManagerLoop() {
}
setProgTrackSyncMain(false);
if (DCCWaveform::progTrack.getPowerMode() == POWERMODE::OFF) {
if (Diag::ACK) DIAG(F("\nAuto Prog power on"));
if (Diag::ACK) DIAG(F("Auto Prog power on"));
DCCWaveform::progTrack.setPowerMode(POWERMODE::ON);
DCCWaveform::progTrack.sentResetsSincePacket = 0;
DCCWaveform::progTrack.autoPowerOff=true;
@ -716,7 +716,7 @@ void DCC::ackManagerLoop() {
case W1: // write 1 bit
{
if (checkResets(RESET_MIN)) return;
if (Diag::ACK) DIAG(F("\nW%d cv=%d bit=%d"),opcode==W1, ackManagerCv,ackManagerBitNum);
if (Diag::ACK) DIAG(F("W%d cv=%d bit=%d"),opcode==W1, ackManagerCv,ackManagerBitNum);
byte instruction = WRITE_BIT | (opcode==W1 ? BIT_ON : BIT_OFF) | ackManagerBitNum;
byte message[] = {cv1(BIT_MANIPULATE, ackManagerCv), cv2(ackManagerCv), instruction };
DCCWaveform::progTrack.schedulePacket(message, sizeof(message), PROG_REPEATS);
@ -727,7 +727,7 @@ void DCC::ackManagerLoop() {
case WB: // write byte
{
if (checkResets( RESET_MIN)) return;
if (Diag::ACK) DIAG(F("\nWB cv=%d value=%d"),ackManagerCv,ackManagerByte);
if (Diag::ACK) DIAG(F("WB cv=%d value=%d"),ackManagerCv,ackManagerByte);
byte message[] = {cv1(WRITE_BYTE, ackManagerCv), cv2(ackManagerCv), ackManagerByte};
DCCWaveform::progTrack.schedulePacket(message, sizeof(message), PROG_REPEATS);
DCCWaveform::progTrack.setAckPending();
@ -737,7 +737,7 @@ void DCC::ackManagerLoop() {
case VB: // Issue validate Byte packet
{
if (checkResets( RESET_MIN)) return;
if (Diag::ACK) DIAG(F("\nVB cv=%d value=%d"),ackManagerCv,ackManagerByte);
if (Diag::ACK) DIAG(F("VB cv=%d value=%d"),ackManagerCv,ackManagerByte);
byte message[] = { cv1(VERIFY_BYTE, ackManagerCv), cv2(ackManagerCv), ackManagerByte};
DCCWaveform::progTrack.schedulePacket(message, sizeof(message), PROG_REPEATS);
DCCWaveform::progTrack.setAckPending();
@ -748,7 +748,7 @@ void DCC::ackManagerLoop() {
case V1: // Issue validate bit=0 or bit=1 packet
{
if (checkResets(RESET_MIN)) return;
if (Diag::ACK) DIAG(F("\nV%d cv=%d bit=%d"),opcode==V1, ackManagerCv,ackManagerBitNum);
if (Diag::ACK) DIAG(F("V%d cv=%d bit=%d"),opcode==V1, ackManagerCv,ackManagerBitNum);
byte instruction = VERIFY_BIT | (opcode==V0?BIT_OFF:BIT_ON) | ackManagerBitNum;
byte message[] = {cv1(BIT_MANIPULATE, ackManagerCv), cv2(ackManagerCv), instruction };
DCCWaveform::progTrack.schedulePacket(message, sizeof(message), PROG_REPEATS);
@ -853,7 +853,7 @@ void DCC::ackManagerLoop() {
case SKIPTARGET:
break;
default:
DIAG(F("\n!! ackOp %d FAULT!!"),opcode);
DIAG(F("!! ackOp %d FAULT!!"),opcode);
callback( -1);
return;
@ -864,14 +864,14 @@ void DCC::ackManagerLoop() {
void DCC::callback(int value) {
ackManagerProg=NULL; // no more steps to execute
if (DCCWaveform::progTrack.autoPowerOff) {
if (Diag::ACK) DIAG(F("\nAuto Prog power off"));
if (Diag::ACK) DIAG(F("Auto Prog power off"));
DCCWaveform::progTrack.doAutoPowerOff();
}
// Restore <1 JOIN> to state before BASELINE
setProgTrackSyncMain(ackManagerRejoin);
if (Diag::ACK) DIAG(F("\nCallback(%d)\n"),value);
if (Diag::ACK) DIAG(F("Callback(%d)"),value);
(ackManagerCallback)( value);
}

View File

@ -73,7 +73,7 @@ DCCEXParser::DCCEXParser() {}
void DCCEXParser::flush()
{
if (Diag::CMD)
DIAG(F("\nBuffer flush"));
DIAG(F("Buffer flush"));
bufferLength = 0;
inCommandPayload = false;
}
@ -256,7 +256,7 @@ void DCCEXParser::parse(Print *stream, byte *com, RingStream * ringStream)
{
(void)EEPROM; // tell compiler not to warn this is unused
if (Diag::CMD)
DIAG(F("\nPARSING:%s\n"), com);
DIAG(F("PARSING:%s"), com);
int p[MAX_COMMAND_PARAMS];
while (com[0] == '<' || com[0] == ' ')
com++; // strip off any number of < or spaces
@ -380,7 +380,7 @@ void DCCEXParser::parse(Print *stream, byte *com, RingStream * ringStream)
byte packet[params];
for (int i=0;i<params;i++) {
packet[i]=(byte)p[i+1];
if (Diag::CMD) DIAG(F("packet[%d]=%d (0x%x)\n"), i, packet[i], packet[i]);
if (Diag::CMD) DIAG(F("packet[%d]=%d (0x%x)"), i, packet[i], packet[i]);
}
(opcode=='M'?DCCWaveform::mainTrack:DCCWaveform::progTrack).schedulePacket(packet,params,3);
}
@ -550,9 +550,9 @@ void DCCEXParser::parse(Print *stream, byte *com, RingStream * ringStream)
break;
default: //anything else will diagnose and drop out to <X>
DIAG(F("\nOpcode=%c params=%d\n"), opcode, params);
DIAG(F("Opcode=%c params=%d"), opcode, params);
for (int i = 0; i < params; i++)
DIAG(F("p[%d]=%d (0x%x)\n"), i, p[i], p[i]);
DIAG(F("p[%d]=%d (0x%x)"), i, p[i], p[i]);
break;
} // end of opcode switch

View File

@ -46,9 +46,9 @@ void DCCWaveform::begin(MotorDriver * mainDriver, MotorDriver * progDriver) {
// Only use PWM if both pins are PWM capable. Otherwise JOIN does not work
MotorDriver::usePWM= mainDriver->isPWMCapable() && progDriver->isPWMCapable();
if (MotorDriver::usePWM)
DIAG(F("\nSignal pin config: high accuracy waveform"));
DIAG(F("Signal pin config: high accuracy waveform"));
else
DIAG(F("\nSignal pin config: normal accuracy waveform"));
DIAG(F("Signal pin config: normal accuracy waveform"));
DCCTimer::begin(DCCWaveform::interruptHandler);
}
@ -140,9 +140,9 @@ void DCCWaveform::checkPowerOverload(bool ackManagerActive) {
}
// Write this after the fact as we want to turn on as fast as possible
// because we don't know which output actually triggered the fault pin
DIAG(F("\n*** COMMON FAULT PIN ACTIVE - TOGGLED POWER on %S ***\n"), isMainTrack ? F("MAIN") : F("PROG"));
DIAG(F("*** COMMON FAULT PIN ACTIVE - TOGGLED POWER on %S ***"), isMainTrack ? F("MAIN") : F("PROG"));
} else {
DIAG(F("\n*** %S FAULT PIN ACTIVE - OVERLOAD ***\n"), isMainTrack ? F("MAIN") : F("PROG"));
DIAG(F("*** %S FAULT PIN ACTIVE - OVERLOAD ***"), isMainTrack ? F("MAIN") : F("PROG"));
if (lastCurrent < tripValue) {
lastCurrent = tripValue; // exaggerate
}
@ -160,7 +160,7 @@ void DCCWaveform::checkPowerOverload(bool ackManagerActive) {
unsigned int maxmA=motorDriver->raw2mA(tripValue);
power_good_counter=0;
sampleDelay = power_sample_overload_wait;
DIAG(F("\n*** %S TRACK POWER OVERLOAD current=%d max=%d offtime=%d ***\n"), isMainTrack ? F("MAIN") : F("PROG"), mA, maxmA, sampleDelay);
DIAG(F("*** %S TRACK POWER OVERLOAD current=%d max=%d offtime=%d ***"), isMainTrack ? F("MAIN") : F("PROG"), mA, maxmA, sampleDelay);
if (power_sample_overload_wait >= 10000)
power_sample_overload_wait = 10000;
else
@ -172,7 +172,7 @@ void DCCWaveform::checkPowerOverload(bool ackManagerActive) {
setPowerMode(POWERMODE::ON);
sampleDelay = POWER_SAMPLE_ON_WAIT;
// Debug code....
DIAG(F("\n*** %S TRACK POWER RESET delay=%d ***\n"), isMainTrack ? F("MAIN") : F("PROG"), sampleDelay);
DIAG(F("*** %S TRACK POWER RESET delay=%d ***"), isMainTrack ? F("MAIN") : F("PROG"), sampleDelay);
break;
default:
sampleDelay = 999; // cant get here..meaningless statement to avoid compiler warning.
@ -279,7 +279,7 @@ void DCCWaveform::setAckBaseline() {
if (isMainTrack) return;
int baseline=motorDriver->getCurrentRaw();
ackThreshold= baseline + motorDriver->mA2raw(ackLimitmA);
if (Diag::ACK) DIAG(F("\nACK baseline=%d/%dmA Threshold=%d/%dmA Duration between %dus and %dus"),
if (Diag::ACK) DIAG(F("ACK baseline=%d/%dmA Threshold=%d/%dmA Duration between %dus and %dus"),
baseline,motorDriver->raw2mA(baseline),
ackThreshold,motorDriver->raw2mA(ackThreshold),
minAckPulseDuration, maxAckPulseDuration);
@ -297,7 +297,7 @@ void DCCWaveform::setAckPending() {
byte DCCWaveform::getAck() {
if (ackPending) return (2); // still waiting
if (Diag::ACK) DIAG(F("\n%S after %dmS max=%d/%dmA pulse=%duS"),ackDetected?F("ACK"):F("NO-ACK"), ackCheckDuration,
if (Diag::ACK) DIAG(F("%S after %dmS max=%d/%dmA pulse=%duS"),ackDetected?F("ACK"):F("NO-ACK"), ackCheckDuration,
ackMaxCurrent,motorDriver->raw2mA(ackMaxCurrent), ackPulseDuration);
if (ackDetected) return (1); // Yes we had an ack
return(0); // pending set off but not detected means no ACK.

View File

@ -94,10 +94,10 @@ int EEStore::pointer(){
void EEStore::dump(int num) {
byte b;
DIAG(F("\nAddr 0x char\n"));
DIAG(F("Addr 0x char"));
for (int n=0 ; n<num; n++) {
EEPROM.get(n, b);
DIAG(F("%d %x %c\n"),n,b,isprint(b) ? b : ' ');
DIAG(F("%d %x %c"),n,b,isprint(b) ? b : ' ');
}
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -52,12 +52,6 @@ EthernetInterface::EthernetInterface()
{
byte mac[6];
DCCTimer::getSimulatedMacAddress(mac);
DIAG(F("\n+++++ Ethernet Setup. Simulatd mac="));
for (byte i=0;i<sizeof(mac); i++) {
DIAG(F("%s%x:"),mac[i] < 0x10 ? "0" : "", mac[i]);
}
DIAG(F("\n"));
connected=false;
#ifdef IP_ADDRESS
@ -65,17 +59,17 @@ EthernetInterface::EthernetInterface()
#else
if (Ethernet.begin(mac) == 0)
{
DIAG(F("begin FAILED\n"));
DIAG(F("Ethernet.begin FAILED"));
return;
}
#endif
DIAG(F("begin OK."));
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
DIAG(F("shield not found\n"));
DIAG(F("Ethernet shield not found"));
return;
}
if (Ethernet.linkStatus() == LinkOFF) {
DIAG(F("cable not connected\n"));
DIAG(F("Ethernet cable not connected"));
return;
}
@ -104,13 +98,13 @@ void EthernetInterface::loop()
{
case 1:
//renewed fail
DIAG(F("\nEthernet Error: renewed fail\n"));
DIAG(F("Ethernet Error: renewed fail"));
singleton=NULL;
return;
case 3:
//rebind fail
DIAG(F("Ethernet Error: rebind fail\n"));
DIAG(F("Ethernet Error: rebind fail"));
singleton=NULL;
return;
@ -131,7 +125,7 @@ void EthernetInterface::loop()
// check for new client
if (client)
{
if (Diag::ETHERNET) DIAG(F("\nEthernet: New client "));
if (Diag::ETHERNET) DIAG(F("Ethernet: New client "));
byte socket;
for (socket = 0; socket < MAX_SOCK_NUM; socket++)
{
@ -139,12 +133,12 @@ void EthernetInterface::loop()
{
// On accept() the EthernetServer doesn't track the client anymore
// so we store it in our client array
if (Diag::ETHERNET) DIAG(F("%d\n"),socket);
if (Diag::ETHERNET) DIAG(F("Socket %d"),socket);
clients[socket] = client;
break;
}
}
if (socket==MAX_SOCK_NUM) DIAG(F("new Ethernet OVERFLOW\n"));
if (socket==MAX_SOCK_NUM) DIAG(F("new Ethernet OVERFLOW"));
}
// check for incoming data from all possible clients
@ -154,11 +148,11 @@ void EthernetInterface::loop()
int available=clients[socket].available();
if (available > 0) {
if (Diag::ETHERNET) DIAG(F("\nEthernet: available socket=%d,avail=%d,count="), socket, available);
if (Diag::ETHERNET) DIAG(F("Ethernet: available socket=%d,avail=%d"), socket, available);
// read bytes from a client
int count = clients[socket].read(buffer, MAX_ETH_BUFFER);
buffer[count] = '\0'; // terminate the string properly
if (Diag::ETHERNET) DIAG(F("%d:%e\n"), socket,buffer);
if (Diag::ETHERNET) DIAG(F(",count=%d:%e"), socket,buffer);
// execute with data going directly back
outboundRing->mark(socket);
CommandDistributor::parse(socket,buffer,outboundRing);
@ -172,7 +166,7 @@ void EthernetInterface::loop()
for (int socket = 0; socket<MAX_SOCK_NUM; socket++) {
if (clients[socket] && !clients[socket].connected()) {
clients[socket].stop();
if (Diag::ETHERNET) DIAG(F("\nEthernet: disconnect %d \n"), socket);
if (Diag::ETHERNET) DIAG(F("Ethernet: disconnect %d "), socket);
}
}
@ -180,7 +174,7 @@ void EthernetInterface::loop()
int socketOut=outboundRing->read();
if (socketOut>=0) {
int count=outboundRing->count();
if (Diag::ETHERNET) DIAG(F("Ethernet reply socket=%d, count=:%d\n"), socketOut,count);
if (Diag::ETHERNET) DIAG(F("Ethernet reply socket=%d, count=:%d"), socketOut,count);
for(;count>0;count--) clients[socketOut].write(outboundRing->read());
clients[socketOut].flush(); //maybe
}

View File

@ -37,7 +37,7 @@ LCDDisplay::LCDDisplay() {
byte error = I2CManager.exists(address);
if (!error) {
// Device found
DIAG(F("\nOLED display found at 0x%x"), address);
DIAG(F("OLED display found at 0x%x"), address);
interfake(OLED_DRIVER, 0);
const DevType *devType;
if (lcdCols == 132)
@ -53,7 +53,7 @@ LCDDisplay::LCDDisplay() {
return;
}
}
DIAG(F("\nOLED display not found\n"));
DIAG(F("OLED display not found"));
}
void LCDDisplay::interfake(int p1, int p2, int p3) {

View File

@ -28,7 +28,7 @@ bool LCN::firstLoop=true;
void LCN::init(Stream & lcnstream) {
stream=&lcnstream;
DIAG(F("\nLCN connection setup\n"));
DIAG(F("LCN connection setup"));
}
@ -47,7 +47,7 @@ void LCN::loop() {
id = 10 * id + ch - '0';
}
else if (ch == 't' || ch == 'T') { // Turnout opcodes
if (Diag::LCN) DIAG(F("\nLCN IN %d%c\n"),id,(char)ch);
if (Diag::LCN) DIAG(F("LCN IN %d%c"),id,(char)ch);
Turnout * tt = Turnout::get(id);
if (!tt) Turnout::create(id, LCN_TURNOUT_ADDRESS, 0);
if (ch == 't') tt->data.tStatus |= STATUS_ACTIVE;
@ -56,7 +56,7 @@ void LCN::loop() {
id = 0;
}
else if (ch == 'S' || ch == 's') {
if (Diag::LCN) DIAG(F("\nLCN IN %d%c\n"),id,(char)ch);
if (Diag::LCN) DIAG(F("LCN IN %d%c"),id,(char)ch);
Sensor * ss = Sensor::get(id);
if (!ss) ss = Sensor::create(id, 255,0); // impossible pin
ss->active = ch == 'S';
@ -69,6 +69,6 @@ void LCN::loop() {
void LCN::send(char opcode, int id, bool state) {
if (stream) {
StringFormatter::send(stream,F("%c/%d/%d"), opcode, id , state);
if (Diag::LCN) DIAG(F("\nLCN OUT %c/%d/%d\n"), opcode, id , state);
if (Diag::LCN) DIAG(F("LCN OUT %c/%d/%d"), opcode, id , state);
}
}

View File

@ -74,9 +74,9 @@ MotorDriver::MotorDriver(byte power_pin, byte signal_pin, byte signal_pin2, int8
rawCurrentTripValue=(int)(trip_milliamps / sense_factor);
if (currentPin==UNUSED_PIN)
DIAG(F("\nMotorDriver ** WARNING ** No current or short detection\n"));
DIAG(F("MotorDriver ** WARNING ** No current or short detection"));
else
DIAG(F("\nMotorDriver currentPin=A%d, senseOffset=%d, rawCurentTripValue(relative to offset)=%d\n"),
DIAG(F("MotorDriver currentPin=A%d, senseOffset=%d, rawCurentTripValue(relative to offset)=%d"),
currentPin-A0, senseOffset,rawCurrentTripValue);
}
@ -159,7 +159,7 @@ int MotorDriver::mA2raw( unsigned int mA) {
}
void MotorDriver::getFastPin(const FSH* type,int pin, bool input, FASTPIN & result) {
// DIAG(F("\nMotorDriver %S Pin=%d,"),type,pin);
// DIAG(F("MotorDriver %S Pin=%d,"),type,pin);
(void) type; // avoid compiler warning if diag not used above.
uint8_t port = digitalPinToPort(pin);
if (input)
@ -168,5 +168,5 @@ void MotorDriver::getFastPin(const FSH* type,int pin, bool input, FASTPIN & res
result.inout = portOutputRegister(port);
result.maskHIGH = digitalPinToBitMask(pin);
result.maskLOW = ~result.maskHIGH;
// DIAG(F(" port=0x%x, inoutpin=0x%x, isinput=%d, mask=0x%x\n"),port, result.inout,input,result.maskHIGH);
// DIAG(F(" port=0x%x, inoutpin=0x%x, isinput=%d, mask=0x%x"),port, result.inout,input,result.maskHIGH);
}

View File

@ -62,12 +62,12 @@ bool PWMServoDriver::setup(int board) {
// Test if device is available
byte error = I2CManager.exists(i2caddr);
if (error) {
DIAG(F("\nI2C Servo device 0x%x Not Found %d\n"),i2caddr, error);
DIAG(F("I2C Servo device 0x%x Not Found %d"),i2caddr, error);
failFlags|=1<<board;
return false;
}
//DIAG(F("\nPWMServoDriver::setup %x prescale=%d"),i2caddr,PRESCALE_50HZ);
//DIAG(F("PWMServoDriver::setup %x prescale=%d"),i2caddr,PRESCALE_50HZ);
writeRegister(i2caddr,PCA9685_MODE1, MODE1_SLEEP | MODE1_AI);
writeRegister(i2caddr,PCA9685_PRESCALE, PRESCALE_50HZ);
writeRegister(i2caddr,PCA9685_MODE1,MODE1_AI);
@ -84,7 +84,7 @@ void PWMServoDriver::setServo(byte servoNum, uint16_t value) {
int pin=servoNum%16;
if (setup(board)) {
DIAG(F("\nSetServo %d %d\n"),servoNum,value);
DIAG(F("SetServo %d %d"),servoNum,value);
Wire.beginTransmission(PCA9685_I2C_ADDRESS + board);
Wire.write(PCA9685_FIRST_SERVO + 4 * pin); // 4 registers per pin
Wire.write(0);
@ -92,7 +92,7 @@ void PWMServoDriver::setServo(byte servoNum, uint16_t value) {
Wire.write(value);
Wire.write(value >> 8);
byte error=Wire.endTransmission();
if (error!=0) DIAG(F("\nSetServo error %d\n"),error);
if (error!=0) DIAG(F("SetServo error %d"),error);
}
}

View File

@ -83,7 +83,7 @@ uint8_t RingStream::peekTargetMark() {
bool RingStream::commit() {
if (_overflow) {
DIAG(F("\nRingStream(%d) commit(%d) OVERFLOW\n"),_len, _count);
DIAG(F("RingStream(%d) commit(%d) OVERFLOW"),_len, _count);
// just throw it away
_pos_write=_mark;
_overflow=false;

View File

@ -38,20 +38,22 @@ bool Diag::LCN=false;
void StringFormatter::diag( const FSH* input...) {
if (!diagSerial) return;
if (!diagSerial) return;
diagSerial->print(F("\n<* "));
va_list args;
va_start(args, input);
send2(diagSerial,input,args);
diagSerial->print(F(" *>"));
}
void StringFormatter::lcd(byte row, const FSH* input...) {
va_list args;
// Issue the LCD as a diag first
diag(F("\nLCD%d:"),row);
send(diagSerial,F("\n<* LCD%d:"),row);
va_start(args, input);
send2(diagSerial,input,args);
diag(F("\n"));
send(diagSerial,F(" *>"));
if (!LCDDisplay::lcdDisplay) return;
LCDDisplay::lcdDisplay->setRow(row);

View File

@ -34,7 +34,7 @@ void Turnout::printAll(Print *stream){
bool Turnout::activate(int n,bool state){
#ifdef EESTOREDEBUG
DIAG(F("\nTurnout::activate(%d,%d)\n"),n,state);
DIAG(F("Turnout::activate(%d,%d)"),n,state);
#endif
Turnout * tt=get(n);
if (tt==NULL) return false;
@ -53,7 +53,7 @@ bool Turnout::isActive(int n){
// activate is virtual here so that it can be overridden by a non-DCC turnout mechanism
void Turnout::activate(bool state) {
#ifdef EESTOREDEBUG
DIAG(F("\nTurnout::activate(%d)\n"),state);
DIAG(F("Turnout::activate(%d)"),state);
#endif
if (data.address==LCN_TURNOUT_ADDRESS) {
// A LCN turnout is transmitted to the LCN master.
@ -170,9 +170,9 @@ Turnout *Turnout::create(int id){
#ifdef EESTOREDEBUG
void Turnout::print(Turnout *tt) {
if (tt->data.tStatus & STATUS_PWM )
DIAG(F("Turnout %d ZeroAngle %d MoveAngle %d Status %d\n"),tt->data.id, tt->data.inactiveAngle, tt->data.moveAngle,tt->data.tStatus & STATUS_ACTIVE);
DIAG(F("Turnout %d ZeroAngle %d MoveAngle %d Status %d"),tt->data.id, tt->data.inactiveAngle, tt->data.moveAngle,tt->data.tStatus & STATUS_ACTIVE);
else
DIAG(F("Turnout %d Addr %d Subaddr %d Status %d\n"),tt->data.id, tt->data.address, tt->data.subAddress,tt->data.tStatus & STATUS_ACTIVE);
DIAG(F("Turnout %d Addr %d Subaddr %d Status %d"),tt->data.id, tt->data.address, tt->data.subAddress,tt->data.tStatus & STATUS_ACTIVE);
}
#endif

View File

@ -76,7 +76,7 @@ bool WiThrottle::areYouUsingThrottle(int cab) {
// One instance of WiThrottle per connected client, so we know what the locos are
WiThrottle::WiThrottle( int wificlientid) {
if (Diag::WITHROTTLE) DIAG(F("\n%l Creating new WiThrottle for client %d\n"),millis(),wificlientid);
if (Diag::WITHROTTLE) DIAG(F("%l Creating new WiThrottle for client %d"),millis(),wificlientid);
nextThrottle=firstThrottle;
firstThrottle= this;
clientid=wificlientid;
@ -104,7 +104,7 @@ void WiThrottle::parse(RingStream * stream, byte * cmdx) {
byte * cmd=cmdx;
heartBeat=millis();
if (Diag::WITHROTTLE) DIAG(F("\n%l WiThrottle(%d)<-[%e]\n"),millis(),clientid,cmd);
if (Diag::WITHROTTLE) DIAG(F("%l WiThrottle(%d)<-[%e]"),millis(),clientid,cmd);
if (initSent) {
// Send power state if different than last sent
@ -184,7 +184,7 @@ void WiThrottle::parse(RingStream * stream, byte * cmdx) {
StringFormatter::send(stream, F("M%c-%c%d<;>\n"), myLocos[loco].throttle, LorS(myLocos[loco].cab), myLocos[loco].cab);
}
}
if (Diag::WITHROTTLE) DIAG(F("%l WiThrottle(%d) Quit\n"),millis(),clientid);
if (Diag::WITHROTTLE) DIAG(F("%l WiThrottle(%d) Quit"),millis(),clientid);
delete this;
break;
}
@ -215,7 +215,7 @@ void WiThrottle::multithrottle(RingStream * stream, byte * cmd){
while(*aval !=';' && *aval !='\0') aval++;
if (*aval) aval+=2; // skip ;>
// DIAG(F("\nMultithrottle aval=%c cab=%d"), aval[0],locoid);
// DIAG(F("Multithrottle aval=%c cab=%d"), aval[0],locoid);
switch(cmd[2]) {
case '+': // add loco request
if (cmd[3]=='*') {
@ -272,7 +272,7 @@ void WiThrottle::multithrottle(RingStream * stream, byte * cmd){
void WiThrottle::locoAction(RingStream * stream, byte* aval, char throttleChar, int cab){
// Note cab=-1 for all cabs in the consist called throttleChar.
// DIAG(F("\nLoco Action aval=%c%c throttleChar=%c, cab=%d"), aval[0],aval[1],throttleChar, cab);
// DIAG(F("Loco Action aval=%c%c throttleChar=%c, cab=%d"), aval[0],aval[1],throttleChar, cab);
switch (aval[0]) {
case 'V': // Vspeed
{
@ -366,10 +366,10 @@ void WiThrottle::loop(RingStream * stream) {
void WiThrottle::checkHeartbeat() {
// if eStop time passed... eStop any locos still assigned to this client and then drop the connection
if(heartBeatEnable && (millis()-heartBeat > ESTOP_SECONDS*1000)) {
if (Diag::WITHROTTLE) DIAG(F("\n\n%l WiThrottle(%d) eStop(%ds) timeout, drop connection\n"), millis(), clientid, ESTOP_SECONDS);
if (Diag::WITHROTTLE) DIAG(F("%l WiThrottle(%d) eStop(%ds) timeout, drop connection"), millis(), clientid, ESTOP_SECONDS);
LOOPLOCOS('*', -1) {
if (myLocos[loco].throttle!='\0') {
if (Diag::WITHROTTLE) DIAG(F("%l eStopping cab %d\n"),millis(),myLocos[loco].cab);
if (Diag::WITHROTTLE) DIAG(F("%l eStopping cab %d"),millis(),myLocos[loco].cab);
DCC::setThrottle(myLocos[loco].cab, 1, DCC::getThrottleDirection(myLocos[loco].cab)); // speed 1 is eStop
}
}

View File

@ -64,7 +64,7 @@ void WifiInboundHandler::loop1() {
if (pendingCipsend) {
if (Diag::WIFI) DIAG( F("\nWiFi: [[CIPSEND=%d,%d]]"), clientPendingCIPSEND, currentReplySize);
if (Diag::WIFI) DIAG( F("WiFi: [[CIPSEND=%d,%d]]"), clientPendingCIPSEND, currentReplySize);
StringFormatter::send(wifiStream, F("AT+CIPSEND=%d,%d\r\n"), clientPendingCIPSEND, currentReplySize);
pendingCipsend=false;
return;
@ -75,11 +75,11 @@ void WifiInboundHandler::loop1() {
int clientId=inboundRing->read();
if (clientId>=0) {
int count=inboundRing->count();
if (Diag::WIFI) DIAG(F("\nWifi EXEC: %d %d:"),clientId,count);
if (Diag::WIFI) DIAG(F("Wifi EXEC: %d %d:"),clientId,count);
byte cmd[count+1];
for (int i=0;i<count;i++) cmd[i]=inboundRing->read();
cmd[count]=0;
if (Diag::WIFI) DIAG(F("%e\n"),cmd);
if (Diag::WIFI) DIAG(F("%e"),cmd);
outboundRing->mark(clientId); // remember start of outbound data
CommandDistributor::parse(clientId,cmd,outboundRing);
@ -193,11 +193,11 @@ WifiInboundHandler::INBOUND_STATE WifiInboundHandler::loop2() {
loopState=ANYTHING;
break;
}
if (Diag::WIFI) DIAG(F("\nWifi inbound data(%d:%d):"),runningClientId,dataLength);
if (Diag::WIFI) DIAG(F("Wifi inbound data(%d:%d):"),runningClientId,dataLength);
if (inboundRing->freeSpace()<=(dataLength+1)) {
// This input would overflow the inbound ring, ignore it
loopState=IPD_IGNORE_DATA;
if (Diag::WIFI) DIAG(F("\nWifi OVERFLOW IGNORING:"));
if (Diag::WIFI) DIAG(F("Wifi OVERFLOW IGNORING:"));
break;
}
inboundRing->mark(runningClientId);
@ -243,7 +243,7 @@ WifiInboundHandler::INBOUND_STATE WifiInboundHandler::loop2() {
void WifiInboundHandler::purgeCurrentCIPSEND() {
// A CIPSEND was sent but errored... or the client closed just toss it away
if (Diag::WIFI) DIAG(F("Wifi: DROPPING CIPSEND=%d,%d\n"),clientPendingCIPSEND,currentReplySize);
if (Diag::WIFI) DIAG(F("Wifi: DROPPING CIPSEND=%d,%d"),clientPendingCIPSEND,currentReplySize);
for (int i=0;i<=currentReplySize;i++) outboundRing->read();
pendingCipsend=false;
clientPendingCIPSEND=-1;

View File

@ -118,12 +118,12 @@ wifiSerialState WifiInterface::setup(Stream & setupStream, const FSH* SSid, con
wifiStream = &setupStream;
DIAG(F("\n++ Wifi Setup Try %d ++\n"), ntry);
DIAG(F("++ Wifi Setup Try %d ++"), ntry);
wifiState = setup2( SSid, password, hostname, port, channel);
if (wifiState == WIFI_NOAT) {
DIAG(F("\n++ Wifi Setup NO AT ++\n"));
DIAG(F("++ Wifi Setup NO AT ++"));
return wifiState;
}
@ -133,7 +133,7 @@ wifiSerialState WifiInterface::setup(Stream & setupStream, const FSH* SSid, con
}
DIAG(F("\n++ Wifi Setup %S ++\n"), wifiState == WIFI_CONNECTED ? F("CONNECTED") : F("DISCONNECTED"));
DIAG(F("++ Wifi Setup %S ++"), wifiState == WIFI_CONNECTED ? F("CONNECTED") : F("DISCONNECTED"));
return wifiState;
}
@ -153,7 +153,7 @@ wifiSerialState WifiInterface::setup2(const FSH* SSid, const FSH* password,
// There may alrerady be a connection with data in the pipeline.
// If there is, just shortcut the setup and continue to read the data as normal.
if (checkForOK(200,F("+IPD"), true)) {
DIAG(F("\nPreconfigured Wifi already running with data waiting\n"));
DIAG(F("Preconfigured Wifi already running with data waiting"));
return WIFI_CONNECTED;
}
@ -169,7 +169,7 @@ wifiSerialState WifiInterface::setup2(const FSH* SSid, const FSH* password,
checkForOK(2000, true, false); // Makes this visible on the console
#ifdef DONT_TOUCH_WIFI_CONF
DIAG(F("\nDONT_TOUCH_WIFI_CONF was set: Using existing config\n"));
DIAG(F("DONT_TOUCH_WIFI_CONF was set: Using existing config"));
#else
StringFormatter::send(wifiStream, F("AT+CWMODE=1\r\n")); // configure as "station" = WiFi client
checkForOK(1000, true); // Not always OK, sometimes "no change"
@ -267,7 +267,7 @@ wifiSerialState WifiInterface::setup2(const FSH* SSid, const FSH* password,
}
} while (!checkForOK(WIFI_CONNECT_TIMEOUT, true) && i++<2); // do twice if necessary but ignore failure as AP mode may still be ok
if (i >= 2)
DIAG(F("\nWarning: Setting AP SSID and password failed\n")); // but issue warning
DIAG(F("Warning: Setting AP SSID and password failed")); // but issue warning
if (!oldCmd) {
StringFormatter::send(wifiStream, F("AT+CIPRECVMODE=0\r\n"), port); // make sure transfer mode is correct
@ -306,7 +306,7 @@ wifiSerialState WifiInterface::setup2(const FSH* SSid, const FSH* password,
}
// suck up anything after the IP.
if (!checkForOK(1000, true, false)) return WIFI_DISCONNECTED;
LCD(5,F("PORT=%d\n"),port);
LCD(5,F("PORT=%d"),port);
return WIFI_CONNECTED;
}
@ -324,7 +324,7 @@ void WifiInterface::ATCommand(const byte * command) {
command++;
if (*command=='X') {
connected = true;
DIAG(F("\n++++++ Wifi Connction forced on ++++++++\n"));
DIAG(F("++++++ Wifi Connction forced on ++++++++"));
}
else {
StringFormatter:: send(wifiStream, F("AT+%s\r\n"), command);
@ -341,25 +341,25 @@ bool WifiInterface::checkForOK( const unsigned int timeout, bool echo, bool esc
bool WifiInterface::checkForOK( const unsigned int timeout, const FSH * waitfor, bool echo, bool escapeEcho) {
unsigned long startTime = millis();
char *locator = (char *)waitfor;
DIAG(F("\nWifi Check: [%E]"), waitfor);
DIAG(F("Wifi Check: [%E]"), waitfor);
while ( millis() - startTime < timeout) {
while (wifiStream->available()) {
int ch = wifiStream->read();
if (echo) {
if (escapeEcho) StringFormatter::printEscape( ch); /// THIS IS A DIAG IN DISGUISE
else DIAG(F("%c"), ch);
else StringFormatter::diagSerial->print((char)ch);
}
if (ch != GETFLASH(locator)) locator = (char *)waitfor;
if (ch == GETFLASH(locator)) {
locator++;
if (!GETFLASH(locator)) {
DIAG(F("\nFound in %dms"), millis() - startTime);
DIAG(F("Found in %dms"), millis() - startTime);
return true;
}
}
}
}
DIAG(F("\nTIMEOUT after %dms\n"), timeout);
DIAG(F("TIMEOUT after %dms"), timeout);
return false;
}

View File

@ -3,7 +3,8 @@
#include "StringFormatter.h"
#define VERSION "3.0.7"
#define VERSION "3.0.8"
// 3.0.8 Includes <* > wraps around DIAGs for the benefit of JMRI.
// 3.0.7 Includes merge from assortedBits (many changes) and ACK manager change for lazy decoders
// 3.0.6 Includes:
// Fix Bug that did not let us transmit 5 byte sized packets like PoM