-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunc_Help.cpp
More file actions
49 lines (46 loc) · 2.65 KB
/
Func_Help.cpp
File metadata and controls
49 lines (46 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
//
//
#include "Func_Help.h"
//-----------------------------------------------------------------------------------------------------------------------------
int16_t GetPosNEQ(char xbuffer[], int16_t& StartPos, int16_t& EndPos, char& foundChar, char noSChar, char noSChar2) {
uint8_t found = 0;
uint8_t i;
for (i = StartPos; i < EndPos; i++) { // suche und untersuche im erlaubten Bereich
foundChar = xbuffer[i];
if (foundChar != noSChar && foundChar != noSChar2) { // sobald ein nützliches Zeichen entdeckt wird ist man fertig
StartPos = i; // dieser Wert könnte auch 0 sein und damit doch gültig
foundChar = xbuffer[i];
found = 1;
break;
}
}
if (found == 0) { // wenn keine passende Stelle gefunden wurde
StartPos = -1; // 32767; // INTEGER positives Maximum -32767 negatives Maximum
foundChar = 0x00;
} // wenn keine gültige Stelle gefunden wurde wird -1 als Wert geliefert
else {} // gültige Stelle gefunden, StartPos beinhaltet bereits die passende Stelle
return StartPos;
}
//-----------------------------------------------------------------------------------------------------------------------------
//int16_t GetPosEQ(char xbuffer[], int16_t& StartPos, int16_t& EndPos, char& foundChar, char searchChar, char = 0xfe);
int16_t GetPosEQ(char xbuffer[], int16_t& StartPos, int16_t& EndPos, char& foundChar, char searchChar, char searchChar2) {
uint8_t found = 0;
uint8_t i;
for (i = StartPos; i < EndPos; i++) { // suche und untersuche im erlaubten Bereich
foundChar = xbuffer[i];
if (foundChar == searchChar || foundChar == searchChar2) { // sobald ein Zeichen entdeckt wird ist man fertig
StartPos = i; // dieser Wert könnte auch 0 sein und damit doch gültig
if (StartPos < EndPos) { foundChar = xbuffer[StartPos + 1]; }
else { foundChar = 0x00; }
found = 1;
break;
}
}
if (found == 0) { // wenn keine passende Stelle gefunden wurde
StartPos = 255;
foundChar = 0x00;
} // wenn keine gültige Stelle gefunden wurde wird 255 als Wert geliefert
else {} // gültige Stelle gefunden, bufferStartPos beinhaltet bereits die passende Stelle
return StartPos;
}