Added usage plots and ADC reading for Vcc

This commit is contained in:
Gunnar Skjold
2021-11-27 20:16:26 +01:00
parent 6f09f523e4
commit eb59245118
27 changed files with 1422 additions and 615 deletions

View File

@@ -15,13 +15,15 @@ void mbus_hexdump(const uint8_t* buf, int len) {
printf("]\n");
}
int HDLC_validate(const uint8_t* d, int len, HDLCConfig* config, CosemDateTime* timestamp) {
int HDLC_validate(const uint8_t* d, int length, HDLCConfig* config, CosemDateTime* timestamp) {
//mbus_hexdump(d, len);
HDLCHeader* h = (HDLCHeader*) d;
// Length field (11 lsb of format)
len = (ntohs(h->format) & 0x7FF) + 2;
int len = (ntohs(h->format) & 0x7FF) + 2;
if(len > length)
return -4;
HDLCFooter* f = (HDLCFooter*) (d + len - sizeof *f);
@@ -81,11 +83,12 @@ int HDLC_validate(const uint8_t* d, int len, HDLCConfig* config, CosemDateTime*
}
ptr += 2 + dateTime->base.length;
} else if(dateTime->base.type == CosemTypeNull) {
timestamp = 0;
ptr++;
} else if(dateTime->base.type == CosemTypeDateTime) {
memcpy(timestamp, ptr, dateTime->base.length);
} else if(dateTime->base.type == 0x0C) { // Kamstrup bug...
memcpy(timestamp, ptr, dateTime->base.length);
memcpy(timestamp, ptr, 0x0C);
ptr += 13;
} else {
return -99;

View File

@@ -5,6 +5,8 @@
#include <stdint.h>
#define HDLC_FLAG 0x7E
#define HDLC_BOUNDRY_FLAG_MISSING -1
#define HDLC_FRAME_INCOMPLETE -4
#define HDLC_ENCRYPTION_CONFIG_MISSING -90
struct HDLCConfig {