We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6908fb9 commit 1e7c7a7Copy full SHA for 1e7c7a7
src/message.cpp
@@ -54,8 +54,17 @@ Message::ParseSignalsStatus Message::parseSignals(const std::vector<uint8_t>& da
54
case 64:
55
values.push_back((int64_t)v * signal.factor + signal.offset);
56
break;
57
- default:
58
- return ParseSignalsStatus::ErrorInvalidConversion;
+ default: {
+ // 2 complement -> decimal
59
+ const int negative = (v & (1 << (signal.size - 1))) != 0;
60
+ int64_t nativeInt;
61
+ if (negative)
62
+ nativeInt = v | ~((1 << signal.size) - 1);
63
+ else
64
+ nativeInt = v;
65
+ values.push_back(nativeInt * signal.factor + signal.offset);
66
+ break;
67
+ }
68
}
69
} else
70
values.push_back(v * signal.factor + signal.offset);
0 commit comments