DFM: check for bit errors

This commit is contained in:
Hansi, dl9rdz 2021-09-30 14:37:18 +02:00
parent 4c24c8c385
commit ef9ae86969
3 changed files with 14 additions and 7 deletions

View File

@ -234,7 +234,9 @@ fonts=0,1
0,0=Is
0,9=f
1,12=t
2,0=xTelemetry Data
2,0=xSonde
3,0=xData
2,10=A
4,0=Mt°C
4,9=Mh%rH
6,0=MphPa

View File

@ -160,7 +160,8 @@ int DFM::hamming(uint8_t *ham, int L, uint8_t *sym) {
for (i = 0; i < L; i++) { // L bytes (4bit data, 4bit parity)
if (use_ecc) {
int res = check(ham+8*i);
if(ret>=0 && res>=0) ret += res; else ret=-1;
if( res<0 ) ret = -1;
else if ( ret >= 0 && res > 0 ) ret++;
}
// systematic Hamming code: copy bits 0..3
for (j = 0; j < 4; j++) {
@ -552,6 +553,7 @@ int DFM::decodeFrameDFM(uint8_t *data) {
int ret0 = hamming(hamming_conf, 7, block_conf);
int ret1 = hamming(hamming_dat1, 13, block_dat1);
int ret2 = hamming(hamming_dat2, 13, block_dat2);
Serial.printf("Hamming returns %d %d %d -- %d\n", ret0, ret1, ret2, ret0|ret1|ret2);
byte byte_conf[4], byte_dat1[7], byte_dat2[7];
bitsToBytes(block_conf, byte_conf, 7);
@ -561,11 +563,14 @@ int DFM::decodeFrameDFM(uint8_t *data) {
printRaw("CFG", 7, ret0, byte_conf);
printRaw("DAT", 13, ret1, byte_dat1);
printRaw("DAT", 13, ret2, byte_dat2);
decodeCFG(byte_conf);
decodeDAT(byte_dat1);
decodeDAT(byte_dat2);
if (ret0>=0) decodeCFG(byte_conf);
if (ret1>=0 && ret1<=4) decodeDAT(byte_dat1);
if (ret2>=0 && ret2<=4) decodeDAT(byte_dat2);
Serial.println("");
return RX_OK;
// Consistent with autorx: If more than 4 corrected bit errors in DAT block, assume it is possibly corrupt and
// don't treat it as a correct frame (ttgo display shows data anyway, but it is not sent to external sites)
if(ret1>4 || ret2>4) return RX_ERROR;
return (ret0|ret1|ret2)>=0 ? RX_OK : RX_ERROR;
}
// moved to a single function in Sonde(). This function can be used for additional

View File

@ -1,4 +1,4 @@
const char *version_name = "rdzTTGOsonde";
const char *version_id = "devel20210928";
const char *version_id = "devel20210930";
const int SPIFFS_MAJOR=2;
const int SPIFFS_MINOR=16;