kopia lustrzana https://github.com/weetmuts/wmbusmeters
Skip spurious bytes when testing for amb8465.
rodzic
ab76ea9788
commit
08b9153167
16
src/util.cc
16
src/util.cc
|
@ -1933,3 +1933,19 @@ bool isValidBps(string b)
|
|||
if (b == "115200") return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t findBytes(vector<uchar> &v, uchar a, uchar b, uchar c)
|
||||
{
|
||||
size_t p = 0;
|
||||
while (p+2 < v.size())
|
||||
{
|
||||
if (v[p+0] == a &&
|
||||
v[p+1] == b &&
|
||||
v[p+2] == c)
|
||||
{
|
||||
return p;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -214,4 +214,6 @@ std::string lookForExecutable(std::string prog, std::string bin_dir, std::string
|
|||
bool parseExtras(std::string s, std::map<std::string,std::string> *extras);
|
||||
void checkIfMultipleWmbusMetersRunning();
|
||||
|
||||
size_t findBytes(std::vector<uchar> &v, uchar a, uchar b, uchar c);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -592,6 +592,14 @@ AccessCheck detectAMB8465(Detected *detected, shared_ptr<SerialCommunicationMana
|
|||
|
||||
// FF8A7A00780080710200000000FFFFFA00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF003200021400FFFFFFFFFF010004000000FFFFFF01440000000000000000FFFF0B040100FFFFFFFFFF00030000FFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF17
|
||||
|
||||
size_t skip = findBytes(response, 0xff, 0x8A, 0x7A);
|
||||
while (skip > 0)
|
||||
{
|
||||
// Sometimes there seems to be a leading 00 noise byte. Skip those.
|
||||
response.erase(response.begin());
|
||||
skip--;
|
||||
}
|
||||
|
||||
if (response.size() < 8 ||
|
||||
response[0] != 0xff ||
|
||||
response[1] != (0x80 | request[1]) ||
|
||||
|
|
Ładowanie…
Reference in New Issue