fix: Enhance command logging and error handling for turtle commands

This commit is contained in:
MayaTheShy
2026-02-16 01:27:58 -05:00
parent 9a02a8d27f
commit 836d734b1f

View File

@@ -52,7 +52,11 @@ wss.on('connection', (ws) => {
param: data.param,
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) {
@@ -120,6 +124,11 @@ app.get('/api/turtle/:id/commands', (req, res) => {
const turtle = turtleData.get(turtleID);
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
turtle.pendingCommands = [];