fix: Enhance command logging and error handling for turtle commands
This commit is contained in:
@@ -52,7 +52,11 @@ wss.on('connection', (ws) => {
|
|||||||
param: data.param,
|
param: data.param,
|
||||||
timestamp: Date.now()
|
timestamp: Date.now()
|
||||||
});
|
});
|
||||||
console.log(`📤 Command queued for turtle ${turtleID}:`, data.command);
|
console.log(`✅ Command queued for turtle ${turtleID}: ${data.command}`, data.param ? `(param: ${data.param})` : '');
|
||||||
|
console.log(` Pending commands: ${turtle.pendingCommands.length}`);
|
||||||
|
} else {
|
||||||
|
console.log(`❌ Turtle ${turtleID} not found in turtleData`);
|
||||||
|
console.log(` Available turtles:`, Array.from(turtleData.keys()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -120,6 +124,11 @@ app.get('/api/turtle/:id/commands', (req, res) => {
|
|||||||
const turtle = turtleData.get(turtleID);
|
const turtle = turtleData.get(turtleID);
|
||||||
const commands = turtle.pendingCommands || [];
|
const commands = turtle.pendingCommands || [];
|
||||||
|
|
||||||
|
if (commands.length > 0) {
|
||||||
|
console.log(`📤 Sending ${commands.length} command(s) to turtle ${turtleID}`);
|
||||||
|
commands.forEach(cmd => console.log(` - ${cmd.command}`, cmd.param ? `(${cmd.param})` : ''));
|
||||||
|
}
|
||||||
|
|
||||||
// Clear pending commands
|
// Clear pending commands
|
||||||
turtle.pendingCommands = [];
|
turtle.pendingCommands = [];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user