Skip to content

Commit

Permalink
Skip invalid WPILOG control records
Browse files Browse the repository at this point in the history
  • Loading branch information
jwbonner committed Oct 8, 2024
1 parent a103fc4 commit df8f36e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/hub/dataSources/wpilog/wpilogWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ async function start(data: Uint8Array) {
},
(entry, position) => {
if (entry === CONTROL_ENTRY) {
let record = decoder!.getRecordAtPosition(position)[0]!;
if (record.isStart()) {
let record = decoder?.getRecordAtPosition(position)[0];
if (record === null || record === undefined) {
console.warn("Encountered invalid control record at offset", position);
} else if (record.isStart()) {
const startData = record.getStartData();
entryIds[startData.entry] = startData.name;
entryTypes[startData.name] = startData.type;
Expand Down Expand Up @@ -98,7 +100,7 @@ async function start(data: Uint8Array) {
log.setMetadataString(entryIds[setMetadataData.entry], setMetadataData.metadata);
}
}
} else {
} else if (entry in entryIds) {
let key = entryIds[entry];
dataRecordPositions[key].push(position);
}
Expand Down

0 comments on commit df8f36e

Please sign in to comment.