p18: get-rated: fix parsing of invalid response
Sometimes (my guess is when AC input line is connected) get-rated (^P007PIRI request) returns additional field in the end. On my device it's two bytes, '00' (0x30 0x30). It shouldn't be there as per documentation (but you know how accurate these chinese docs can be, right?) and, as of now, I have no clue what that means.
This commit is contained in:
parent
750297157d
commit
9ba7a470ad
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "response.h"
|
#include "response.h"
|
||||||
#include "exceptions.h"
|
#include "exceptions.h"
|
||||||
|
#include "../logging.h"
|
||||||
|
|
||||||
#define RETURN_TABLE(...) \
|
#define RETURN_TABLE(...) \
|
||||||
return std::shared_ptr<formatter::Table<VariantHolder>>( \
|
return std::shared_ptr<formatter::Table<VariantHolder>>( \
|
||||||
@ -89,6 +90,12 @@ std::vector<std::string> GetResponse::getList(std::vector<FieldLength> itemLengt
|
|||||||
|
|
||||||
// check each item's length
|
// check each item's length
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
if (i >= itemLengths.size()) {
|
||||||
|
myerr << "while parsing " << demangle_type_name(typeid(*this).name())
|
||||||
|
<< ": item " << i << " is not expected";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!itemLengths[i].validate(list[i].size())) {
|
if (!itemLengths[i].validate(list[i].size())) {
|
||||||
std::ostringstream error;
|
std::ostringstream error;
|
||||||
error << "while parsing " << demangle_type_name(typeid(*this).name());
|
error << "while parsing " << demangle_type_name(typeid(*this).name());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user