From 836d734b1f463924be24ea06b1fa05326d11dac5 Mon Sep 17 00:00:00 2001 From: MayaTheShy Date: Mon, 16 Feb 2026 01:27:58 -0500 Subject: [PATCH] fix: Enhance command logging and error handling for turtle commands --- server/server.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/server/server.js b/server/server.js index e3a9d5f..17e41d4 100644 --- a/server/server.js +++ b/server/server.js @@ -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 = [];