From 9bda665ad4465709a3caea1a7ab8119ecaf4776d Mon Sep 17 00:00:00 2001 From: Asbelos Date: Mon, 7 Apr 2025 19:38:57 +0100 Subject: [PATCH] sample doc extract and and validations --- DCCEXCommands.h | 17 +-- DCCEXParserMacros.h | 22 +++- Release_Notes/AutoRefManual.html | 14 +++ Release_Notes/AutoRefManual.js | 177 +++++++++++++++++++++++++++++++ 4 files changed, 220 insertions(+), 10 deletions(-) create mode 100644 Release_Notes/AutoRefManual.html create mode 100644 Release_Notes/AutoRefManual.js diff --git a/DCCEXCommands.h b/DCCEXCommands.h index 55f45e6..9c8488e 100644 --- a/DCCEXCommands.h +++ b/DCCEXCommands.h @@ -110,6 +110,7 @@ e.g. Use of the CHECK() macro validates a condition to be true. If the condition is false an error is genarated, resulting in an reply. +Commonly known parameters such as loco, cv bitvalue etc are range checked automatically. The REPLY( format, ...) macro sends a formatted string to the stream. These macros are included into the DCCEXParser::execute function so @@ -550,8 +551,8 @@ ZZ(-,loco) // remove loco state amnd reminders DCC::forgetLoco(loco); ZZ(F,loco,DCCFREQ,freqvalue) // Set DC frequencey for loco CHECK(freqvalue>=0 && freqvalue<=3) DCC::setDCFreq(loco,freqvalue); -ZZ(F,loco,function,fvalue) // Set loco function ON/OFF - CHECK(fvalue==0 || fvalue==1) DCC::setFn(loco,function,fvalue); +ZZ(F,loco,function,onoff) // Set loco function ON/OFF + CHECK(onoff==0 || onoff==1) DCC::setFn(loco,function,onoff); // ZZ(M,ignore,d0,d1,d2,d3,d4,d5) // Send up to 5 byte DCC packet on MAIN track (all d values in hex) ZZ_nodoc(M,ignore,d0,d1,d2,d3,d4,d5) byte packet[]={(byte)d0,(byte)d1,(byte)d2,(byte)d3,(byte)d4,(byte)d5}; DCCWaveform::mainTrack.schedulePacket(packet,sizeof(packet),3); @@ -623,11 +624,11 @@ ZZ(=,track,AUTO) // Update track to auto reverse CHECK(TrackManager::orTrackMode(track, TRACK_MODIFIER_AUTO)) ZZ(=,track,INV) // Update track to inverse polarity CHECK(TrackManager::orTrackMode(track, TRACK_MODIFIER_INV)) -ZZ(=,track,DC,locoid) // Set track to DC - CHECK(TrackManager::setTrackMode(track, TRACK_MODE_DC, locoid)) -ZZ(=,track,DC_INV,locoid) // Set track to DC with inverted polarity - CHECK(TrackManager::setTrackMode(track, TRACK_MODE_DC_INV, locoid)) -ZZ(=,track,DCX,locoid) // Set track to DC with inverted polarity - CHECK(TrackManager::setTrackMode(track, TRACK_MODE_DC_INV, locoid)) +ZZ(=,track,DC,loco) // Set track to DC + CHECK(TrackManager::setTrackMode(track, TRACK_MODE_DC, loco)) +ZZ(=,track,DC_INV,loco) // Set track to DC with inverted polarity + CHECK(TrackManager::setTrackMode(track, TRACK_MODE_DC_INV, loco)) +ZZ(=,track,DCX,loco) // Set track to DC with inverted polarity + CHECK(TrackManager::setTrackMode(track, TRACK_MODE_DC_INV, loco)) ZZEND diff --git a/DCCEXParserMacros.h b/DCCEXParserMacros.h index 0f80ca8..9d99506 100644 --- a/DCCEXParserMacros.h +++ b/DCCEXParserMacros.h @@ -1,3 +1,22 @@ +/* + * © 2025 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 . + */ // Count the number of arguments #define FOR_EACH_NARG(...) FOR_EACH_NARG_HELPER(__VA_ARGS__,8,7, 6,5,4, 3, 2, 1, 0) @@ -61,8 +80,7 @@ ZCHECK(track,_index,_pname,'A','H') \ ZCHECK(cv,_index,_pname,1,255) \ ZCHECK(value,_index,_pname,0,255) \ ZCHECK(bit,_index,_pname,0,7) \ -ZCHECK(bitvalue,_index,_pname,0,1) \ -ZCHECK(crapvalue,_index,_pname,99,100) \ +ZCHECK(bitvalue,_index,_pname,0,1) diff --git a/Release_Notes/AutoRefManual.html b/Release_Notes/AutoRefManual.html new file mode 100644 index 0000000..f0b2a87 --- /dev/null +++ b/Release_Notes/AutoRefManual.html @@ -0,0 +1,14 @@ + + + + + + + \ No newline at end of file diff --git a/Release_Notes/AutoRefManual.js b/Release_Notes/AutoRefManual.js new file mode 100644 index 0000000..87a2a1c --- /dev/null +++ b/Release_Notes/AutoRefManual.js @@ -0,0 +1,177 @@ +ZZ('#','Request number of simultaneously supported locos'); +ZZ('!','Emergency stop all locos'); +ZZ('t loco','Request loco status'); +ZZ('t loco tspeed direction','Set throttle speed(0..127) and direction (0=reverse, 1=fwd) '); +ZZ('t ignore loco tspeed direction','(Deprecated) Set throttle speed and direction'); +ZZ('T','List all turnouts'); +ZZ('T id','Delete turnout'); +ZZ('T id X','List turnout details'); +ZZ('T id T','Throw Turnout'); +ZZ('T id C','Close turnout#'); +ZZ('T id value','Close (value=0) ot Throw turnout'); +ZZ('T id SERVO vpin closedValue thrownValue','Create Servo turnout '); +ZZ('T id VPIN vpin','Create pin turnout'); +ZZ('T id DCC addr subadd','Create DCC turnout '); +ZZ('T id DCC linearAddr','Create DCC turnout'); +ZZ('T id addr subadd','Create DCC turnout'); +ZZ('T id vpin closedValue thrownValue','Create SERVO turnout'); +ZZ('S id vpin pullup','Create Sensor'); +ZZ('S id','Delete sensor'); +ZZ('S','List sensors'); +ZZ('J M','List stash values'); +ZZ('J M stash_id','get stash value'); +ZZ('J M CLEAR ALL','Clear all stash values'); +ZZ('J M CLEAR stash_id','Clear given stash'); +ZZ('J M stashId locoId','Set stash value'); +ZZ('J M CLEAR ANY locoId','Clear all stash entries that contain locoId'); +ZZ('J C','get fastclock time'); +ZZ('J C mmmm nn','Set fastclock time'); +ZZ('J G','FReport gauge limits '); +ZZ('J I','Report currents '); +ZZ('J L display row','Direct current displays to LCS/OLED'); +ZZ('J A','List Routes'); +ZZ('J R','List Roster'); +ZZ('J R id','Get roster for loco'); +ZZ('J T','Get turnout list '); +ZZ('J T id','Get turnout state and description'); +ZZ('z vpin','Set pin. HIGH iv vpin positive, LOW if vpin negative '); +ZZ('z vpin analog profile duration','Change analog value over duration (Fade or servo move)'); +ZZ('z vpin analog profile','Write analog device using profile number (Fade or servo movement)'); +ZZ('z vpin analog','Write analog device value'); +ZZ('I','List all turntables'); +ZZ('I id','Broadcast turntable type and current position '); +ZZ('I id position','Rotate a DCC turntable'); +ZZ('I id DCC home','Create DCC turntable'); +ZZ('I id position activity','Rotate an EXTT turntable'); +ZZ('I id EXTT vpin home','Create an EXTT turntable'); +ZZ('I id ADD position value angle','Add turntable position'); +ZZ('Q','List all sensors '); +ZZ('s','Command station status'); +ZZ('E','STORE EPROM'); +ZZ('e','CLEAR EPROM'); +ZZ('Z','List Output definitions '); +ZZ('Z id pin iflag','Create Output'); +ZZ('Z id active','Set output '); +ZZ('Z id','Delete output'); +ZZ('D ACK ON','Enable PROG track diagnostics'); +ZZ('D ACK OFF','Disable PROG track diagnostics'); +ZZ('D CABS','Diagnostic display loco state table'); +ZZ('D RAM','Diagnostic display free RAM'); +ZZ('D CMD ON','Enable command input diagnostics'); +ZZ('D CMD OFF','Disable command input diagnostics'); +ZZ('D RAILCOM ON','Enable Railcom diagnostics'); +ZZ('D RAILCOM OFF','DIsable Railcom diagnostics'); +ZZ('D WIFI ON','Enable Wifi diagnostics'); +ZZ('D WIFI OFF','Disable Wifi diagnostics'); +ZZ('D ETHERNET ON','Enable Ethernet diagnostics'); +ZZ('D ETHERNET OFF','Disabel Ethernet diagnostics '); +ZZ('D WIT ON','Enable Withrottle diagnostics'); +ZZ('D WIT OFF','Disable Withrottle diagnostics '); +ZZ('D LCN ON','Enable LCN Diagnostics'); +ZZ('D LCN OFF','Disabel LCN diagnostics'); +ZZ('D WEBSOCKET ON','Enable Websocket diagnostics '); +ZZ('D WEBSOCKET OFF','Disable wensocket diagnostics '); +ZZ('D EEPROM numentries','Dump EEPROM contents'); +ZZ('D ANOUT vpin position','see '); +ZZ('D ANOUT vpin position profile','see '); +ZZ('D SERVO vpin position','Test servo'); +ZZ('D SERVO vpin position profile','Test servo'); +ZZ('D ANIN vpin','Display analogue input value'); +ZZ('D HAL SHOW','Show HAL devices table'); +ZZ('D HAL RESET','Reset all HAL devices'); +ZZ('D TT vpin steps','Test turntable'); +ZZ('D TT vpin steps activity','Test turntable'); +ZZ('C PROGBOOST','Configute PROG track boost'); +ZZ('C RESET','Reset and restart command station'); +ZZ('C SPEED28','Set all DCC speed commands as 28 step to old decoders'); +ZZ('C SPEED128','Set all DCC speed commands to 128 step (default)'); +ZZ('C RAILCOM ON','Enable Railcom cutout '); +ZZ('C RAILCOM OFF','Disable Railcom cutout'); +ZZ('C RAILCOM DEBUG','Enable Railcom cutout for easy scope reading test'); +ZZ('D ACK LIMIT value','Set ACK detection limit mA'); +ZZ('D ACK MIN value MS','Set ACK minimum duration mS'); +ZZ('D ACK MIN value','Set ACK minimum duration uS'); +ZZ('D ACK MAX value MS','Set ACK maximum duration mS'); +ZZ('D ACK MAX value','Set ACK maximum duration uS'); +ZZ('D ACK RETRY value','Set ACK retry count'); +ZZ('C WIFI "ssid" "password"','reconfigure stored wifi credentials '); +ZZ('o vpin','Set neopixel on(vpin>0) or off(vpin<0)'); +ZZ('o vpin count','Set multiple neopixels on(vpin>0) or off(vpin<0)'); +ZZ('o vpin r g b','Set neopixel colour'); +ZZ('o vpin r g b count','Set multiple neopixels colour '); +ZZ('1','Power ON all tracks'); +ZZ('1 MAIN','Power on MAIN track'); +ZZ('1 PROG','Power on PROG track'); +ZZ('1 JOIN','JOIN prog track to MAIN and power'); +ZZ('1 track','Power on given track'); +ZZ('0','Power off all tracks'); +ZZ('0 MAIN','Power off MAIN track'); +ZZ('0 PROG','Power off PROG track'); +ZZ('0 track','Power off given track'); +ZZ('c','Report main track currect (Deprecated)'); +ZZ('a address subaddress activate','Send DCC accessory command'); +ZZ('a address subaddress activate onoff','Send DCC accessory command with onoff control (TODO.. numbers) '); +ZZ('a linearaddress activate','send dcc accessory command '); +ZZ('A address value','Send DCC extended accessory (Aspect) command'); +ZZ('w loco cv value','POM write cv on main track'); +ZZ('r loco cv','POM read cv on main track'); +ZZ('b loco cv bit value','POM write cv bit on main track'); +ZZ('m LINEAR','Set Momentum algorithm to linear acceleration'); +ZZ('m POWER','Set momentum algortithm to very based on difference between current speed and throttle seting'); +ZZ('m loco momentum','set momentum for loco (accel and braking)'); +ZZ('m loco accelerating braking','set momentum for loco'); +ZZ('W cv value ignore1 ignore2','(Deprecated) Write cv value on PROG track'); +ZZ('W cab','Write loco address on PROG track'); +ZZ('W CONSIST cab REVERSE','Write consist address and reverse flag on PROG track '); +ZZ('W CONSIST cab','write consist address on PROG track '); +ZZ('W cv value','Write cv value on PROG track'); +ZZ('W cv value bit','Write cv bit on prog track'); +ZZ('V cv value','Fast read cv with expected value'); +ZZ('V cv bit value','Fast read bit with expected value'); +ZZ('B cv bit value','Write cv bit'); +ZZ('R cv ignore1 ignore2','(Deprecated) read cv'); +ZZ('R cv','Read cv'); +ZZ('R','Read driveable loco id (may be long, short or consist)'); +ZZ('-','Clear loco state and reminder table'); +ZZ('- loco','remove loco state amnd reminders'); +ZZ('F loco DCCFREQ value','Set DC frequencey for loco '); +ZZ('F loco function value','Set loco function ON/OFF'); +ZZ('M ignore d0 d1 d2 d3 d4 d5','Send up to 5 byte DCC packet on MAIN track (all d values in hex)'); +ZZ('P ignore d0 d1 d2 d3 d4 d5','Send up to 5 byte DCC packet on PROG track (all d values in hex)'); +ZZ('J O','List turntable IDs'); +ZZ('J O id','List turntable state'); +ZZ('J P id','list turntable positions'); +ZZ('=','list track manager states'); +ZZ('= track MAIN','Set track to MAIN'); +ZZ('= track MAIN_INV','Set track to MAIN inverted polatity'); +ZZ('= track MAIN_AUTO','Set track to MAIN with auto reversing'); +ZZ('= track PROG','Set track to PROG'); +ZZ('= track OFF','Set track power OFF'); +ZZ('= track NONE','Set track no output'); +ZZ('= track EXT','Set track to use external sync'); +ZZ('= track AUTO','Update track to auto reverse'); +ZZ('= track INV','Update track to inverse polarity'); +ZZ('= track DC locoid','Set track to DC'); +ZZ('= track DC_INV locoid','Set track to DC with inverted polarity'); +ZZ('= track DCX locoid','Set track to DC with inverted polarity');ZZ('D EXRAIL ON','EXRAIL diagnostics on'); +ZZ('D EXRAIL OFF','EXRAIL doagnostics off'); +ZZ('L','LCC/CBUS adapter introducing self'); +ZZ('L eventid','LCC incoming event '); +ZZ('J A','List automation ids'); +ZZ('J A id','list automation details'); +ZZ('K blockid loco','Loco entering Block'); +ZZ('k blockid loco','Loco exiting block'); +ZZ('/','Stream EXRAIL status'); +ZZ('/ PAUSE','pause all tasks '); +ZZ('/ RESUME','Resume all tasks'); +ZZ('/ START route','Start a route or sequence'); +ZZ('/ START loco route','Start an AUTOMATION or sequence with a loco '); +ZZ('/ KILL ALL','Kill all exrail tasks'); +ZZ('/ KILL taskid','Kill specific exrail tasks '); +ZZ('/ RESERVE section','Flag section as reserved'); +ZZ('/ FREE section','Free reserve on section'); +ZZ('/ LATCH latch','Set pin latch'); +ZZ('/ UNLATCH latch','Removeve pin latch'); +ZZ('/ RED signal','Set signal to Red '); +ZZ('/ AMBER signal','set Signal to Amber'); +ZZ('/ GREEN signal','Set signal to Green ');