diff --git a/.gitattributes b/.gitattributes index dfe0770..09d8971 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,3 @@ # Auto detect text files and perform LF normalization * text=auto +*.svg -text diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index ec6f049..d16b21e 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -158,6 +158,66 @@ int DCCEXParser::splitValues(int result[MAX_PARAMS], const byte *cmd) return parameterCount; } +int DCCEXParser::splitHexValues(int result[MAX_PARAMS], const byte *cmd) +{ + byte state = 1; + byte parameterCount = 0; + int runningValue = 0; + const byte *remainingCmd = cmd + 1; // skips the opcode + + // clear all parameters in case not enough found + for (int i = 0; i < MAX_PARAMS; i++) + result[i] = 0; + + while (parameterCount < MAX_PARAMS) + { + byte hot = *remainingCmd; + + switch (state) + { + + case 1: // skipping spaces before a param + if (hot == ' ') + break; + if (hot == '\0' || hot == '>') + return parameterCount; + state = 2; + continue; + + case 2: // checking first hex digit + runningValue = 0; + state = 3; + continue; + + case 3: // building a parameter + if (hot >= '0' && hot <= '9') + { + runningValue = 16 * runningValue + (hot - '0'); + break; + } + if (hot >= 'A' && hot <= 'F') + { + runningValue = 16 * runningValue + 10 + (hot - 'A'); + break; + } + if (hot >= 'a' && hot <= 'f') + { + runningValue = 16 * runningValue + 10 + (hot - 'a'); + break; + } + if (hot==' ' || hot=='>' || hot=='\0') { + result[parameterCount] = runningValue; + parameterCount++; + state = 1; + continue; + } + return -1; // invalid hex digit + } + remainingCmd++; + } + return parameterCount; +} + FILTER_CALLBACK DCCEXParser::filterCallback = 0; AT_COMMAND_CALLBACK DCCEXParser::atCommandCallback = 0; void DCCEXParser::setFilter(FILTER_CALLBACK filter) @@ -265,6 +325,21 @@ void DCCEXParser::parse(Print *stream, byte *com, bool blocking) DCC::writeCVBitMain(p[0], p[1], p[2], p[3]); return; + case 'M': // WRITE TRANSPARENT DCC PACKET MAIN + case 'P': // WRITE TRANSPARENT DCC PACKET PROG

