vif parsing

This commit is contained in:
2020-11-17 18:44:57 +01:00
parent c7ac9a9dc3
commit 7bcfa7070d
3 changed files with 19 additions and 3 deletions

View File

@ -3,10 +3,12 @@
#include <logger.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
static parsedVIB_t parseVIB_FB(mbus_value_information_block vib) {
parsedVIB_t parsedVIB = { .name = "FB unknown", .unit = "?", .exponent = 1 };
parsedVIB_t parsedVIB = { .name = "FB unknown", .unit = "?", .exponent = 1, .found = false };
coloredMsg(LOG_RED, true, "mpe pvd_fb unknown vife 0x%02x", vib.vife[0]);
@ -14,16 +16,18 @@ static parsedVIB_t parseVIB_FB(mbus_value_information_block vib) {
}
static parsedVIB_t parseVIB_FD(mbus_value_information_block vib) {
parsedVIB_t parsedVIB = { .name = "FD unknown", .unit = "?", .exponent = 1 };
parsedVIB_t parsedVIB = { .name = "FD unknown", .unit = "?", .exponent = 1, .found = false };
if ((vib.vife[0] & 0b01110000) == 0b01000000) {
strcpy(parsedVIB.name, "Voltage");
strcpy(parsedVIB.unit, "V");
parsedVIB.exponent = (vib.vife[0] & 0b01111) - 9;
parsedVIB.found = true;
} else if ((vib.vife[0] & 0b01110000) == 0b01010000) {
strcpy(parsedVIB.name, "Current");
strcpy(parsedVIB.unit, "A");
parsedVIB.exponent = (vib.vife[0] & 0b01111) - 12;
parsedVIB.found = true;
} else {
coloredMsg(LOG_RED, true, "mpe pvd_fd unknown vife 0x%02x", vib.vife[0]);
}
@ -32,16 +36,18 @@ static parsedVIB_t parseVIB_FD(mbus_value_information_block vib) {
}
static parsedVIB_t parseVIB_default(mbus_value_information_block vib) {
parsedVIB_t parsedVIB = { .name = "default unknown", .unit = "?", .exponent = 1 };
parsedVIB_t parsedVIB = { .name = "default unknown", .unit = "?", .exponent = 1, .found = false };
if ((vib.vif & 0b01111000) == 0b00000000) {
strcpy(parsedVIB.name, "Energy");
strcpy(parsedVIB.unit, "Wh");
parsedVIB.exponent = (vib.vif & 0b0111) - 3;
parsedVIB.found = true;
} else if ((vib.vif & 0b01111000) == 0b00101000) {
strcpy(parsedVIB.name, "Power");
strcpy(parsedVIB.unit, "W");
parsedVIB.exponent = (vib.vif & 0b0111) - 3;
parsedVIB.found = true;
} else {
coloredMsg(LOG_RED, true, "mpe pvd unknown vif 0x%02x", vib.vif);
}