Skip to content

Commit

Permalink
Add SpecificationFile#getPacketTemplate.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielwippermann committed Jul 8, 2023
1 parent c14af4a commit db4cc30
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/specification-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,21 @@ class SpecificationFile {
this.packetTemplates = packetTemplates;
}

getPacketTemplate(destinationAddress, sourceAddress, command) {
return this.packetTemplates.find(pt => {
if ((pt.destinationAddress & pt.destinationMask) !== (destinationAddress & pt.destinationMask)) {
// nop
} else if ((pt.sourceAddress & pt.sourceMask) !== (sourceAddress & pt.sourceMask)) {
// nop
} else if (pt.command !== command) {
// nop
} else {
return true;
}
return false;
});
}

getRawValue(pt, ptf, buffer, start, end) {
let rawValue = 0, valid = false;
for (const part of ptf.parts) {
Expand Down

0 comments on commit db4cc30

Please sign in to comment.