refactor: optimize polling interval and command transmission for improved responsiveness
This commit is contained in:
@@ -305,7 +305,7 @@ for i = 0, 65535 do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Start polling timer
|
-- Start polling timer
|
||||||
local POLL_INTERVAL = 2 -- Poll every 2 seconds (reduced frequency for better reliability)
|
local POLL_INTERVAL = 1 -- Poll every 1 second for responsive command execution
|
||||||
os.startTimer(POLL_INTERVAL)
|
os.startTimer(POLL_INTERVAL)
|
||||||
|
|
||||||
-- Track which turtles we've sent commands to recently
|
-- Track which turtles we've sent commands to recently
|
||||||
@@ -360,15 +360,15 @@ while true do
|
|||||||
addLog(" CMD: " .. cmd.command .. " -> T#" .. turtleID, colors.yellow)
|
addLog(" CMD: " .. cmd.command .. " -> T#" .. turtleID, colors.yellow)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Send command multiple times for reliability
|
-- Send command twice for reliability
|
||||||
for i = 1, 3 do
|
for i = 1, 2 do
|
||||||
modem.transmit(COMMAND_CHANNEL, CHANNEL_RECEIVE, commandPacket)
|
modem.transmit(COMMAND_CHANNEL, CHANNEL_RECEIVE, commandPacket)
|
||||||
os.sleep(0.05)
|
os.sleep(0.05)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Acknowledge that we sent the commands
|
-- Acknowledge that we sent the commands
|
||||||
os.sleep(1.5)
|
os.sleep(0.3)
|
||||||
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