From 431db07c80087e5154d51484afcba6cb8da355d2 Mon Sep 17 00:00:00 2001 From: Barry Daniel Date: Mon, 7 Oct 2024 15:55:52 +1000 Subject: [PATCH] Add files via upload --- CamParser.cpp | 15 +++++------ IO_EXSensorCAM.h | 58 ++++++++++++++++++++++--------------------- myHal.cpp_example.txt | 32 +++++++++--------------- 3 files changed, 50 insertions(+), 55 deletions(-) diff --git a/CamParser.cpp b/CamParser.cpp index f27ecc9..27ba9a3 100644 --- a/CamParser.cpp +++ b/CamParser.cpp @@ -1,5 +1,5 @@ -//sensorCAM parser.cpp version 3.01 Aug 2024 +//sensorCAM parser.cpp version 3.03 Sep 2024 #include "CamParser.h" #include "FSH.h" #include "IO_EXSensorCAM.h" @@ -48,17 +48,18 @@ bool CamParser::parseN(Print * stream, byte paramCount, int16_t p[]) { } if (EXSensorCAM::CAMBaseVpin==0) return false; // no cam defined - if((p[0] == ve) || (p[0] == ver) || (p[0] == 'V')) camop='^'; + // send UPPER case to sensorCAM to flag binary data from a DCCEX-CS parser switch(paramCount) { - case 1: // produces '^' + case 1: // produces '^' + if((p[0] == ve) || (p[0] == ver) || (p[0] == 'V')) camop='^'; if (STRCHR_P((const char *)F("EFGMQRVW^"),camop) == nullptr) return false; - if (camop=='F') camop=']'; // for Reset/Finish webCAM. if (camop=='Q') param3=10; // for activation state of all 10 banks of sensors - break; // Coded as ']' else conflicts with + if (camop=='F') camop=']'; // for Reset/Finish webCAM. + break; // F Coded as ']' else conflicts with case 2: // - if (STRCHR_P((const char *)F("ABFILMNOPQRSTUV^"),camop)==nullptr) return false; + if (STRCHR_P((const char *)F("ABFILMNOPQRSTUV"),camop)==nullptr) return false; param1=p[1]; break; @@ -74,7 +75,7 @@ bool CamParser::parseN(Print * stream, byte paramCount, int16_t p[]) { param3 = p[2]; break; - case 4: // + case 4: // if (camop!='A') return false; //must start with 'a' if (p[3]>316 || p[3]<0) return false; if (p[2]>236 || p[2]<0) return false; diff --git a/IO_EXSensorCAM.h b/IO_EXSensorCAM.h index 1fc5d36..fcc0bd8 100644 --- a/IO_EXSensorCAM.h +++ b/IO_EXSensorCAM.h @@ -16,10 +16,11 @@ * You should have received a copy of the GNU General Public License * along with CommandStation. If not, see . */ -#define driverVer 304 +#define driverVer 305 +// v305 less debug & alpha ordered switch // v304 static oldb0; t(##[,%%]; // v303 zipped with CS 5.2.76 and uploaded to repo (with debug) -// v302 SEND=StringFormatter::send; remove Sp(); + 'q'; memcpy( .8) -> .7); +// v302 SEND=StringFormatter::send, remove Sp(), add 'q', memcpy( .8) -> .7); // v301 improved 'f','p'&'q' code and driver version calc. Correct bsNo calc. for 'a' // v300 stripped & revised without expander functionality. Needs sensorCAM.h v300 AND CamParser.cpp // v222 uses '@'for EXIORDD read. handles and @@ -222,7 +223,7 @@ int ioESP32(uint8_t i2cAddr,uint8_t *rBuf,int inbytes,uint8_t *outBuff,int outby //rBuf contains packet of up to 32 bytes usually with (ascii) cmd header in rBuf[0] //sensorCmd command header byte from CAM (in rBuf[0]?) int processIncomingPkt(uint8_t *rBuf,uint8_t sensorCmd) { -static uint8_t oldb0; //for debug only +//static uint8_t oldb0; //for debug only int k; int b; char str[] = "11111111"; @@ -230,9 +231,10 @@ static uint8_t oldb0; //for debug only switch (sensorCmd){ case '`': //response to request for digitalInputStates[] table '@'=>'`' memcpy(_digitalInputStates, rBuf+1, digitalBytesNeeded); - if ( _digitalInputStates[0]!=oldb0) { oldb0=_digitalInputStates[0]; //debug +// if ( _digitalInputStates[0]!=oldb0) { oldb0=_digitalInputStates[0]; //debug // for (k=0;k<5;k++) {Serial.print(" ");Serial.print(_digitalInputStates[k],HEX);} - }break; +// } + break; case EXIORDY: //some commands give back acknowledgement only break; @@ -241,33 +243,12 @@ static uint8_t oldb0; //for debug only DIAG(F("CAM cmd error 0xFE 0x%x"),rBuf[1]); break; - case '~': //information from '^' version request + case '~': //information from '^' version request DIAG(F("EX-SensorCAM device found, I2C:%s,CAM Version v%d.%d.%d vpins %u-%u"), _I2CAddress.toString(), rBuf[1]/10, rBuf[1]%10, rBuf[2],(int) _firstVpin, (int) _firstVpin +_nPins-1); DIAG(F("IO_EXSensorCAM driver v0.%d.%d vpin: %d "), driverVer/100,driverVer%100,_firstVpin); break; - - case 'i': //information from i%% - k=256*rBuf[5]+rBuf[4]; - DIAG(F("(i%%%%[,$$]) Info: Sensor 0%o(%d) enabled:%d status:%d row=%d x=%d Twin=0%o pvtThreshold=%d A~%d") - ,rBuf[1],rBuf[1],rBuf[3],rBuf[2],rBuf[6],k,rBuf[7],rBuf[9],int(rBuf[8])*16); - break; - - case 'm': - DIAG(F("(m$[,##]) Min/max: $ frames min2flip (trip) %d, maxSensors 0%o, minSensors 0%o, nLED %d," - " threshold %d, TWOIMAGE_MAXBS 0%o"),rBuf[1],rBuf[3],rBuf[2],rBuf[4],rBuf[5],rBuf[6]); - break; - - case 'n': - DIAG(F("(n$[,##]) Nominate: $ nLED %d, ## minSensors 0%o (maxSensors 0%o threshold %d)") - ,rBuf[4],rBuf[2],rBuf[3],rBuf[5]); - break; - - case 'q': - for (int i =0; i<8; i++) str[i] = ((rBuf[2] << i) & 0x80 ? '1' : '0'); - DIAG(F("(q $) Query bank %c ENABLED sensors(S%c7-%c0): %s "), rBuf[1], rBuf[1], rBuf[1], str); - break; - + case 'f': DIAG(F("(f %%%%) frame header 'f' for bsNo %d/%d - showing Quarter sample (1 row) only"), rBuf[1]/8,rBuf[1]%8); SEND(&USB_SERIAL,F("\n"); break; + case 'i': //information from i%% + k=256*rBuf[5]+rBuf[4]; + DIAG(F("(i%%%%[,$$]) Info: Sensor 0%o(%d) enabled:%d status:%d row=%d x=%d Twin=0%o pvtThreshold=%d A~%d") + ,rBuf[1],rBuf[1],rBuf[3],rBuf[2],rBuf[6],k,rBuf[7],rBuf[9],int(rBuf[8])*16); + break; + + case 'm': + DIAG(F("(m$[,##]) Min/max: $ frames min2flip (trip) %d, maxSensors 0%o, minSensors 0%o, nLED %d," + " threshold %d, TWOIMAGE_MAXBS 0%o"),rBuf[1],rBuf[3],rBuf[2],rBuf[4],rBuf[5],rBuf[6]); + break; + + case 'n': + DIAG(F("(n$[,##]) Nominate: $ nLED %d, ## minSensors 0%o (maxSensors 0%o threshold %d)") + ,rBuf[4],rBuf[2],rBuf[3],rBuf[5]); + break; + case 'p': b=rBuf[1]-2; if(b<4) { Serial.print("\n"); break; } @@ -288,6 +285,11 @@ static uint8_t oldb0; //for debug only Serial.print(" n>\n"); break; + case 'q': + for (int i =0; i<8; i++) str[i] = ((rBuf[2] << i) & 0x80 ? '1' : '0'); + DIAG(F("(q $) Query bank %c ENABLED sensors(S%c7-%c0): %s "), rBuf[1], rBuf[1], rBuf[1], str); + break; + case 't': //threshold etc. from t## //bad pkt if 't' FF's if(rBuf[1]==0xFF) {Serial.println("");_savedCmd[2] +=1; return 0;} SEND(&USB_SERIAL,F("