Skip to content

Commit

Permalink
signalDecoder.cpp
Browse files Browse the repository at this point in the history
In ManchesterpatternDecoder isManchester wird geprüft, ob longlow + longhigh und longhigh+longlow als Sequenz vorkommen.
Dies ist notwendig, um eine bessere MC Erkennung zu erreichen. In der Regel, sollten MC Signale auch beide Sequenzen enthalten. Auch wenn dies nicht 100% garantiert werden kann. z.B bei FFFF ist dies nicht der Fall. Dieser Fall wird aber auch heute bereits nicht erkannt.

fixes #76, #72
  • Loading branch information
sidey79 committed Feb 24, 2018
1 parent 0b81939 commit 93243a4
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 14 deletions.
35 changes: 32 additions & 3 deletions src/_micro-api/libraries/signalDecoder/src/signalDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1724,10 +1724,39 @@ const bool ManchesterpatternDecoder::isManchester()
}

}
if (break_flag == true) {
if (break_flag == false) {
break_flag = true; // Must be set false during loops
uint8_t seq_a = (longhigh * 10) + longlow;
uint8_t seq_b = (longlow * 10) + longhigh;
if (seq_a < 10) seq_a += 100;
if (seq_b < 10) seq_b += 100;
for (uint8_t a = 0; a < 4 && break_flag == true; a++) // check longlow longhigh and vice versa
{
if (sequence_even[a] == seq_a || sequence_odd[a] == seq_a)
{
for (uint8_t a2 = 0; a2 < 4 && break_flag == true; a2++)
{
if (sequence_even[a2] == seq_b || sequence_odd[a2] == seq_b)
{
break_flag = false;
}

}
}

}
#if DEBUGDETECT >= 1
DBG_PRINT(" sequence check not passed");
if (break_flag == true)
DBG_PRINT(" sequence dual long match failed ");
#endif
}
else {
#if DEBUGDETECT >= 1
DBG_PRINT(" basic sequence not passed ");
#endif
}

if (break_flag == true) {
// Check if we can start a new calulation at a later position
if (pdec->messageLen - z > minbitlen)
{
Expand All @@ -1737,13 +1766,13 @@ const bool ManchesterpatternDecoder::isManchester()
sequence_even[a] = -1;
sequence_odd[a] = -1;
}

z++; // Increase z counter to start new check
continue;

}
break;
}

#if DEBUGDETECT >= 1
DBG_PRINT(" all check passed");
#endif
Expand Down
53 changes: 42 additions & 11 deletions tests/testSignalDecoder/signalDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1774,33 +1774,62 @@ const bool ManchesterpatternDecoder::isManchester()
if ((longlow == longhigh) || (shortlow == shorthigh) || (longlow == shortlow) || (longhigh == shorthigh) || (longlow == shorthigh) || (longhigh == shortlow)) break; //Check if the indexes are valid

bool break_flag = false;
for (uint8_t a = 0; a < 4 && break_flag==false; a++)
for (uint8_t a = 0; a < 4 && break_flag == false; a++)
{
#ifdef DEBUGDETECT //>=0
char str[20];
sprintf(str, " seq_even[%d]=%d", a, sequence_even[a]);
DBG_PRINT(str);
sprintf(str, " seq_odd[%d]=%d", a, sequence_odd[a]);
DBG_PRINT(str);
/* DBG_PRINT(" seq_even["); DBG_PRINT(a,DEC); DBG_PRINT("]");
DBG_PRINT("="); DBG_PRINT(str);
DBG_PRINT(" seq_odd["); DBG_PRINT(a,DEC); DBG_PRINT("]");
DBG_PRINT("="); DBG_PRINT(sequence_odd[a],DEC);
*/
/* DBG_PRINT(" seq_even["); DBG_PRINT(a,DEC); DBG_PRINT("]");
DBG_PRINT("="); DBG_PRINT(str);
DBG_PRINT(" seq_odd["); DBG_PRINT(a,DEC); DBG_PRINT("]");
DBG_PRINT("="); DBG_PRINT(sequence_odd[a],DEC);
*/
#if DEBUGDETECT == 0
DBG_PRINTLN(" ");
DBG_PRINTLN(" ");
#endif
#endif
if ( (sequence_even[a] - sequence_odd[a] != 0) && (sequence_odd[a] == -1 || sequence_even[a] == -1))
if ((sequence_even[a] - sequence_odd[a] != 0) && (sequence_odd[a] == -1 || sequence_even[a] == -1))
{
break_flag = true;
}

}
if (break_flag == true) {
if (break_flag == false) {
break_flag = true; // Must be set false during loops
uint8_t seq_a = (longhigh * 10) + longlow;
uint8_t seq_b = (longlow * 10) + longhigh;
if (seq_a < 10) seq_a += 100;
if (seq_b < 10) seq_b += 100;

for (uint8_t a = 0; a < 4 && break_flag == true; a++) // check longlow longhigh and vice versa
{
if (sequence_even[a] == seq_a || sequence_odd[a] == seq_a)
{
for (uint8_t a2 = 0; a2 < 4 && break_flag == true; a2++)
{
if (sequence_even[a2] == seq_b || sequence_odd[a2] == seq_b)
{
break_flag = false;
}

}
}

}
#if DEBUGDETECT >= 1
DBG_PRINT(" sequence check not passed");
if (break_flag == true)
DBG_PRINT(" sequence dual long match failed ");
#endif
} else {
#if DEBUGDETECT >= 1
DBG_PRINT(" basic sequence not passed ");
#endif
}

if (break_flag == true) {
// Check if we can start a new calulation at a later position
if (pdec->messageLen - z > minbitlen)
{
Expand All @@ -1810,13 +1839,15 @@ const bool ManchesterpatternDecoder::isManchester()
sequence_even[a] = -1;
sequence_odd[a] = -1;
}

z++; // Increase z counter to start new check
continue;

}
break;
}



#if DEBUGDETECT >= 1
DBG_PRINT(" all check passed");
#endif
Expand Down

0 comments on commit 93243a4

Please sign in to comment.