diff --git a/cube/User/Src/main2.c b/cube/User/Src/main2.c index ebf2d1a..ed20da6 100644 --- a/cube/User/Src/main2.c +++ b/cube/User/Src/main2.c @@ -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 } } }; diff --git a/cube/User/Src/mbusComm.c b/cube/User/Src/mbusComm.c index 750457a..3f9c7a1 100644 --- a/cube/User/Src/mbusComm.c +++ b/cube/User/Src/mbusComm.c @@ -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;