5 Commits

Author SHA1 Message Date
4ceabca1b4 photo 2024-05-08 10:50:50 +02:00
a33dbe2387 Merge branch 'fix_power_export_issue' 2023-03-18 18:03:56 +01:00
78509ff2cb test scripts 2023-03-18 18:03:05 +01:00
13c8344276 allow negative values from mbus 2023-03-15 22:55:37 +01:00
b7071379b9 add volume 2022-10-16 19:40:34 +02:00
8 changed files with 39 additions and 4 deletions

View File

@ -218,7 +218,7 @@ static void parseAndPrintFrame() {
// mbusCommHandle.requestId,
// parsedVIB.name, parsedVIB.unit, parsedVIB.exponent);
if (parsedVIB.found) {
uint32_t value = strtol(mbus_data_record_value(record), NULL, 10);
int32_t value = strtol(mbus_data_record_value(record), NULL, 10);
float weightedValue = ((float) value) * powf(10.0, ((float) parsedVIB.exponent));
coloredMsg(LOG_YELLOW, false, "mbc papf [%d] %s is %.1f %s (%d * 10^%d)",
mbusCommHandle.requestId, parsedVIB.name, weightedValue, parsedVIB.unit,

View File

@ -12,12 +12,14 @@ static const char NAME_VOLTAGE[] = "Voltage";
static const char NAME_CURRENT[] = "Current";
static const char NAME_POWER[] = "Power";
static const char NAME_ENERGY[] = "Energy";
static const char NAME_VOLUME[] = "Volume";
static const char NAME_UNKNOWN[] = "unknown";
static const char UNIT_VOLT[] = "V";
static const char UNIT_AMPERE[] = "A";
static const char UNIT_WATT[] = "W";
static const char UNIT_WATTHOUR[] = "Wh";
static const char UNIT_QUBICMETER[] = "m3";
static const char UNIT_UNKNOWN[] = "?";
static parsedVIB_t parseVIB_FB(mbus_value_information_block vib) {
@ -61,6 +63,11 @@ static parsedVIB_t parseVIB_default(mbus_value_information_block vib) {
parsedVIB.unit = UNIT_WATT;
parsedVIB.exponent = (vib.vif & 0b0111) - 3;
parsedVIB.found = true;
} else if ((vib.vif & 0b01111000) == 0b00010000) {
parsedVIB.name = NAME_VOLUME;
parsedVIB.unit = UNIT_QUBICMETER;
parsedVIB.exponent = (vib.vif & 0b0111) - 3;
parsedVIB.found = true;
} else {
coloredMsg(LOG_RED, true, "mpe pvd unknown vif 0x%02x", vib.vif);
}

BIN
docs/IMG_2915.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

View File

@ -1,3 +1,6 @@
![](./docs/IMG_2915.jpg)
## Build environment
On Ubuntu/Debian install

View File

@ -1,12 +1,12 @@
CFLAGS=-I../cube/User/Inc -DTEST
CFLAGS=-I../../cube/User/Inc -DTEST
test: ringbuffer.o test.o
gcc -o $@ -lcunit $^
ringbuffer.o: ../cube/User/Src/ringbuffer.c
ringbuffer.o: ../../cube/User/Src/ringbuffer.c
gcc -c -o $@ $(CFLAGS) $^
logger.o: ../cube/User/Src/logger.c
logger.o: ../../cube/User/Src/logger.c
gcc -c -o $@ $(CFLAGS) $^
test.o: test.c

15
tests/test2/Makefile Normal file
View File

@ -0,0 +1,15 @@
test: test.o
gcc -o $@ $^
test.o: test.c
gcc -c -o $@ $(CFLAGS) $^
.PHONY: run
run: test
./test
.PHONY: clean
clean:
rm -f *.o test

10
tests/test2/test.c Normal file
View File

@ -0,0 +1,10 @@
#include <stdio.h>
#include <stdint.h>
int main() {
uint32_t i = -10;
int32_t j = i;
printf("%lu %d\n", i, j);
}