feat: Enhance command processing feedback in turtle; improve sleep duration for command acknowledgment in webbridge
This commit is contained in:
@@ -903,11 +903,13 @@ local function processMessage(message)
|
|||||||
|
|
||||||
if message.command then
|
if message.command then
|
||||||
print(" Command: " .. message.command)
|
print(" Command: " .. message.command)
|
||||||
|
print(" Available handlers: " .. textutils.serialize(table.keys or function(t) local k={} for n in pairs(t) do table.insert(k,n) end return k end)(commands))
|
||||||
|
|
||||||
local handler = commands[message.command]
|
local handler = commands[message.command]
|
||||||
if handler then
|
if handler then
|
||||||
print(" Executing command...")
|
print(" ✅ Executing command: " .. message.command)
|
||||||
local success, result = handler(message.param)
|
local success, result = handler(message.param)
|
||||||
|
print(" Result: success=" .. tostring(success) .. ", msg=" .. tostring(result))
|
||||||
|
|
||||||
modem.transmit(CHANNEL_SEND, CHANNEL_RECEIVE, {
|
modem.transmit(CHANNEL_SEND, CHANNEL_RECEIVE, {
|
||||||
status = success and "ok" or "error",
|
status = success and "ok" or "error",
|
||||||
@@ -917,8 +919,10 @@ local function processMessage(message)
|
|||||||
|
|
||||||
broadcastStatus()
|
broadcastStatus()
|
||||||
else
|
else
|
||||||
print(" No handler found for command: " .. message.command)
|
print(" ❌ No handler found for command: " .. message.command)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
print(" ❌ No command in message")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -335,7 +335,8 @@ while true do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Acknowledge that we sent the commands
|
-- Acknowledge that we sent the commands
|
||||||
os.sleep(0.5) -- Give turtle time to receive
|
-- Wait longer to ensure turtle has received them
|
||||||
|
os.sleep(1.5) -- Give turtle time to receive and process
|
||||||
if acknowledgeCommands(turtleID) then
|
if acknowledgeCommands(turtleID) then
|
||||||
addLog(" ACK: Commands acknowledged", colors.lime)
|
addLog(" ACK: Commands acknowledged", colors.lime)
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user