Compare commits
2 Commits
b1d68565cd
...
5a4fd000fe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a4fd000fe | ||
|
|
86250deba3 |
@@ -913,7 +913,13 @@ local function processMessage(message)
|
||||
|
||||
if message.command then
|
||||
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))
|
||||
-- Don't try to serialize the commands table - it contains functions!
|
||||
-- Just list the command names
|
||||
local availableCommands = {}
|
||||
for cmdName, _ in pairs(commands) do
|
||||
table.insert(availableCommands, cmdName)
|
||||
end
|
||||
print(" Available handlers: " .. table.concat(availableCommands, ", "))
|
||||
|
||||
local handler = commands[message.command]
|
||||
if handler then
|
||||
|
||||
@@ -296,6 +296,14 @@ end
|
||||
|
||||
addLog("Listening on channels " .. STATUS_CHANNEL .. ", " .. CHANNEL_RECEIVE .. ", " .. POCKET_CHANNEL, colors.lightBlue)
|
||||
|
||||
-- Debug: Print what channels are actually open
|
||||
print("Opened channels:")
|
||||
for i = 0, 65535 do
|
||||
if modem.isOpen(i) then
|
||||
print(" Channel " .. i .. " is OPEN")
|
||||
end
|
||||
end
|
||||
|
||||
-- Start polling timer
|
||||
local POLL_INTERVAL = 2 -- Poll every 2 seconds (reduced frequency for better reliability)
|
||||
os.startTimer(POLL_INTERVAL)
|
||||
@@ -305,9 +313,18 @@ local recentCommandSends = {}
|
||||
|
||||
-- Main loop
|
||||
local lastRefresh = os.epoch("utc")
|
||||
print("🎧 Starting main event loop...")
|
||||
while true do
|
||||
local event, side, channel, replyChannel, message, distance = os.pullEvent()
|
||||
|
||||
-- Log ALL modem messages for debugging
|
||||
if event == "modem_message" then
|
||||
print("🔔 MODEM MESSAGE RECEIVED!")
|
||||
print(" Event: " .. event)
|
||||
print(" Channel: " .. channel)
|
||||
print(" Expected channels: " .. STATUS_CHANNEL .. " (status), " .. CHANNEL_RECEIVE .. " (receive), " .. POCKET_CHANNEL .. " (pocket)")
|
||||
end
|
||||
|
||||
if event == "timer" then
|
||||
-- Poll for commands for all known turtles
|
||||
for turtleID, turtleData in pairs(turtles) do
|
||||
|
||||
Reference in New Issue
Block a user