1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2025-04-21 20:41:19 +02:00

Compare commits

..

No commits in common. "d14aa46d51c546b8eb8d1d393c2be3ccbbd16eb4" and "58b180603ac351727e86fdbdc0d5ff3bac1929d9" have entirely different histories.

7 changed files with 24 additions and 26 deletions

1
.gitignore vendored
View File

@ -15,3 +15,4 @@ my*.h
compile_commands.json compile_commands.json
newcode.txt.old newcode.txt.old
UserAddin.txt UserAddin.txt
platformio.ini

View File

@ -19,7 +19,7 @@
* along with CommandStation. If not, see <https://www.gnu.org/licenses/>. * along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
*/ */
//sensorCAM parser.cpp version 3.06 Jan 2025 //sensorCAM parser.cpp version 3.05 Jan 2025
#include "DCCEXParser.h" #include "DCCEXParser.h"
#include "CamParser.h" #include "CamParser.h"
#include "FSH.h" #include "FSH.h"
@ -32,7 +32,7 @@ const int16_t ve =2899;
// the CamParser::addVpin() function. // the CamParser::addVpin() function.
// The CAMBaseVpin is the one to be used when commands are given without a vpin. // The CAMBaseVpin is the one to be used when commands are given without a vpin.
VPIN CamParser::CAMBaseVpin = 0; // no vpins yet known VPIN CamParser::CAMBaseVpin = 0; // no vpins yet known
VPIN CamParser::CAMVPINS[] = {0,0,0,0}; // determines max # CAM's VPIN CamParser::CAMVPINS[] = {0,0,0,0}; // no vpins yet known
int CamParser::vpcount=sizeof(CAMVPINS)/sizeof(CAMVPINS[0]); int CamParser::vpcount=sizeof(CAMVPINS)/sizeof(CAMVPINS[0]);
void CamParser::parse(Print * stream, byte & opcode, byte & paramCount, int16_t p[]) { void CamParser::parse(Print * stream, byte & opcode, byte & paramCount, int16_t p[]) {
@ -43,7 +43,6 @@ void CamParser::parse(Print * stream, byte & opcode, byte & paramCount, int16_t
bool CamParser::parseN(Print * stream, byte paramCount, int16_t p[]) { bool CamParser::parseN(Print * stream, byte paramCount, int16_t p[]) {
(void)stream; // probably unused parameter (void)stream; // probably unused parameter
if (CAMBaseVpin==0) CAMBaseVpin=CAMVPINS[0]; // default to CAM 1.
VPIN vpin=CAMBaseVpin; //use current CAM selection VPIN vpin=CAMBaseVpin; //use current CAM selection
if (paramCount==0) { if (paramCount==0) {
@ -60,21 +59,20 @@ bool CamParser::parseN(Print * stream, byte paramCount, int16_t p[]) {
if(camop=='C'){ if(camop=='C'){
if(p[1]>=100) CAMBaseVpin=p[1]; if(p[1]>=100) CAMBaseVpin=p[1];
if(p[1]<=vpcount && p[1]>0) CAMBaseVpin=CAMVPINS[p[1]-1]; if(p[1]<vpcount) CAMBaseVpin=CAMVPINS[p[1]];
DIAG(F("CAM base Vpin: %c %d "),p[0],CAMBaseVpin); DIAG(F("CAM base Vpin: %c %d "),p[0],CAMBaseVpin);
return true; return true;
} }
if (camop<100) { //switch CAM# if p[1] dictates if (camop<100) { //switch CAM# if p[1] dictates
if(p[1]>=100 && p[1]<=(vpcount*100+99)) { //limits to CAM# 1 to 4 for now if(p[1]>=100 && p[1]<(vpcount*100)) { //limits to CAM# 1 to 3 for now
vpin=CAMVPINS[p[1]/100-1]; vpin=CAMVPINS[p[1]/100];
CAMBaseVpin=vpin; CAMBaseVpin=vpin;
DIAG(F("switching to CAM %d baseVpin:%d"),p[1]/100,vpin); DIAG(F("switching to CAM %d baseVpin:%d"),p[1]/100,vpin);
p[1]=p[1]%100; //strip off CAM # p[1]=p[1]%100; //strip off CAM #
} }
} }
if (CAMBaseVpin==0) {DIAG(F("<n Error: Invalid CAM selected, default to CAM1>")); if (CAMBaseVpin==0) return false; // no cam defined
return false; // cam not defined
}
// send UPPER case to sensorCAM to flag binary data from a DCCEX-CS parser // send UPPER case to sensorCAM to flag binary data from a DCCEX-CS parser
switch(paramCount) { switch(paramCount) {
@ -91,13 +89,13 @@ bool CamParser::parseN(Print * stream, byte paramCount, int16_t p[]) {
break; break;
case 3: //<N vpin rowY colx > or <N cmd p1 p2> case 3: //<N vpin rowY colx > or <N cmd p1 p2>
camop=p[0];
if (p[0]>=100) { //vpin - i.e. NOT 'A' through 'Z' if (p[0]>=100) { //vpin - i.e. NOT 'A' through 'Z'
if (p[1]>236 || p[1]<0) return false; //row if (p[1]>236 || p[1]<0) return false; //row
if (p[2]>316 || p[2]<0) return false; //column if (p[2]>316 || p[2]<0) return false; //column
camop=0x80; // special 'a' case for IO_SensorCAM camop=0x80; // special 'a' case for IO_SensorCAM
vpin = p[0]; vpin = p[0];
}else if (STRCHR_P((const char *)F("IJMNT"),camop) == nullptr) return false; }else if (STRCHR_P((const char *)F("IJMNT"),camop) == nullptr) return false;
camop=p[0];
param1 = p[1]; param1 = p[1];
param3 = p[2]; param3 = p[2];
break; break;

11
DCC.cpp
View File

@ -268,9 +268,14 @@ bool DCC::setFn( int cab, int16_t functionNumber, bool on) {
// Flip function state (used from withrottle protocol) // Flip function state (used from withrottle protocol)
void DCC::changeFn( int cab, int16_t functionNumber) { void DCC::changeFn( int cab, int16_t functionNumber) {
auto currentValue=getFn(cab,functionNumber); if (cab<=0 || functionNumber>31) return;
if (currentValue<0) return; // function not valid for change auto slot=lookupSpeedTable(cab);
setFn(cab,functionNumber, currentValue?false:true); unsigned long funcmask = (1UL<<functionNumber);
slot->functions ^= funcmask;
if (functionNumber <= 28) {
updateGroupflags(slot->groupFlags, functionNumber);
}
CommandDistributor::broadcastLoco(slot);
} }
// Report function state (used from withrottle protocol) // Report function state (used from withrottle protocol)

View File

@ -408,7 +408,7 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
) break; ) break;
// Honour the configuration option (config.h) which allows the <a> command to be reversed // Honour the configuration option (config.h) which allows the <a> command to be reversed
// Because of earlier confusion we need to do the same thing under both defines // Because of earlier confusion we need to do the same thing under both defines
#if defined(DCC_ACCESSORY_COMMAND_REVERSE) #if defined(DCC_ACCESSORY_COMMAND_REVERSE) || defined(DCC_ACCESSORY_RCN_213)
DCC::setAccessory(address, subaddress,p[activep]==0,onoff); DCC::setAccessory(address, subaddress,p[activep]==0,onoff);
#else #else
DCC::setAccessory(address, subaddress,p[activep]==1,onoff); DCC::setAccessory(address, subaddress,p[activep]==1,onoff);

View File

@ -379,7 +379,7 @@
// DCC++ Classic behaviour is that Throw writes a 1 in the packet, // DCC++ Classic behaviour is that Throw writes a 1 in the packet,
// and Close writes a 0. // and Close writes a 0.
// RCN-213 specifies that Throw is 0 and Close is 1. // RCN-213 specifies that Throw is 0 and Close is 1.
#ifndef DCC_TURNOUTS_RCN_213 #if defined(DCC_TURNOUTS_RCN_213)
close = !close; close = !close;
#endif #endif
DCC::setAccessory(_dccTurnoutData.address, _dccTurnoutData.subAddress, close); DCC::setAccessory(_dccTurnoutData.address, _dccTurnoutData.subAddress, close);

View File

@ -269,8 +269,8 @@ The configuration file for DCC-EX Command Station
// over DCC++. This #define likewise inverts the behaviour of the <a> command // over DCC++. This #define likewise inverts the behaviour of the <a> command
// for triggering DCC Accessory Decoders, so that <a addr subaddr 0> generates a // for triggering DCC Accessory Decoders, so that <a addr subaddr 0> generates a
// DCC packet with D=1 (close turnout) and <a addr subaddr 1> generates D=0 // DCC packet with D=1 (close turnout) and <a addr subaddr 1> generates D=0
// (throw turnout). // (throw turnout). This is the same as DCC_ACCESSORY_COMMAND_REVERSE
//#define DCC_ACCESSORY_COMMAND_REVERSE //#define DCC_ACCESSORY_RCN_213
// HANDLING MULTIPLE SERIAL THROTTLES // HANDLING MULTIPLE SERIAL THROTTLES

View File

@ -3,10 +3,7 @@
#include "StringFormatter.h" #include "StringFormatter.h"
#define VERSION "5.5.11" #define VERSION "5.5.8"
// 5.5.11 - (5.4.2) accessory command reverse
// 5.5.10 - CamParser fix
// 5.5.9 - (5.4.3) fix changeFn for functions 29..31
// 5.5.8 - EXSensorCam clean up to match other filters and // 5.5.8 - EXSensorCam clean up to match other filters and
// - avoid need for config.h settings // - avoid need for config.h settings
// - Test: IO_I2CDFPlayer.h inserted 10mS deleay in Init_SC16IS752() just after soft-reset for board with 1.8432 Mhz xtal // - Test: IO_I2CDFPlayer.h inserted 10mS deleay in Init_SC16IS752() just after soft-reset for board with 1.8432 Mhz xtal
@ -26,9 +23,6 @@
// 5.5.2 - DS1307 Real Time clock // 5.5.2 - DS1307 Real Time clock
// 5.5.1 - Momentum // 5.5.1 - Momentum
// 5.5.0 - New version on devel // 5.5.0 - New version on devel
// 5.4.3 - bugfix changeFn for functions 29..31
// 5.4.2 - Reversed turnout bugfix
// 5.4.1 - ESP32 bugfix packet buffer race
// 5.4.0 - New version on master // 5.4.0 - New version on master
// 5.2.96 - EXRAIL additions XFWD() and XREV() // 5.2.96 - EXRAIL additions XFWD() and XREV()
// 5.2.95 - Release candidate for 5.4 // 5.2.95 - Release candidate for 5.4