+ // Re-parse the command using a hex-only splitter + params=splitHexValues(p,com)-1; // drop REG + if (params<1) break; + { + byte packet[params]; + for (int i=0;i if (!stashCallback(stream, p)) break; @@ -515,7 +590,7 @@ bool DCCEXParser::parseT(Print *stream, int params, int p[]) for (Turnout *tt = Turnout::firstTurnout; tt != NULL; tt = tt->nextTurnout) { gotOne = true; - StringFormatter::send(stream, F(""), tt->data.id, tt->data.tStatus & STATUS_ACTIVE); + StringFormatter::send(stream, F(""), tt->data.id, (tt->data.tStatus & STATUS_ACTIVE)!=0); } return gotOne; // will if none found } @@ -532,7 +607,7 @@ bool DCCEXParser::parseT(Print *stream, int params, int p[]) if (!tt) return false; tt->activate(p[1]); - StringFormatter::send(stream, F(""), tt->data.id, tt->data.tStatus & STATUS_ACTIVE); + StringFormatter::send(stream, F(""), tt->data.id, (tt->data.tStatus & STATUS_ACTIVE)!=0); } return true; diff --git a/DCCEXParser.h b/DCCEXParser.h index 2c2f337..ec0286d 100644 --- a/DCCEXParser.h +++ b/DCCEXParser.h @@ -40,6 +40,7 @@ struct DCCEXParser bool inCommandPayload=false; byte buffer[MAX_BUFFER+2]; int splitValues( int result[MAX_PARAMS], const byte * command); + int splitHexValues( int result[MAX_PARAMS], const byte * command); bool parseT(Print * stream, int params, int p[]); bool parseZ(Print * stream, int params, int p[]); diff --git a/Release - Architecture Doc/CommandStation-EX-Arch-v1-0.pdf b/Release - Architecture Doc/CommandStation-EX-Arch-v1-0.pdf new file mode 100644 index 0000000..067d966 Binary files /dev/null and b/Release - Architecture Doc/CommandStation-EX-Arch-v1-0.pdf differ diff --git a/Release - Architecture Doc/CommandStation-EX-Arch-v1-0.svg b/Release - Architecture Doc/CommandStation-EX-Arch-v1-0.svg new file mode 100644 index 0000000..b99995d --- /dev/null +++ b/Release - Architecture Doc/CommandStation-EX-Arch-v1-0.svg @@ -0,0 +1,1046 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Page-1 + + + + + Start/End + Wi-Fi Input + + + + + + + + + + + + + + + + + + + + + + + + Wi-Fi Input + + + Process + (WifiInboundHandler.cpp) + + + + + + + + + + + + + + + + + + + + + + + + (WifiInboundHandler.cpp) + + + Start/End.4 + Ethernet Input + + + + + + + + + + + + + + + + + + + + + + + + Ethernet Input + + Start/End.5 + USB Input (From JMRI or Console) + + + + + + + + + + + + + + + + + + + + + + + + USB Input(From JMRI or Console) + + + Process.6 + Command Distributor (CommandDistributor.cpp) + + + + + + + + + + + + + + + + + + + + + + + + Command Distributor(CommandDistributor.cpp) + + + + Process.8 + DCC-EX Command Parser (DCCEXParser.cpp) + + + + + + + + + + + + + + + + + + + + + + + + DCC-EX Command Parser(DCCEXParser.cpp) + + + + Process.9 + WiThrottle Server (Withrottle.cpp) + + + + + + + + + + + + + + + + + + + + + + + + WiThrottle Server(Withrottle.cpp) + + + Process.10 + TPL Automation (Train Programming Language - Coming Soon) + + + + + + + + + + + + + + + + + + + + + + + + TPL Automation(Train Programming Language - Coming Soon) + + + Process.11 + DCC API (Builds DCC Packets from Simple Parameters) + + + + + + + + + + + + + + + + + + + + + + + + DCC API(Builds DCC Packets from Simple Parameters) + + + + Process.12 + DCC Waveform (Converts DCC Packets into a Digital Signal) + + + + + + + + + + + + + + + + + + + + + + + + DCC Waveform(Converts DCC Packets into a Digital Signal) + + + + Process.13 + Accessories (Output.cpp) + + + + + + + + + + + + + + + + + + + + + + + + Accessories (Output.cpp) + + + + Process.14 + Other Utilities (LCDDisplay.cpp) + + + + + + + + + + + + + + + + + + + + + + + + Other Utilities(LCDDisplay.cpp) + + + Dynamic connector + + + + + + + + + Process.15 + (Ethernetinterface.cpp) + + + + + + + + + + + + + + + + + + + + + + + + (Ethernetinterface.cpp) + + + Dynamic connector.16 + + + + + + + + Dynamic connector.7 + + + + + + + + Dynamic connector.17 + + + + + + + + Dynamic connector.18 + + + + + + + + Dynamic connector.19 + + + + + + + + Dynamic connector.20 + + + + + + + + Sheet.21 + DCC-EX CommandStation-EX Architecture (CS-EX) v3.0.0 Drawing ... + + + + + + + + DCC-EX CommandStation-EX Architecture (CS-EX) v3.0.0 Drawing v1-0 - 25-Nov-2020 + + Dynamic connector.22 + + + + + + + + Dynamic connector.23 + + + + + + + + Dynamic connector.24 + + + + + + + + Dynamic connector.26 + + + + + + + + Dynamic connector.27 + + + + + + + + Process.29 + CPU GPIO Pins Driving Turnouts & Reading Servers + + + + + + + + + + + + + + + + + + + + + + + + CPU GPIO Pins Driving Turnouts & Reading Servers + + Process.30 + CPU Pins driving Motor Shield Power Outputs + + + + + + + + + + + + + + + + + + + + + + + + CPU Pins driving Motor Shield Power Outputs + + Dynamic connector.31 + + + + + + + + Dynamic connector.32 + + + + + + + + Dynamic connector.25 + + + + + + + + Dynamic connector.28 + + + + + + + + Dynamic connector.33 + + + + + + + + + Process.35 + (WifiInterface.cpp) + + + + + + + + + + + + + + + + + + + + + + + + (WifiInterface.cpp) + + + Dynamic connector.34 + + + + + + + + Dynamic connector.36 + + + + + + + + + Process.41 + Other Utilities (StingFormatter.cpp) + + + + + + + + + + + + + + + + + + + + + + + + Other Utilities(StingFormatter.cpp) + + + + Process.37 + Turnouts (Turnout.cpp) + + + + + + + + + + + + + + + + + + + + + + + + Turnouts(Turnout.cpp) + + + + Process.38 + Sensors ( Sensor.cpp) + + + + + + + + + + + + + + + + + + + + + + + + Sensors( Sensor.cpp) + + + + Process.39 + Servos (PWMServerDriver.cpp) + + + + + + + + + + + + + + + + + + + + + + + + Servos (PWMServerDriver.cpp) + + + Dynamic connector.40 + + + + + + + + Dynamic connector.42 + + + + + + + + Dynamic connector.43 + + + + + + + + Dynamic connector.44 + + + + + + + + Dynamic connector.45 + + + + + + + + Dynamic connector.46 + + + + + + + + diff --git a/Release - Architecture Doc/CommandStation-EX-Arch-v1-0.vsd b/Release - Architecture Doc/CommandStation-EX-Arch-v1-0.vsd new file mode 100644 index 0000000..59acd9e Binary files /dev/null and b/Release - Architecture Doc/CommandStation-EX-Arch-v1-0.vsd differ diff --git a/Release - Architecture Doc/Prod-Release-Notes.md b/Release - Architecture Doc/Prod-Release-Notes.md new file mode 100644 index 0000000..2b95877 --- /dev/null +++ b/Release - Architecture Doc/Prod-Release-Notes.md @@ -0,0 +1,71 @@ +The DCC-EX Team is pleased to release CommandStation-EX-v3.0.0 as a Production Release. This release is a major re-write of earlier versions. We've re-architected the code-base so that it can better handle new features going forward. + +**Known Bugs:** + - **Consisting through JMRI** - currently does not work in this release. A number of testers were able to develop a work around. If interested enter a Support Ticket. + - **Wi-Fi** - works, but can be challenging to use if you want to switch between AP mode and STA station mode. + - **Pololu Motor Shield** - is supported with this release, but the user may have to play around with some timings to enable programming mode due to limitation in its current sensing circuitry + + **Summary of the key new features added to CommandStation-EX V3.0.0:** + - **WiFi Support** - AP and station modes supported. Auto-detection of an ESP8266 WiFi module with AT firmware on a Mega's serial port. Connection to JMRI and WiThrottle clients. + - **Withrottle Integrations** - Act as a host for four WiThrottle clients concurrently. + - **Add LCD/OLED support** - OLED supported on Mega only + - **Improved CV programming routines** - checks for length of CV pulse, and breaks out of the wait state once it has received an ACK, now reading one CV per second. + - **Improved current sensing** - rewrote current sensing routines for safer operation. Current thresholds based on milliamps, not magic numbers + - **Individual track power control** - Ability to toggle power on either or both tracks, and to "JOIN" the tracks and make them output the same waveform for multiple power districts. + - **Single or Dual-Pin PWM output** - Allows control of H-bridges with PH/EN or dual PWM inputs + - **New, simpler function command** - `````` command allows setting functions based on their number, not based on a code as in `````` + - **Function reminders** - Function reminders are sent in addition to speed reminders + - **Functions to F28** - All NMRA functions are now supported + - **Filters and user functions** - Ability to filter commands in the parser and execute custom code based on them + - **Diagnostic `````` commands** - See documentation for a full list of new diagnostic commands + - **Rewrote DCC++ Parser** - more efficient operation, accepts multi-char input and uses less RAM + - **Rewritten waveform generator** - capable of using any pin for DCC waveform out, eliminating the need for jumpers + - **Rewritten packet generator** - Simplify and make smaller, remove idea of "registers" from original code + - **Add free RAM messages** - Free RAM messages are now printed whenever there is a decerase in available RAM + - **Fix EEPROM bugs** + - **Number of locos discovery command** - ```<#>``` command + - **Support for more locomotives** - 20 locomotives on an UNO and 50 an a Mega. + - **Automatic slot managment** - slot variable in throttle/function commands are ignored and slot management is taken care of automatically. `````` command added to release locos from memory. + + +**Key Contributors** + +**Project Lead** +- Fred Decker - Holly Springs, North Carolina, USA (FlightRisk) + +**CommandStation-EX Developers** +- Chris Harlow - Bournemouth, UK (UKBloke) +- Harald Barth - Stockholm, Sweden (Haba) +- Fred Decker - Holly Springs, North Carolina, USA (FlightRisk) +- Dave Cutting - Logan, Utah, USA (Dave Cutting/ David Cutting) +- M Steve Todd - - Engine Driver and JMRI Interface +- Scott Catalanno - Pennsylvania +- Gregor Baues - Île-de-France, France (grbba) + +**exInstaller Software** +- Anthony W - Dayton, Ohio, USA (Dex, Dex++) + +**Website and Documentation** +- Mani Kumar - Bangalor, India (Mani / Mani Kumar) +- Fred Decker - Holly Springs, North Carolina, USA (FlightRisk) +- Dave Cutting - Logan, Utah, USA (Dave Cutting/ David Cutting) +- Roger Beschizza - Dorset, UK (Roger Beschizza) +- Keith Ledbetter - Chicago, Illinois, USA (Keith Ledbetter) +-Kevin Smith - (KCSmith) + +**Beta Testing / Release Management / Support** +- Larry Dribin - Release Management +- Keith Ledbetter +- BradVan der Elst +- Andrew Pye +- Mike Bowers +- Randy McKenzie +- Roberto Bravin +- Sim Brigden +- Alan Lautenslager +- Martin Bafver +- Mário André Silva +- Anthony Kochevar +- Gajanatha Kobbekaduwe +- Sumner Patterson +- Paul - Virginia, USA diff --git a/Release - Architecture Doc/Rough Release-Notes.md b/Release - Architecture Doc/Rough Release-Notes.md new file mode 100644 index 0000000..edd8c6c --- /dev/null +++ b/Release - Architecture Doc/Rough Release-Notes.md @@ -0,0 +1,23 @@ +# CommandStation-EX Release Notes + +## v3.0.0 + + - **WiFi Support** - AP and station modes supported. Auto-detection of an ESP8266 WiFi module with AT firmware on a Mega's serial port. Connection to JMRI and WiThrottle clients. + - **Withrottle Integrations** - Act as a host for four WiThrottle clients concurrently. + - **Add LCD/OLED support** - OLED supported on Mega only + - **Improved CV programming routines** - checks for length of CV pulse, and breaks out of the wait state once it has received an ACK, now reading one CV per second. + - **Improved current sensing** - rewrote current sensing routines for safer operation. Current thresholds based on milliamps, not magic numbers + - **Individual track power control** - Ability to toggle power on either or both tracks, and to "JOIN" the tracks and make them output the same waveform for multiple power districts. + - **Single or Dual-Pin PWM output** - Allows control of H-bridges with PH/EN or dual PWM inputs + - **New, simpler function command** - `````` command allows setting functions based on their number, not based on a code as in `````` + - **Function reminders** - Function reminders are sent in addition to speed reminders + - **Functions to F28** - All NMRA functions are now supported + - **Filters and user functions** - Ability to filter commands in the parser and execute custom code based on them + - **Diagnostic `````` commands** - See documentation for a full list of new diagnostic commands + - **Rewrote DCC++ Parser** - more efficient operation, accepts multi-char input and uses less RAM + - **Rewritten waveform generator** - capable of using any pin for DCC waveform out, eliminating the need for jumpers + - **Rewritten packet generator** - Simplify and make smaller, remove idea of "registers" from original code + - **Add free RAM messages** - Free RAM messages are now printed whenever there is a decerase in available RAM + - **Fix EEPROM bugs** + - **Support for more decoders** - Support for 20 (Uno) or 50 (Mega) mobile decoders, number automaticlaly recognized by JMRI. + - **Automatic slot managment** - slot variable in throttle/function commands are ignored and slot management is taken care of automatically. `````` command added to release locos from memory.