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

Compare commits

...

13 Commits

Author SHA1 Message Date
Asbelos
d14aa46d51 5.5.11 2025-01-21 10:45:56 +00:00
Asbelos
2b50e31e50 Merge branch 'master' into devel 2025-01-21 10:38:48 +00:00
Asbelos
ee8f6eea1f CamParser fix 2025-01-21 10:29:26 +00:00
Asbelos
fb6070784e changeFn fix 2025-01-21 10:18:09 +00:00
Asbelos
2f1d5b993c revert gitignore 2025-01-21 10:00:26 +00:00
Asbelos
9054d8d9f5 Merge branch 'master-fn31' 2025-01-21 09:35:58 +00:00
Harald Barth
865f75dda4 version 5.4.2 2025-01-20 22:41:47 +01:00
Harald Barth
b40fa779a6 revert part of commit 3c725a which did fix bug but reverse direction 2025-01-20 22:40:43 +01:00
Asbelos
2115ada2a1 5.4.2 bugfix fn31 flip 2025-01-20 20:03:21 +00:00
Harald Barth
830de850a9 version 5.4.1 2025-01-17 19:14:32 +01:00
Harald Barth
c28965c58d ESP32 bugfix packet buffer race 2025-01-17 19:12:11 +01:00
Harald Barth
0476b9c1d8 Merge branch 'master' of https://github.com/DCC-EX/CommandStation-EX 2025-01-10 20:16:37 +01:00
Harald Barth
ba9ca1ccad sha 2025-01-10 20:15:20 +01:00
7 changed files with 26 additions and 24 deletions

1
.gitignore vendored
View File

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

View File

@ -19,7 +19,7 @@
* along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
*/
//sensorCAM parser.cpp version 3.05 Jan 2025
//sensorCAM parser.cpp version 3.06 Jan 2025
#include "DCCEXParser.h"
#include "CamParser.h"
#include "FSH.h"
@ -32,7 +32,7 @@ const int16_t ve =2899;
// the CamParser::addVpin() function.
// 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::CAMVPINS[] = {0,0,0,0}; // no vpins yet known
VPIN CamParser::CAMVPINS[] = {0,0,0,0}; // determines max # CAM's
int CamParser::vpcount=sizeof(CAMVPINS)/sizeof(CAMVPINS[0]);
void CamParser::parse(Print * stream, byte & opcode, byte & paramCount, int16_t p[]) {
@ -42,7 +42,8 @@ void CamParser::parse(Print * stream, byte & opcode, byte & paramCount, int16_t
}
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
if (paramCount==0) {
@ -59,21 +60,22 @@ bool CamParser::parseN(Print * stream, byte paramCount, int16_t p[]) {
if(camop=='C'){
if(p[1]>=100) CAMBaseVpin=p[1];
if(p[1]<vpcount) CAMBaseVpin=CAMVPINS[p[1]];
if(p[1]<=vpcount && p[1]>0) CAMBaseVpin=CAMVPINS[p[1]-1];
DIAG(F("CAM base Vpin: %c %d "),p[0],CAMBaseVpin);
return true;
}
if (camop<100) { //switch CAM# if p[1] dictates
if(p[1]>=100 && p[1]<(vpcount*100)) { //limits to CAM# 1 to 3 for now
vpin=CAMVPINS[p[1]/100];
if(p[1]>=100 && p[1]<=(vpcount*100+99)) { //limits to CAM# 1 to 4 for now
vpin=CAMVPINS[p[1]/100-1];
CAMBaseVpin=vpin;
DIAG(F("switching to CAM %d baseVpin:%d"),p[1]/100,vpin);
p[1]=p[1]%100; //strip off CAM #
}
}
if (CAMBaseVpin==0) return false; // no cam defined
if (CAMBaseVpin==0) {DIAG(F("<n Error: Invalid CAM selected, default to CAM1>"));
return false; // cam not defined
}
// send UPPER case to sensorCAM to flag binary data from a DCCEX-CS parser
switch(paramCount) {
case 1: //<N ver> produces '^'
@ -89,13 +91,13 @@ bool CamParser::parseN(Print * stream, byte paramCount, int16_t p[]) {
break;
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[1]>236 || p[1]<0) return false; //row
if (p[2]>316 || p[2]<0) return false; //column
camop=0x80; // special 'a' case for IO_SensorCAM
vpin = p[0];
}else if (STRCHR_P((const char *)F("IJMNT"),camop) == nullptr) return false;
camop=p[0];
param1 = p[1];
param3 = p[2];
break;

11
DCC.cpp
View File

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

View File

@ -408,7 +408,7 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
) break;
// 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
#if defined(DCC_ACCESSORY_COMMAND_REVERSE) || defined(DCC_ACCESSORY_RCN_213)
#if defined(DCC_ACCESSORY_COMMAND_REVERSE)
DCC::setAccessory(address, subaddress,p[activep]==0,onoff);
#else
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,
// and Close writes a 0.
// RCN-213 specifies that Throw is 0 and Close is 1.
#if defined(DCC_TURNOUTS_RCN_213)
#ifndef DCC_TURNOUTS_RCN_213
close = !close;
#endif
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
// 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
// (throw turnout). This is the same as DCC_ACCESSORY_COMMAND_REVERSE
//#define DCC_ACCESSORY_RCN_213
// (throw turnout).
//#define DCC_ACCESSORY_COMMAND_REVERSE
// HANDLING MULTIPLE SERIAL THROTTLES

View File

@ -3,7 +3,10 @@
#include "StringFormatter.h"
#define VERSION "5.5.8"
#define VERSION "5.5.11"
// 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
// - 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
@ -23,6 +26,9 @@
// 5.5.2 - DS1307 Real Time clock
// 5.5.1 - Momentum
// 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.2.96 - EXRAIL additions XFWD() and XREV()
// 5.2.95 - Release candidate for 5.4