first use of libmbus

This commit is contained in:
Wolfgang Hottgenroth 2020-11-03 10:24:03 +01:00
parent 83c6d65172
commit a13588f97f
Signed by: wn
GPG Key ID: 6C1E5E531E0D5D7F

View File

@ -12,6 +12,7 @@
#include <logger.h>
#include <frontend.h>
#include <mbus/mbus-protocol.h>
typedef enum {
MBCS_IDLE,
@ -52,7 +53,37 @@ static t_mbusCommHandle mbusCommHandle = { .state = MBCS_IDLE, .retryCnt = 0, .c
static void parseAndPrintFrame(t_longframe *frame) {
mbus_frame reply;
memset(&reply, 0, sizeof(reply));
//mbus_parse(&reply, buf, len);
reply.start1 = frame->start1;
reply.length1 = frame->length1;
reply.length2 = frame->length2;
reply.start2 = frame->start2;
reply.control = frame->c;
reply.address = frame->a;
reply.control_information = frame->ci;
memcpy(reply.data, frame->userdata, frame->length1 - 3);
reply.checksum = frame->chksum;
reply.stop = frame->stop;
reply.type = MBUS_FRAME_TYPE_LONG;
reply.data_size = frame->length1 - 3;
int r = mbus_frame_verify(&reply);
logMsg("papf verify: %d", r);
// memset(&frame_data, 0, sizeof(frame_data));
// mbus_frame_data_parse(&reply, &frame_data);
// mbus_frame_print(&reply);
}
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",