Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
Update buffer bit delimeter (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexGodbehere authored Mar 7, 2024
1 parent 6b13e9c commit 9607497
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/helpers/typeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,20 @@ export function parseValueFromPayload(msg: any, metric: sparkplugMetric, payload
}
break;
case serialisationType.fixedBuffer:
return parseValFromBuffer(metric.type, (typeof metric.properties !== "undefined" && typeof metric.properties.endianness !== "undefined" ? metric.properties.endianness.value as number : 0), parseInt(path), msg as Buffer, parseInt(path));
// Split the path into path.bit if bit. This may not always match but the bit is required if the data is a boolean
let _path = path;
let bit: number | undefined;
if (path.includes(':')) {
const splitPath = path.split(':');
_path = splitPath[0];
bit = parseInt(splitPath[1]);
}
return parseValFromBuffer(
metric.type,
(typeof metric.properties !== "undefined" && typeof metric.properties.endianness !== "undefined" ? metric.properties.endianness.value as number : 0),
parseInt(_path),
msg as Buffer,
bit);
case serialisationType.serialisedBuffer:
break;
default:
Expand Down

0 comments on commit 9607497

Please sign in to comment.