first use of libmbus
This commit is contained in:
parent
a928e15e74
commit
43fe49f90d
@ -30,7 +30,9 @@ void helloMeterbus(void *handle) {
|
||||
.address = 80,
|
||||
.consideredField = {
|
||||
{ .label = "energy", .index = 0 },
|
||||
{ .label = "power", .index = 17 }
|
||||
{ .label = "power", .index = 17 },
|
||||
{ .label = "", .index = 0 },
|
||||
{ .label = "", .index = 0 }
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -90,7 +90,9 @@ static t_mbusCommHandle mbusCommHandle = { .state = MBCS_IDLE, .retryCnt = 0, .c
|
||||
|
||||
|
||||
|
||||
static void parseAndPrintFrame(t_longframe *frame) {
|
||||
static void parseAndPrintFrame(t_mbusCommHandle *mbusCommHandle) {
|
||||
t_longframe *frame = &(mbusCommHandle->frame);
|
||||
|
||||
mbus_frame reply;
|
||||
memset(&reply, 0, sizeof(reply));
|
||||
|
||||
@ -120,9 +122,16 @@ static void parseAndPrintFrame(t_longframe *frame) {
|
||||
for (record = data_var->record, i = 0;
|
||||
record;
|
||||
record = record->next, i++) {
|
||||
logMsg("papf txt: U:%s V:%s",
|
||||
mbus_data_record_unit(record),
|
||||
mbus_data_record_value(record));
|
||||
for (uint8_t j = 0; j < MBUSDEVICE_NUM_OF_CONSIDEREDFIELDS; j++) {
|
||||
if ((mbusCommHandle->device->consideredField[j].index == i) &&
|
||||
(strlen(mbusCommHandle->device->consideredField[j].label) > 0)) {
|
||||
logMsg("papf txt: I:%d, L:%s, U:%s V:%s",
|
||||
i,
|
||||
mbusCommHandle->device->consideredField[j].label,
|
||||
mbus_data_record_unit(record),
|
||||
mbus_data_record_value(record));
|
||||
}
|
||||
}
|
||||
}
|
||||
mbus_data_record_free(data_var->record);
|
||||
} else {
|
||||
@ -130,18 +139,6 @@ static void parseAndPrintFrame(t_longframe *frame) {
|
||||
}
|
||||
}
|
||||
|
||||
static void printFrame(t_longframe *frame) {
|
||||
parseAndPrintFrame(frame);
|
||||
/*
|
||||
logMsg("frame: %02x %02x %02x %02x",
|
||||
frame->start1, frame->length1, frame->length2, frame->start2);
|
||||
logMsg("frame: C:%02x A:%02x CI:%02x",
|
||||
frame->c, frame->a, frame->ci);
|
||||
logMsg("frame: userdata ...");
|
||||
logMsg("frame: CHKSUM:%02x", frame->chksum);
|
||||
logMsg("frame: %02x", frame->stop);
|
||||
*/
|
||||
}
|
||||
|
||||
static void handleRequestEngine(void *handle);
|
||||
static void timeoutHandler(void *handle) {
|
||||
@ -334,7 +331,7 @@ static void handleRequestEngine(void *handle) {
|
||||
|
||||
case MBCS_DONE:
|
||||
logMsg("hre state DONE");
|
||||
printFrame(&(localMbusCommHandle->frame));
|
||||
parseAndPrintFrame(localMbusCommHandle);
|
||||
if (localMbusCommHandle->frame.userdata != NULL) {
|
||||
free(localMbusCommHandle->frame.userdata);
|
||||
localMbusCommHandle->frame.userdata = NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user