Skip to content

Commit

Permalink
fix switch back to 0 in HTP merging (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
mutec authored Nov 13, 2024
1 parent 767dfc9 commit 7be0d0c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/merging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export class MergingReceiver extends Receiver {
) {
for (let ch = 1; ch <= 512; ch += 1) {
const newValue = packet.payload[ch] || 0;
if ((mergedData[ch] ?? 0) < newValue) {
if ((mergedData[ch] ?? 0) <= newValue) {
mergedData[ch] = newValue;
}
}
Expand Down
4 changes: 4 additions & 0 deletions test/merging.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ describe('HTP', () => {
}),
},
});
deleteZeros(merged);

expect(merged).toStrictEqual({
// HTP applies to the whole packet, so channel 4 is 0, instead of 204
// referenceData is irrelevant for HTP, so channel 5 is 0, instead of 5
Expand All @@ -66,6 +68,8 @@ describe('HTP', () => {
}),
},
});
deleteZeros(merged);

expect(merged).toStrictEqual({
1: 201,
2: 202,
Expand Down

0 comments on commit 7be0d0c

Please sign in to comment.