mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-23 16:16:13 +01:00
Compare commits
9 Commits
796d5c4774
...
a508ee7055
Author | SHA1 | Date | |
---|---|---|---|
|
a508ee7055 | ||
|
20ae915eaf | ||
|
35a0bde115 | ||
|
d24d09c37a | ||
|
9ab6b3d4ea | ||
|
d8c282434c | ||
|
43648fd9f4 | ||
|
b5ddade2b3 | ||
|
2e4995cab3 |
1
DCCEX.h
1
DCCEX.h
|
@ -49,6 +49,7 @@
|
||||||
#include "CommandDistributor.h"
|
#include "CommandDistributor.h"
|
||||||
#include "TrackManager.h"
|
#include "TrackManager.h"
|
||||||
#include "DCCTimer.h"
|
#include "DCCTimer.h"
|
||||||
|
#include "KeywordHasher.h"
|
||||||
#include "EXRAIL.h"
|
#include "EXRAIL.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
154
DCCEXParser.cpp
154
DCCEXParser.cpp
|
@ -116,6 +116,7 @@ Once a new OPCODE is decided upon, update this list.
|
||||||
#include "EXRAIL2.h"
|
#include "EXRAIL2.h"
|
||||||
#include "Turntables.h"
|
#include "Turntables.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
#include "KeywordHasher.h"
|
||||||
|
|
||||||
// This macro can't be created easily as a portable function because the
|
// This macro can't be created easily as a portable function because the
|
||||||
// flashlist requires a far pointer for high flash access.
|
// flashlist requires a far pointer for high flash access.
|
||||||
|
@ -126,57 +127,6 @@ Once a new OPCODE is decided upon, update this list.
|
||||||
StringFormatter::send(stream,F(" %d"),value); \
|
StringFormatter::send(stream,F(" %d"),value); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// These keywords are used in the <1> command. The number is what you get if you use the keyword as a parameter.
|
|
||||||
// To discover new keyword numbers , use the <$ YOURKEYWORD> command
|
|
||||||
const int16_t HASH_KEYWORD_MAIN = 11339;
|
|
||||||
const int16_t HASH_KEYWORD_CABS = -11981;
|
|
||||||
const int16_t HASH_KEYWORD_RAM = 25982;
|
|
||||||
const int16_t HASH_KEYWORD_CMD = 9962;
|
|
||||||
const int16_t HASH_KEYWORD_ACK = 3113;
|
|
||||||
const int16_t HASH_KEYWORD_ON = 2657;
|
|
||||||
const int16_t HASH_KEYWORD_DCC = 6436;
|
|
||||||
const int16_t HASH_KEYWORD_SLOW = -17209;
|
|
||||||
#ifndef DISABLE_PROG
|
|
||||||
const int16_t HASH_KEYWORD_JOIN = -30750;
|
|
||||||
const int16_t HASH_KEYWORD_PROG = -29718;
|
|
||||||
const int16_t HASH_KEYWORD_PROGBOOST = -6353;
|
|
||||||
#endif
|
|
||||||
#ifndef DISABLE_EEPROM
|
|
||||||
const int16_t HASH_KEYWORD_EEPROM = -7168;
|
|
||||||
#endif
|
|
||||||
const int16_t HASH_KEYWORD_LIMIT = 27413;
|
|
||||||
const int16_t HASH_KEYWORD_MAX = 16244;
|
|
||||||
const int16_t HASH_KEYWORD_MIN = 15978;
|
|
||||||
const int16_t HASH_KEYWORD_RESET = 26133;
|
|
||||||
const int16_t HASH_KEYWORD_RETRY = 25704;
|
|
||||||
const int16_t HASH_KEYWORD_SPEED28 = -17064;
|
|
||||||
const int16_t HASH_KEYWORD_SPEED128 = 25816;
|
|
||||||
const int16_t HASH_KEYWORD_SERVO=27709;
|
|
||||||
const int16_t HASH_KEYWORD_TT=2688;
|
|
||||||
const int16_t HASH_KEYWORD_VPIN=-415;
|
|
||||||
const int16_t HASH_KEYWORD_A='A';
|
|
||||||
const int16_t HASH_KEYWORD_C='C';
|
|
||||||
const int16_t HASH_KEYWORD_G='G';
|
|
||||||
const int16_t HASH_KEYWORD_H='H';
|
|
||||||
const int16_t HASH_KEYWORD_I='I';
|
|
||||||
const int16_t HASH_KEYWORD_M='M';
|
|
||||||
const int16_t HASH_KEYWORD_O='O';
|
|
||||||
const int16_t HASH_KEYWORD_P='P';
|
|
||||||
const int16_t HASH_KEYWORD_R='R';
|
|
||||||
const int16_t HASH_KEYWORD_T='T';
|
|
||||||
const int16_t HASH_KEYWORD_X='X';
|
|
||||||
const int16_t HASH_KEYWORD_LCN = 15137;
|
|
||||||
const int16_t HASH_KEYWORD_HAL = 10853;
|
|
||||||
const int16_t HASH_KEYWORD_SHOW = -21309;
|
|
||||||
const int16_t HASH_KEYWORD_ANIN = -10424;
|
|
||||||
const int16_t HASH_KEYWORD_ANOUT = -26399;
|
|
||||||
const int16_t HASH_KEYWORD_WIFI = -5583;
|
|
||||||
const int16_t HASH_KEYWORD_ETHERNET = -30767;
|
|
||||||
const int16_t HASH_KEYWORD_WIT = 31594;
|
|
||||||
const int16_t HASH_KEYWORD_EXTT = 8573;
|
|
||||||
const int16_t HASH_KEYWORD_ADD = 3201;
|
|
||||||
|
|
||||||
int16_t DCCEXParser::stashP[MAX_COMMAND_PARAMS];
|
int16_t DCCEXParser::stashP[MAX_COMMAND_PARAMS];
|
||||||
bool DCCEXParser::stashBusy;
|
bool DCCEXParser::stashBusy;
|
||||||
Print *DCCEXParser::stashStream = NULL;
|
Print *DCCEXParser::stashStream = NULL;
|
||||||
|
@ -567,20 +517,20 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
TrackManager::setTrackPower(TRACK_MODE_ALL, POWERMODE::ON);
|
TrackManager::setTrackPower(TRACK_MODE_ALL, POWERMODE::ON);
|
||||||
}
|
}
|
||||||
if (params==1) {
|
if (params==1) {
|
||||||
if (p[0]==HASH_KEYWORD_MAIN) { // <1 MAIN>
|
if (p[0]=="MAIN"_hk) { // <1 MAIN>
|
||||||
TrackManager::setTrackPower(TRACK_MODE_MAIN, POWERMODE::ON);
|
TrackManager::setTrackPower(TRACK_MODE_MAIN, POWERMODE::ON);
|
||||||
}
|
}
|
||||||
#ifndef DISABLE_PROG
|
#ifndef DISABLE_PROG
|
||||||
else if (p[0] == HASH_KEYWORD_JOIN) { // <1 JOIN>
|
else if (p[0] == "JOIN"_hk) { // <1 JOIN>
|
||||||
TrackManager::setJoin(true);
|
TrackManager::setJoin(true);
|
||||||
TrackManager::setTrackPower(TRACK_MODE_MAIN|TRACK_MODE_PROG, POWERMODE::ON);
|
TrackManager::setTrackPower(TRACK_MODE_MAIN|TRACK_MODE_PROG, POWERMODE::ON);
|
||||||
}
|
}
|
||||||
else if (p[0]==HASH_KEYWORD_PROG) { // <1 PROG>
|
else if (p[0]=="PROG"_hk) { // <1 PROG>
|
||||||
TrackManager::setJoin(false);
|
TrackManager::setJoin(false);
|
||||||
TrackManager::setTrackPower(TRACK_MODE_PROG, POWERMODE::ON);
|
TrackManager::setTrackPower(TRACK_MODE_PROG, POWERMODE::ON);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else if (p[0] >= HASH_KEYWORD_A && p[0] <= HASH_KEYWORD_H) { // <1 A-H>
|
else if (p[0] >= "A"_hk && p[0] <= "H"_hk) { // <1 A-H>
|
||||||
byte t = (p[0] - 'A');
|
byte t = (p[0] - 'A');
|
||||||
TrackManager::setTrackPower(POWERMODE::ON, t);
|
TrackManager::setTrackPower(POWERMODE::ON, t);
|
||||||
//StringFormatter::send(stream, F("<p1 %c>\n"), t+'A');
|
//StringFormatter::send(stream, F("<p1 %c>\n"), t+'A');
|
||||||
|
@ -600,17 +550,17 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
TrackManager::setTrackPower(TRACK_MODE_ALL, POWERMODE::OFF);
|
TrackManager::setTrackPower(TRACK_MODE_ALL, POWERMODE::OFF);
|
||||||
}
|
}
|
||||||
if (params==1) {
|
if (params==1) {
|
||||||
if (p[0]==HASH_KEYWORD_MAIN) { // <0 MAIN>
|
if (p[0]=="MAIN"_hk) { // <0 MAIN>
|
||||||
TrackManager::setJoin(false);
|
TrackManager::setJoin(false);
|
||||||
TrackManager::setTrackPower(TRACK_MODE_MAIN, POWERMODE::OFF);
|
TrackManager::setTrackPower(TRACK_MODE_MAIN, POWERMODE::OFF);
|
||||||
}
|
}
|
||||||
#ifndef DISABLE_PROG
|
#ifndef DISABLE_PROG
|
||||||
else if (p[0]==HASH_KEYWORD_PROG) { // <0 PROG>
|
else if (p[0]=="PROG"_hk) { // <0 PROG>
|
||||||
TrackManager::progTrackBoosted=false; // Prog track boost mode will not outlive prog track off
|
TrackManager::progTrackBoosted=false; // Prog track boost mode will not outlive prog track off
|
||||||
TrackManager::setTrackPower(TRACK_MODE_PROG, POWERMODE::OFF);
|
TrackManager::setTrackPower(TRACK_MODE_PROG, POWERMODE::OFF);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else if (p[0] >= HASH_KEYWORD_A && p[0] <= HASH_KEYWORD_H) { // <1 A-H>
|
else if (p[0] >= "A"_hk && p[0] <= "H"_hk) { // <1 A-H>
|
||||||
byte t = (p[0] - 'A');
|
byte t = (p[0] - 'A');
|
||||||
TrackManager::setJoin(false);
|
TrackManager::setJoin(false);
|
||||||
TrackManager::setTrackPower(POWERMODE::OFF, t);
|
TrackManager::setTrackPower(POWERMODE::OFF, t);
|
||||||
|
@ -704,7 +654,7 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
//if ((params<1) | (params>2)) break; // <J>
|
//if ((params<1) | (params>2)) break; // <J>
|
||||||
int16_t id=(params==2)?p[1]:0;
|
int16_t id=(params==2)?p[1]:0;
|
||||||
switch(p[0]) {
|
switch(p[0]) {
|
||||||
case HASH_KEYWORD_C: // <JC mmmm nn> sets time and speed
|
case "C"_hk: // <JC mmmm nn> sets time and speed
|
||||||
if (params==1) { // <JC> returns latest time
|
if (params==1) { // <JC> returns latest time
|
||||||
int16_t x = CommandDistributor::retClockTime();
|
int16_t x = CommandDistributor::retClockTime();
|
||||||
StringFormatter::send(stream, F("<jC %d>\n"), x);
|
StringFormatter::send(stream, F("<jC %d>\n"), x);
|
||||||
|
@ -713,28 +663,28 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
CommandDistributor::setClockTime(p[1], p[2], 1);
|
CommandDistributor::setClockTime(p[1], p[2], 1);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case HASH_KEYWORD_G: // <JG> current gauge limits
|
case "G"_hk: // <JG> current gauge limits
|
||||||
if (params>1) break;
|
if (params>1) break;
|
||||||
TrackManager::reportGauges(stream); // <g limit...limit>
|
TrackManager::reportGauges(stream); // <g limit...limit>
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case HASH_KEYWORD_I: // <JI> current values
|
case "I"_hk: // <JI> current values
|
||||||
if (params>1) break;
|
if (params>1) break;
|
||||||
TrackManager::reportCurrent(stream); // <g limit...limit>
|
TrackManager::reportCurrent(stream); // <g limit...limit>
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case HASH_KEYWORD_A: // <JA> intercepted by EXRAIL// <JA> returns automations/routes
|
case "A"_hk: // <JA> intercepted by EXRAIL// <JA> returns automations/routes
|
||||||
if (params!=1) break; // <JA>
|
if (params!=1) break; // <JA>
|
||||||
StringFormatter::send(stream, F("<jA>\n"));
|
StringFormatter::send(stream, F("<jA>\n"));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case HASH_KEYWORD_M: // <JM> intercepted by EXRAIL
|
case "M"_hk: // <JM> intercepted by EXRAIL
|
||||||
if (params>1) break; // invalid cant do
|
if (params>1) break; // invalid cant do
|
||||||
// <JM> requests stash size so say none.
|
// <JM> requests stash size so say none.
|
||||||
StringFormatter::send(stream,F("<jM 0>\n"));
|
StringFormatter::send(stream,F("<jM 0>\n"));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case HASH_KEYWORD_R: // <JR> returns rosters
|
case "R"_hk: // <JR> returns rosters
|
||||||
StringFormatter::send(stream, F("<jR"));
|
StringFormatter::send(stream, F("<jR"));
|
||||||
#ifdef EXRAIL_ACTIVE
|
#ifdef EXRAIL_ACTIVE
|
||||||
if (params==1) {
|
if (params==1) {
|
||||||
|
@ -753,7 +703,7 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
#endif
|
#endif
|
||||||
StringFormatter::send(stream, F(">\n"));
|
StringFormatter::send(stream, F(">\n"));
|
||||||
return;
|
return;
|
||||||
case HASH_KEYWORD_T: // <JT> returns turnout list
|
case "T"_hk: // <JT> returns turnout list
|
||||||
StringFormatter::send(stream, F("<jT"));
|
StringFormatter::send(stream, F("<jT"));
|
||||||
if (params==1) { // <JT>
|
if (params==1) { // <JT>
|
||||||
for ( Turnout * t=Turnout::first(); t; t=t->next()) {
|
for ( Turnout * t=Turnout::first(); t; t=t->next()) {
|
||||||
|
@ -780,7 +730,7 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
return;
|
return;
|
||||||
// No turntables without HAL support
|
// No turntables without HAL support
|
||||||
#ifndef IO_NO_HAL
|
#ifndef IO_NO_HAL
|
||||||
case HASH_KEYWORD_O: // <JO returns turntable list
|
case "O"_hk: // <JO returns turntable list
|
||||||
StringFormatter::send(stream, F("<jO"));
|
StringFormatter::send(stream, F("<jO"));
|
||||||
if (params==1) { // <JO>
|
if (params==1) { // <JO>
|
||||||
for (Turntable * tto=Turntable::first(); tto; tto=tto->next()) {
|
for (Turntable * tto=Turntable::first(); tto; tto=tto->next()) {
|
||||||
|
@ -805,7 +755,7 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case HASH_KEYWORD_P: // <JP id> returns turntable position list for the turntable id
|
case "P"_hk: // <JP id> returns turntable position list for the turntable id
|
||||||
if (params==2) { // <JP id>
|
if (params==2) { // <JP id>
|
||||||
Turntable *tto=Turntable::get(id);
|
Turntable *tto=Turntable::get(id);
|
||||||
if (!tto || tto->isHidden()) {
|
if (!tto || tto->isHidden()) {
|
||||||
|
@ -972,14 +922,14 @@ bool DCCEXParser::parseT(Print *stream, int16_t params, int16_t p[])
|
||||||
switch (p[1]) {
|
switch (p[1]) {
|
||||||
// Turnout messages use 1=throw, 0=close.
|
// Turnout messages use 1=throw, 0=close.
|
||||||
case 0:
|
case 0:
|
||||||
case HASH_KEYWORD_C:
|
case "C"_hk:
|
||||||
state = true;
|
state = true;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
case HASH_KEYWORD_T:
|
case "T"_hk:
|
||||||
state= false;
|
state= false;
|
||||||
break;
|
break;
|
||||||
case HASH_KEYWORD_X:
|
case "X"_hk:
|
||||||
{
|
{
|
||||||
Turnout *tt = Turnout::get(p[0]);
|
Turnout *tt = Turnout::get(p[0]);
|
||||||
if (tt) {
|
if (tt) {
|
||||||
|
@ -996,14 +946,14 @@ bool DCCEXParser::parseT(Print *stream, int16_t params, int16_t p[])
|
||||||
}
|
}
|
||||||
|
|
||||||
default: // Anything else is some kind of turnout create function.
|
default: // Anything else is some kind of turnout create function.
|
||||||
if (params == 6 && p[1] == HASH_KEYWORD_SERVO) { // <T id SERVO n n n n>
|
if (params == 6 && p[1] == "SERVO"_hk) { // <T id SERVO n n n n>
|
||||||
if (!ServoTurnout::create(p[0], (VPIN)p[2], (uint16_t)p[3], (uint16_t)p[4], (uint8_t)p[5]))
|
if (!ServoTurnout::create(p[0], (VPIN)p[2], (uint16_t)p[3], (uint16_t)p[4], (uint8_t)p[5]))
|
||||||
return false;
|
return false;
|
||||||
} else
|
} else
|
||||||
if (params == 3 && p[1] == HASH_KEYWORD_VPIN) { // <T id VPIN n>
|
if (params == 3 && p[1] == "VPIN"_hk) { // <T id VPIN n>
|
||||||
if (!VpinTurnout::create(p[0], p[2])) return false;
|
if (!VpinTurnout::create(p[0], p[2])) return false;
|
||||||
} else
|
} else
|
||||||
if (params >= 3 && p[1] == HASH_KEYWORD_DCC) {
|
if (params >= 3 && p[1] == "DCC"_hk) {
|
||||||
// <T id DCC addr subadd> 0<=addr<=511, 0<=subadd<=3 (like <a> command).<T>
|
// <T id DCC addr subadd> 0<=addr<=511, 0<=subadd<=3 (like <a> command).<T>
|
||||||
if (params==4 && p[2]>=0 && p[2]<512 && p[3]>=0 && p[3]<4) { // <T id DCC n m>
|
if (params==4 && p[2]>=0 && p[2]<512 && p[3]>=0 && p[3]<4) { // <T id DCC n m>
|
||||||
if (!DCCTurnout::create(p[0], p[2], p[3])) return false;
|
if (!DCCTurnout::create(p[0], p[2], p[3])) return false;
|
||||||
|
@ -1069,41 +1019,41 @@ bool DCCEXParser::parseC(Print *stream, int16_t params, int16_t p[]) {
|
||||||
switch (p[0])
|
switch (p[0])
|
||||||
{
|
{
|
||||||
#ifndef DISABLE_PROG
|
#ifndef DISABLE_PROG
|
||||||
case HASH_KEYWORD_PROGBOOST:
|
case "PROGBOOST"_hk:
|
||||||
TrackManager::progTrackBoosted=true;
|
TrackManager::progTrackBoosted=true;
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
case HASH_KEYWORD_RESET:
|
case "RESET"_hk:
|
||||||
DCCTimer::reset();
|
DCCTimer::reset();
|
||||||
break; // and <X> if we didnt restart
|
break; // and <X> if we didnt restart
|
||||||
case HASH_KEYWORD_SPEED28:
|
case "SPEED28"_hk:
|
||||||
DCC::setGlobalSpeedsteps(28);
|
DCC::setGlobalSpeedsteps(28);
|
||||||
DIAG(F("28 Speedsteps"));
|
DIAG(F("28 Speedsteps"));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case HASH_KEYWORD_SPEED128:
|
case "SPEED128"_hk:
|
||||||
DCC::setGlobalSpeedsteps(128);
|
DCC::setGlobalSpeedsteps(128);
|
||||||
DIAG(F("128 Speedsteps"));
|
DIAG(F("128 Speedsteps"));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
#ifndef DISABLE_PROG
|
#ifndef DISABLE_PROG
|
||||||
case HASH_KEYWORD_ACK: // <D ACK ON/OFF> <D ACK [LIMIT|MIN|MAX|RETRY] Value>
|
case "ACK"_hk: // <D ACK ON/OFF> <D ACK [LIMIT|MIN|MAX|RETRY] Value>
|
||||||
if (params >= 3) {
|
if (params >= 3) {
|
||||||
if (p[1] == HASH_KEYWORD_LIMIT) {
|
if (p[1] == "LIMIT"_hk) {
|
||||||
DCCACK::setAckLimit(p[2]);
|
DCCACK::setAckLimit(p[2]);
|
||||||
LCD(1, F("Ack Limit=%dmA"), p[2]); // <D ACK LIMIT 42>
|
LCD(1, F("Ack Limit=%dmA"), p[2]); // <D ACK LIMIT 42>
|
||||||
} else if (p[1] == HASH_KEYWORD_MIN) {
|
} else if (p[1] == "MIN"_hk) {
|
||||||
DCCACK::setMinAckPulseDuration(p[2]);
|
DCCACK::setMinAckPulseDuration(p[2]);
|
||||||
LCD(0, F("Ack Min=%uus"), p[2]); // <D ACK MIN 1500>
|
LCD(0, F("Ack Min=%uus"), p[2]); // <D ACK MIN 1500>
|
||||||
} else if (p[1] == HASH_KEYWORD_MAX) {
|
} else if (p[1] == "MAX"_hk) {
|
||||||
DCCACK::setMaxAckPulseDuration(p[2]);
|
DCCACK::setMaxAckPulseDuration(p[2]);
|
||||||
LCD(0, F("Ack Max=%uus"), p[2]); // <D ACK MAX 9000>
|
LCD(0, F("Ack Max=%uus"), p[2]); // <D ACK MAX 9000>
|
||||||
} else if (p[1] == HASH_KEYWORD_RETRY) {
|
} else if (p[1] == "RETRY"_hk) {
|
||||||
if (p[2] >255) p[2]=3;
|
if (p[2] >255) p[2]=3;
|
||||||
LCD(0, F("Ack Retry=%d Sum=%d"), p[2], DCCACK::setAckRetry(p[2])); // <D ACK RETRY 2>
|
LCD(0, F("Ack Retry=%d Sum=%d"), p[2], DCCACK::setAckRetry(p[2])); // <D ACK RETRY 2>
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bool onOff = (params > 0) && (p[1] == 1 || p[1] == HASH_KEYWORD_ON); // dont care if other stuff or missing... just means off
|
bool onOff = (params > 0) && (p[1] == 1 || p[1] == "ON"_hk); // dont care if other stuff or missing... just means off
|
||||||
|
|
||||||
DIAG(F("Ack diag %S"), onOff ? F("on") : F("off"));
|
DIAG(F("Ack diag %S"), onOff ? F("on") : F("off"));
|
||||||
Diag::ACK = onOff;
|
Diag::ACK = onOff;
|
||||||
|
@ -1121,64 +1071,64 @@ bool DCCEXParser::parseD(Print *stream, int16_t params, int16_t p[])
|
||||||
{
|
{
|
||||||
if (params == 0)
|
if (params == 0)
|
||||||
return false;
|
return false;
|
||||||
bool onOff = (params > 0) && (p[1] == 1 || p[1] == HASH_KEYWORD_ON); // dont care if other stuff or missing... just means off
|
bool onOff = (params > 0) && (p[1] == 1 || p[1] == "ON"_hk); // dont care if other stuff or missing... just means off
|
||||||
switch (p[0])
|
switch (p[0])
|
||||||
{
|
{
|
||||||
case HASH_KEYWORD_CABS: // <D CABS>
|
case "CABS"_hk: // <D CABS>
|
||||||
DCC::displayCabList(stream);
|
DCC::displayCabList(stream);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case HASH_KEYWORD_RAM: // <D RAM>
|
case "RAM"_hk: // <D RAM>
|
||||||
DIAG(F("Free memory=%d"), DCCTimer::getMinimumFreeMemory());
|
DIAG(F("Free memory=%d"), DCCTimer::getMinimumFreeMemory());
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case HASH_KEYWORD_CMD: // <D CMD ON/OFF>
|
case "CMD"_hk: // <D CMD ON/OFF>
|
||||||
Diag::CMD = onOff;
|
Diag::CMD = onOff;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
#ifdef HAS_ENOUGH_MEMORY
|
#ifdef HAS_ENOUGH_MEMORY
|
||||||
case HASH_KEYWORD_WIFI: // <D WIFI ON/OFF>
|
case "WIFI"_hk: // <D WIFI ON/OFF>
|
||||||
Diag::WIFI = onOff;
|
Diag::WIFI = onOff;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case HASH_KEYWORD_ETHERNET: // <D ETHERNET ON/OFF>
|
case "ETHERNET"_hk: // <D ETHERNET ON/OFF>
|
||||||
Diag::ETHERNET = onOff;
|
Diag::ETHERNET = onOff;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case HASH_KEYWORD_WIT: // <D WIT ON/OFF>
|
case "WIT"_hk: // <D WIT ON/OFF>
|
||||||
Diag::WITHROTTLE = onOff;
|
Diag::WITHROTTLE = onOff;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case HASH_KEYWORD_LCN: // <D LCN ON/OFF>
|
case "LCN"_hk: // <D LCN ON/OFF>
|
||||||
Diag::LCN = onOff;
|
Diag::LCN = onOff;
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
#ifndef DISABLE_EEPROM
|
#ifndef DISABLE_EEPROM
|
||||||
case HASH_KEYWORD_EEPROM: // <D EEPROM NumEntries>
|
case "EEPROM"_hk: // <D EEPROM NumEntries>
|
||||||
if (params >= 2)
|
if (params >= 2)
|
||||||
EEStore::dump(p[1]);
|
EEStore::dump(p[1]);
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
case HASH_KEYWORD_SERVO: // <D SERVO vpin position [profile]>
|
case "SERVO"_hk: // <D SERVO vpin position [profile]>
|
||||||
|
|
||||||
case HASH_KEYWORD_ANOUT: // <D ANOUT vpin position [profile]>
|
case "ANOUT"_hk: // <D ANOUT vpin position [profile]>
|
||||||
IODevice::writeAnalogue(p[1], p[2], params>3 ? p[3] : 0);
|
IODevice::writeAnalogue(p[1], p[2], params>3 ? p[3] : 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HASH_KEYWORD_ANIN: // <D ANIN vpin> Display analogue input value
|
case "ANIN"_hk: // <D ANIN vpin> Display analogue input value
|
||||||
DIAG(F("VPIN=%u value=%d"), p[1], IODevice::readAnalogue(p[1]));
|
DIAG(F("VPIN=%u value=%d"), p[1], IODevice::readAnalogue(p[1]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if !defined(IO_NO_HAL)
|
#if !defined(IO_NO_HAL)
|
||||||
case HASH_KEYWORD_HAL:
|
case "HAL"_hk:
|
||||||
if (p[1] == HASH_KEYWORD_SHOW)
|
if (p[1] == "SHOW"_hk)
|
||||||
IODevice::DumpAll();
|
IODevice::DumpAll();
|
||||||
else if (p[1] == HASH_KEYWORD_RESET)
|
else if (p[1] == "RESET"_hk)
|
||||||
IODevice::reset();
|
IODevice::reset();
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case HASH_KEYWORD_TT: // <D TT vpin steps activity>
|
case "TT"_hk: // <D TT vpin steps activity>
|
||||||
IODevice::writeAnalogue(p[1], p[2], params>3 ? p[3] : 0);
|
IODevice::writeAnalogue(p[1], p[2], params>3 ? p[3] : 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1232,7 +1182,7 @@ bool DCCEXParser::parseI(Print *stream, int16_t params, int16_t p[])
|
||||||
case 3: // <I id position activity> | <I id DCC home> - rotate to position for EX-Turntable or create DCC turntable
|
case 3: // <I id position activity> | <I id DCC home> - rotate to position for EX-Turntable or create DCC turntable
|
||||||
{
|
{
|
||||||
Turntable *tto = Turntable::get(p[0]);
|
Turntable *tto = Turntable::get(p[0]);
|
||||||
if (p[1] == HASH_KEYWORD_DCC) {
|
if (p[1] == "DCC"_hk) {
|
||||||
if (tto || p[2] < 0 || p[2] > 3600) return false;
|
if (tto || p[2] < 0 || p[2] > 3600) return false;
|
||||||
if (!DCCTurntable::create(p[0])) return false;
|
if (!DCCTurntable::create(p[0])) return false;
|
||||||
Turntable *tto = Turntable::get(p[0]);
|
Turntable *tto = Turntable::get(p[0]);
|
||||||
|
@ -1249,7 +1199,7 @@ bool DCCEXParser::parseI(Print *stream, int16_t params, int16_t p[])
|
||||||
case 4: // <I id EXTT vpin home> create an EXTT turntable
|
case 4: // <I id EXTT vpin home> create an EXTT turntable
|
||||||
{
|
{
|
||||||
Turntable *tto = Turntable::get(p[0]);
|
Turntable *tto = Turntable::get(p[0]);
|
||||||
if (p[1] == HASH_KEYWORD_EXTT) {
|
if (p[1] == "EXTT"_hk) {
|
||||||
if (tto || p[3] < 0 || p[3] > 3600) return false;
|
if (tto || p[3] < 0 || p[3] > 3600) return false;
|
||||||
if (!EXTTTurntable::create(p[0], (VPIN)p[2])) return false;
|
if (!EXTTTurntable::create(p[0], (VPIN)p[2])) return false;
|
||||||
Turntable *tto = Turntable::get(p[0]);
|
Turntable *tto = Turntable::get(p[0]);
|
||||||
|
@ -1264,7 +1214,7 @@ bool DCCEXParser::parseI(Print *stream, int16_t params, int16_t p[])
|
||||||
case 5: // <I id ADD position value angle> add a position
|
case 5: // <I id ADD position value angle> add a position
|
||||||
{
|
{
|
||||||
Turntable *tto = Turntable::get(p[0]);
|
Turntable *tto = Turntable::get(p[0]);
|
||||||
if (p[1] == HASH_KEYWORD_ADD) {
|
if (p[1] == "ADD"_hk) {
|
||||||
// tto must exist, no more than 48 positions, angle 0 - 3600
|
// tto must exist, no more than 48 positions, angle 0 - 3600
|
||||||
if (!tto || p[2] > 48 || p[4] < 0 || p[4] > 3600) return false;
|
if (!tto || p[2] > 48 || p[4] < 0 || p[4] > 3600) return false;
|
||||||
tto->addPosition(p[2], p[3], p[4]);
|
tto->addPosition(p[2], p[3], p[4]);
|
||||||
|
|
|
@ -28,25 +28,7 @@
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "EXRAIL2.h"
|
#include "EXRAIL2.h"
|
||||||
#include "DCC.h"
|
#include "DCC.h"
|
||||||
// Command parsing keywords
|
#include "KeywordHasher.h"
|
||||||
const int16_t HASH_KEYWORD_EXRAIL=15435;
|
|
||||||
const int16_t HASH_KEYWORD_ON = 2657;
|
|
||||||
const int16_t HASH_KEYWORD_START=23232;
|
|
||||||
const int16_t HASH_KEYWORD_RESERVE=11392;
|
|
||||||
const int16_t HASH_KEYWORD_FREE=-23052;
|
|
||||||
const int16_t HASH_KEYWORD_LATCH=1618;
|
|
||||||
const int16_t HASH_KEYWORD_UNLATCH=1353;
|
|
||||||
const int16_t HASH_KEYWORD_PAUSE=-4142;
|
|
||||||
const int16_t HASH_KEYWORD_RESUME=27609;
|
|
||||||
const int16_t HASH_KEYWORD_KILL=5218;
|
|
||||||
const int16_t HASH_KEYWORD_ALL=3457;
|
|
||||||
const int16_t HASH_KEYWORD_ROUTES=-3702;
|
|
||||||
const int16_t HASH_KEYWORD_RED=26099;
|
|
||||||
const int16_t HASH_KEYWORD_AMBER=18713;
|
|
||||||
const int16_t HASH_KEYWORD_GREEN=-31493;
|
|
||||||
const int16_t HASH_KEYWORD_A='A';
|
|
||||||
const int16_t HASH_KEYWORD_M='M';
|
|
||||||
|
|
||||||
|
|
||||||
// This filter intercepts <> commands to do the following:
|
// This filter intercepts <> commands to do the following:
|
||||||
// - Implement RMFT specific commands/diagnostics
|
// - Implement RMFT specific commands/diagnostics
|
||||||
|
@ -58,8 +40,8 @@ void RMFT2::ComandFilter(Print * stream, byte & opcode, byte & paramCount, int16
|
||||||
switch(opcode) {
|
switch(opcode) {
|
||||||
|
|
||||||
case 'D':
|
case 'D':
|
||||||
if (p[0]==HASH_KEYWORD_EXRAIL) { // <D EXRAIL ON/OFF>
|
if (p[0]=="EXRAIL"_hk) { // <D EXRAIL ON/OFF>
|
||||||
diag = paramCount==2 && (p[1]==HASH_KEYWORD_ON || p[1]==1);
|
diag = paramCount==2 && (p[1]=="ON"_hk || p[1]==1);
|
||||||
opcode=0;
|
opcode=0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -125,7 +107,7 @@ void RMFT2::ComandFilter(Print * stream, byte & opcode, byte & paramCount, int16
|
||||||
case 'J': // throttle info commands
|
case 'J': // throttle info commands
|
||||||
if (paramCount<1) return;
|
if (paramCount<1) return;
|
||||||
switch(p[0]) {
|
switch(p[0]) {
|
||||||
case HASH_KEYWORD_A: // <JA> returns automations/routes
|
case "A"_hk: // <JA> returns automations/routes
|
||||||
if (paramCount==1) {// <JA>
|
if (paramCount==1) {// <JA>
|
||||||
StringFormatter::send(stream, F("<jA"));
|
StringFormatter::send(stream, F("<jA"));
|
||||||
routeLookup->stream(stream);
|
routeLookup->stream(stream);
|
||||||
|
@ -152,7 +134,7 @@ void RMFT2::ComandFilter(Print * stream, byte & opcode, byte & paramCount, int16
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HASH_KEYWORD_M:
|
case "M"_hk:
|
||||||
// NOTE: we only need to handle valid calls here because
|
// NOTE: we only need to handle valid calls here because
|
||||||
// DCCEXParser has to have code to handle the <J<> cases where
|
// DCCEXParser has to have code to handle the <J<> cases where
|
||||||
// exrail isnt involved anyway.
|
// exrail isnt involved anyway.
|
||||||
|
@ -236,13 +218,13 @@ bool RMFT2::parseSlash(Print * stream, byte & paramCount, int16_t p[]) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
switch (p[0]) {
|
switch (p[0]) {
|
||||||
case HASH_KEYWORD_PAUSE: // </ PAUSE>
|
case "PAUSE"_hk: // </ PAUSE>
|
||||||
if (paramCount!=1) return false;
|
if (paramCount!=1) return false;
|
||||||
DCC::setThrottle(0,1,true); // pause all locos on the track
|
DCC::setThrottle(0,1,true); // pause all locos on the track
|
||||||
pausingTask=(RMFT2 *)1; // Impossible task address
|
pausingTask=(RMFT2 *)1; // Impossible task address
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case HASH_KEYWORD_RESUME: // </ RESUME>
|
case "RESUME"_hk: // </ RESUME>
|
||||||
if (paramCount!=1) return false;
|
if (paramCount!=1) return false;
|
||||||
pausingTask=NULL;
|
pausingTask=NULL;
|
||||||
{
|
{
|
||||||
|
@ -256,7 +238,7 @@ bool RMFT2::parseSlash(Print * stream, byte & paramCount, int16_t p[]) {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
||||||
case HASH_KEYWORD_START: // </ START [cab] route >
|
case "START"_hk: // </ START [cab] route >
|
||||||
if (paramCount<2 || paramCount>3) return false;
|
if (paramCount<2 || paramCount>3) return false;
|
||||||
{
|
{
|
||||||
int route=(paramCount==2) ? p[1] : p[2];
|
int route=(paramCount==2) ? p[1] : p[2];
|
||||||
|
@ -273,7 +255,7 @@ bool RMFT2::parseSlash(Print * stream, byte & paramCount, int16_t p[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check KILL ALL here, otherwise the next validation confuses ALL with a flag
|
// check KILL ALL here, otherwise the next validation confuses ALL with a flag
|
||||||
if (p[0]==HASH_KEYWORD_KILL && p[1]==HASH_KEYWORD_ALL) {
|
if (p[0]=="KILL"_hk && p[1]=="ALL"_hk) {
|
||||||
while (loopTask) loopTask->kill(F("KILL ALL")); // destructor changes loopTask
|
while (loopTask) loopTask->kill(F("KILL ALL")); // destructor changes loopTask
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -282,7 +264,7 @@ bool RMFT2::parseSlash(Print * stream, byte & paramCount, int16_t p[]) {
|
||||||
if (paramCount!=2 ) return false;
|
if (paramCount!=2 ) return false;
|
||||||
|
|
||||||
switch (p[0]) {
|
switch (p[0]) {
|
||||||
case HASH_KEYWORD_KILL: // Kill taskid|ALL
|
case "KILL"_hk: // Kill taskid|ALL
|
||||||
{
|
{
|
||||||
if ( p[1]<0 || p[1]>=MAX_FLAGS) return false;
|
if ( p[1]<0 || p[1]>=MAX_FLAGS) return false;
|
||||||
RMFT2 * task=loopTask;
|
RMFT2 * task=loopTask;
|
||||||
|
@ -297,27 +279,27 @@ bool RMFT2::parseSlash(Print * stream, byte & paramCount, int16_t p[]) {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
case HASH_KEYWORD_RESERVE: // force reserve a section
|
case "RESERVE"_hk: // force reserve a section
|
||||||
return setFlag(p[1],SECTION_FLAG);
|
return setFlag(p[1],SECTION_FLAG);
|
||||||
|
|
||||||
case HASH_KEYWORD_FREE: // force free a section
|
case "FREE"_hk: // force free a section
|
||||||
return setFlag(p[1],0,SECTION_FLAG);
|
return setFlag(p[1],0,SECTION_FLAG);
|
||||||
|
|
||||||
case HASH_KEYWORD_LATCH:
|
case "LATCH"_hk:
|
||||||
return setFlag(p[1], LATCH_FLAG);
|
return setFlag(p[1], LATCH_FLAG);
|
||||||
|
|
||||||
case HASH_KEYWORD_UNLATCH:
|
case "UNLATCH"_hk:
|
||||||
return setFlag(p[1], 0, LATCH_FLAG);
|
return setFlag(p[1], 0, LATCH_FLAG);
|
||||||
|
|
||||||
case HASH_KEYWORD_RED:
|
case "RED"_hk:
|
||||||
doSignal(p[1],SIGNAL_RED);
|
doSignal(p[1],SIGNAL_RED);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case HASH_KEYWORD_AMBER:
|
case "AMBER"_hk:
|
||||||
doSignal(p[1],SIGNAL_AMBER);
|
doSignal(p[1],SIGNAL_AMBER);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case HASH_KEYWORD_GREEN:
|
case "GREEN"_hk:
|
||||||
doSignal(p[1],SIGNAL_GREEN);
|
doSignal(p[1],SIGNAL_GREEN);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,10 @@ void EthernetInterface::setup()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef IP_ADDRESS
|
||||||
|
static IPAddress myIP(IP_ADDRESS);
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Aquire IP Address from DHCP and start server
|
* @brief Aquire IP Address from DHCP and start server
|
||||||
*
|
*
|
||||||
|
@ -60,14 +64,14 @@ EthernetInterface::EthernetInterface()
|
||||||
connected=false;
|
connected=false;
|
||||||
|
|
||||||
#ifdef IP_ADDRESS
|
#ifdef IP_ADDRESS
|
||||||
if (Ethernet.begin(mac, IP_ADDRESS) == 0)
|
Ethernet.begin(mac, myIP);
|
||||||
#else
|
#else
|
||||||
if (Ethernet.begin(mac) == 0)
|
if (Ethernet.begin(mac) == 0)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
DIAG(F("Ethernet.begin FAILED"));
|
DIAG(F("Ethernet.begin FAILED"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
|
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
|
||||||
DIAG(F("Ethernet shield not found or W5100"));
|
DIAG(F("Ethernet shield not found or W5100"));
|
||||||
}
|
}
|
||||||
|
@ -136,7 +140,7 @@ bool EthernetInterface::checkLink() {
|
||||||
DIAG(F("Ethernet cable connected"));
|
DIAG(F("Ethernet cable connected"));
|
||||||
connected=true;
|
connected=true;
|
||||||
#ifdef IP_ADDRESS
|
#ifdef IP_ADDRESS
|
||||||
Ethernet.setLocalIP(IP_ADDRESS); // for static IP, set it again
|
Ethernet.setLocalIP(myIP); // for static IP, set it again
|
||||||
#endif
|
#endif
|
||||||
IPAddress ip = Ethernet.localIP(); // look what IP was obtained (dynamic or static)
|
IPAddress ip = Ethernet.localIP(); // look what IP was obtained (dynamic or static)
|
||||||
server = new EthernetServer(IP_PORT); // Ethernet Server listening on default port IP_PORT
|
server = new EthernetServer(IP_PORT); // Ethernet Server listening on default port IP_PORT
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
#define GITHUB_SHA "devel-202401100719Z"
|
#define GITHUB_SHA "devel-202401101409Z"
|
||||||
|
|
|
@ -110,7 +110,6 @@ void I2CManagerClass::I2C_setClock(uint32_t i2cClockSpeed) {
|
||||||
// Calculate a rise time appropriate to the requested bus speed
|
// Calculate a rise time appropriate to the requested bus speed
|
||||||
// Use 10x the rise time spec to enable integer divide of 50ns clock period
|
// Use 10x the rise time spec to enable integer divide of 50ns clock period
|
||||||
uint16_t t_rise;
|
uint16_t t_rise;
|
||||||
uint32_t ccr_freq;
|
|
||||||
|
|
||||||
while (s->CR1 & I2C_CR1_STOP); // Prevents lockup by guarding further
|
while (s->CR1 & I2C_CR1_STOP); // Prevents lockup by guarding further
|
||||||
// writes to CR1 while STOP is being executed!
|
// writes to CR1 while STOP is being executed!
|
||||||
|
|
57
KeywordHasher.h
Normal file
57
KeywordHasher.h
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
/*
|
||||||
|
* © 2024 Vincent Hamp and Chris Harlow
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This file is part of CommandStation-EX
|
||||||
|
*
|
||||||
|
* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* Reader be aware:
|
||||||
|
This function implements the _hk data type so that a string keyword
|
||||||
|
is hashed to the same value as the DCCEXParser uses to hash incoming
|
||||||
|
keywords.
|
||||||
|
Thus "MAIN"_hk generates exactly the same run time vakue
|
||||||
|
as const int16_t HASH_KEYWORD_MAIN=11339
|
||||||
|
*/
|
||||||
|
#ifndef KeywordHAsher_h
|
||||||
|
#define KeywordHasher_h
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
constexpr uint16_t CompiletimeKeywordHasher(const char * sv, uint16_t running=0) {
|
||||||
|
return (*sv==0) ? running : CompiletimeKeywordHasher(sv+1,
|
||||||
|
(*sv >= '0' && *sv <= '9')
|
||||||
|
? (10*running+*sv-'0') // Numeric hash
|
||||||
|
: ((running << 5) + running) ^ *sv
|
||||||
|
); //
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr int16_t operator""_hk(const char * keyword, size_t len)
|
||||||
|
{
|
||||||
|
return (int16_t) CompiletimeKeywordHasher(keyword,len*0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Some historical values for testing:
|
||||||
|
const int16_t HASH_KEYWORD_MAIN = 11339;
|
||||||
|
const int16_t HASH_KEYWORD_SLOW = -17209;
|
||||||
|
const int16_t HASH_KEYWORD_SPEED28 = -17064;
|
||||||
|
const int16_t HASH_KEYWORD_SPEED128 = 25816;
|
||||||
|
*/
|
||||||
|
|
||||||
|
static_assert("MAIN"_hk == 11339,"Keyword hasher error");
|
||||||
|
static_assert("SLOW"_hk == -17209,"Keyword hasher error");
|
||||||
|
static_assert("SPEED28"_hk == -17064,"Keyword hasher error");
|
||||||
|
static_assert("SPEED128"_hk == 25816,"Keyword hasher error");
|
||||||
|
#endif
|
|
@ -28,6 +28,7 @@
|
||||||
#include "DIAG.h"
|
#include "DIAG.h"
|
||||||
#include "CommandDistributor.h"
|
#include "CommandDistributor.h"
|
||||||
#include "DCCEXParser.h"
|
#include "DCCEXParser.h"
|
||||||
|
#include "KeywordHasher.h"
|
||||||
// Virtualised Motor shield multi-track hardware Interface
|
// Virtualised Motor shield multi-track hardware Interface
|
||||||
#define FOR_EACH_TRACK(t) for (byte t=0;t<=lastTrack;t++)
|
#define FOR_EACH_TRACK(t) for (byte t=0;t<=lastTrack;t++)
|
||||||
|
|
||||||
|
@ -35,21 +36,6 @@
|
||||||
FOR_EACH_TRACK(t) \
|
FOR_EACH_TRACK(t) \
|
||||||
if (track[t]->getMode()==findmode) \
|
if (track[t]->getMode()==findmode) \
|
||||||
track[t]->function;
|
track[t]->function;
|
||||||
#ifndef DISABLE_PROG
|
|
||||||
const int16_t HASH_KEYWORD_PROG = -29718;
|
|
||||||
#endif
|
|
||||||
const int16_t HASH_KEYWORD_MAIN = 11339;
|
|
||||||
const int16_t HASH_KEYWORD_OFF = 22479;
|
|
||||||
const int16_t HASH_KEYWORD_NONE = -26550;
|
|
||||||
const int16_t HASH_KEYWORD_DC = 2183;
|
|
||||||
const int16_t HASH_KEYWORD_DCX = 6463; // DC reversed polarity
|
|
||||||
const int16_t HASH_KEYWORD_EXT = 8201; // External DCC signal
|
|
||||||
const int16_t HASH_KEYWORD_A = 65; // parser makes single chars the ascii.
|
|
||||||
const int16_t HASH_KEYWORD_AUTO = -5457;
|
|
||||||
#ifdef BOOSTER_INPUT
|
|
||||||
const int16_t HASH_KEYWORD_BOOST = 11269;
|
|
||||||
#endif
|
|
||||||
const int16_t HASH_KEYWORD_INV = 11857;
|
|
||||||
|
|
||||||
MotorDriver * TrackManager::track[MAX_TRACKS];
|
MotorDriver * TrackManager::track[MAX_TRACKS];
|
||||||
int16_t TrackManager::trackDCAddr[MAX_TRACKS];
|
int16_t TrackManager::trackDCAddr[MAX_TRACKS];
|
||||||
|
@ -362,38 +348,38 @@ bool TrackManager::parseEqualSign(Print *stream, int16_t params, int16_t p[])
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p[0]-=HASH_KEYWORD_A; // convert A... to 0....
|
p[0]-="A"_hk; // convert A... to 0....
|
||||||
|
|
||||||
if (params>1 && (p[0]<0 || p[0]>=MAX_TRACKS))
|
if (params>1 && (p[0]<0 || p[0]>=MAX_TRACKS))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (params==2 && p[1]==HASH_KEYWORD_MAIN) // <= id MAIN>
|
if (params==2 && p[1]=="MAIN"_hk) // <= id MAIN>
|
||||||
return setTrackMode(p[0],TRACK_MODE_MAIN);
|
return setTrackMode(p[0],TRACK_MODE_MAIN);
|
||||||
|
|
||||||
#ifndef DISABLE_PROG
|
#ifndef DISABLE_PROG
|
||||||
if (params==2 && p[1]==HASH_KEYWORD_PROG) // <= id PROG>
|
if (params==2 && p[1]=="PROG"_hk) // <= id PROG>
|
||||||
return setTrackMode(p[0],TRACK_MODE_PROG);
|
return setTrackMode(p[0],TRACK_MODE_PROG);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (params==2 && (p[1]==HASH_KEYWORD_OFF || p[1]==HASH_KEYWORD_NONE)) // <= id OFF> <= id NONE>
|
if (params==2 && (p[1]=="OFF"_hk || p[1]=="NONE"_hk)) // <= id OFF> <= id NONE>
|
||||||
return setTrackMode(p[0],TRACK_MODE_NONE);
|
return setTrackMode(p[0],TRACK_MODE_NONE);
|
||||||
|
|
||||||
if (params==2 && p[1]==HASH_KEYWORD_EXT) // <= id EXT>
|
if (params==2 && p[1]=="EXT"_hk) // <= id EXT>
|
||||||
return setTrackMode(p[0],TRACK_MODE_EXT);
|
return setTrackMode(p[0],TRACK_MODE_EXT);
|
||||||
#ifdef BOOSTER_INPUT
|
#ifdef BOOSTER_INPUT
|
||||||
if (params==2 && p[1]==HASH_KEYWORD_BOOST) // <= id BOOST>
|
if (params==2 && p[1]=="BOOST"_hk) // <= id BOOST>
|
||||||
return setTrackMode(p[0],TRACK_MODE_BOOST);
|
return setTrackMode(p[0],TRACK_MODE_BOOST);
|
||||||
#endif
|
#endif
|
||||||
if (params==2 && p[1]==HASH_KEYWORD_AUTO) // <= id AUTO>
|
if (params==2 && p[1]=="AUTO"_hk) // <= id AUTO>
|
||||||
return setTrackMode(p[0], track[p[0]]->getMode() | TRACK_MODE_AUTOINV);
|
return setTrackMode(p[0], track[p[0]]->getMode() | TRACK_MODE_AUTOINV);
|
||||||
|
|
||||||
if (params==2 && p[1]==HASH_KEYWORD_INV) // <= id AUTO>
|
if (params==2 && p[1]=="INV"_hk) // <= id AUTO>
|
||||||
return setTrackMode(p[0], track[p[0]]->getMode() | TRACK_MODE_INV);
|
return setTrackMode(p[0], track[p[0]]->getMode() | TRACK_MODE_INV);
|
||||||
|
|
||||||
if (params==3 && p[1]==HASH_KEYWORD_DC && p[2]>0) // <= id DC cab>
|
if (params==3 && p[1]=="DC"_hk && p[2]>0) // <= id DC cab>
|
||||||
return setTrackMode(p[0],TRACK_MODE_DC,p[2]);
|
return setTrackMode(p[0],TRACK_MODE_DC,p[2]);
|
||||||
|
|
||||||
if (params==3 && p[1]==HASH_KEYWORD_DCX && p[2]>0) // <= id DCX cab>
|
if (params==3 && p[1]=="DCX"_hk && p[2]>0) // <= id DCX cab>
|
||||||
return setTrackMode(p[0],TRACK_MODE_DC|TRACK_MODE_INV,p[2]);
|
return setTrackMode(p[0],TRACK_MODE_DC|TRACK_MODE_INV,p[2]);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
|
|
||||||
#include "StringFormatter.h"
|
#include "StringFormatter.h"
|
||||||
|
|
||||||
#define VERSION "5.2.22"
|
#define VERSION "5.2.23"
|
||||||
|
// 5.2.23 - KeywordHasher _hk (no functional change)
|
||||||
// 5.2.22 - Bugfixes: Empty turnout descriptions ok; negative route numbers valid.
|
// 5.2.22 - Bugfixes: Empty turnout descriptions ok; negative route numbers valid.
|
||||||
// 5.2.21 - Add STARTUP_DELAY config option to delay CS bootup
|
// 5.2.21 - Add STARTUP_DELAY config option to delay CS bootup
|
||||||
// 5.2.20 - Check return of Ethernet.begin()
|
// 5.2.20 - Check return of Ethernet.begin()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user