From 9c76689e06a508c33fefc9f5d9c60f053d3a330e Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Tue, 3 Nov 2020 12:42:55 +0100 Subject: [PATCH] first use of libmbus --- cube/User/Src/mbusComm.c | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/cube/User/Src/mbusComm.c b/cube/User/Src/mbusComm.c index 3495682..9282156 100644 --- a/cube/User/Src/mbusComm.c +++ b/cube/User/Src/mbusComm.c @@ -71,38 +71,29 @@ static void parseAndPrintFrame(t_longframe *frame) { reply.type = MBUS_FRAME_TYPE_LONG; reply.data_size = frame->length1 - 3; - int r = mbus_frame_verify(&reply); - logMsg("papf verify: %d", r); - mbus_frame_data frame_data; memset(&frame_data, 0, sizeof(frame_data)); - r = mbus_frame_data_parse(&reply, &frame_data); - logMsg("papf parse: %d, t:%d", r, frame_data.type); - - mbus_data_record *record; - int i; - for (record = frame_data.data_var.record, i = 0; - record; - record = record->next, i++) { - logMsg("papf len: %d, dif: %02x, difel: %02x, vif: %02x, vifel: %02x", - record->data_len, - record->drh.dib.dif, - record->drh.dib.ndife, - record->drh.vib.vif, - record->drh.vib.nvife); - logMsg("papf txt: F:%s U:%s V:%s", - mbus_data_record_function(record), - mbus_data_record_unit(record), - mbus_data_record_value(record)); + int r = mbus_frame_data_parse(&reply, &frame_data); + if (r == 0) { + mbus_data_record *record; + int i; + for (record = frame_data.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)); + } + mbus_data_record_free(frame_data.data_var.record); + } else { + logMsg("papf err: unable to parse frame"); } - - mbus_data_record_free(frame_data.data_var.record); } 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", @@ -110,6 +101,7 @@ static void printFrame(t_longframe *frame) { logMsg("frame: userdata ..."); logMsg("frame: CHKSUM:%02x", frame->chksum); logMsg("frame: %02x", frame->stop); + */ } static void handleRequestEngine(void *handle);