Skip to content

Commit

Permalink
Don't queue IMU data
Browse files Browse the repository at this point in the history
  • Loading branch information
JovannMC committed Aug 8, 2024
1 parent a1535ed commit 97de0b6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/mode/com.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ async function processData(data: string, port: string) {

try {
let trackerName = null;
let identifier = null;
let identifier: string = null;
let portId: string = null;
let portData: string = null;

Expand All @@ -278,17 +278,19 @@ async function processData(data: string, port: string) {

// Check if all trackers are assigned and queue if not
if (!trackersAssigned && !isOverThreshold) {
if (dataQueue && dataQueue.length >= 200) {
if (dataQueue && dataQueue.length >= 50) {
isOverThreshold = true;
log(`Data queue is over threshold, assuming not all trackers have been connected.`);
dataQueue = null;
return;
}

// Skip IMU data for trackers, not needed to be processed after trackers are assigned
if (identifier.startsWith('x')) return;

dataQueue.push({ data, port });
log(`Trackers not assigned yet - ${data} - Queue length: ${dataQueue.length}`);
}

const numberOfPorts = Object.keys(activePorts).length;
const requiredAssignments = numberOfPorts * 2;

Expand Down

0 comments on commit 97de0b6

Please sign in to comment.