feat: Enhance logging for modem communication in turtle and webbridge; improve command transmission feedback
This commit is contained in:
32
turtle.lua
32
turtle.lua
@@ -53,6 +53,8 @@ if not modem then
|
||||
error("No wireless modem found!")
|
||||
end
|
||||
modem.open(CHANNEL_RECEIVE)
|
||||
print("📻 Modem opened on channel " .. CHANNEL_RECEIVE)
|
||||
print(" Listening for commands...")
|
||||
|
||||
print("Advanced Mining Turtle System")
|
||||
print("ID: " .. os.getComputerID())
|
||||
@@ -994,12 +996,34 @@ parallel.waitForAny(
|
||||
|
||||
function()
|
||||
-- Command processing loop
|
||||
print("🎧 Command listener started - waiting for messages...")
|
||||
while true do
|
||||
local event, side, channel, replyChannel, message = os.pullEvent()
|
||||
|
||||
if event == "modem_message" then
|
||||
print("Modem message on channel " .. channel)
|
||||
-- Log ALL events for debugging
|
||||
if event ~= "modem_message" then
|
||||
-- Skip non-modem events to reduce spam
|
||||
else
|
||||
print("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
|
||||
print("📻 MODEM MESSAGE DETECTED!")
|
||||
print(" Event: " .. event)
|
||||
print(" Side: " .. tostring(side))
|
||||
print(" Channel: " .. channel)
|
||||
print(" Reply channel: " .. replyChannel)
|
||||
print(" Message type: " .. type(message))
|
||||
print(" CHANNEL_RECEIVE value: " .. CHANNEL_RECEIVE)
|
||||
|
||||
if type(message) == "table" then
|
||||
print(" Message contents:")
|
||||
for k, v in pairs(message) do
|
||||
print(" " .. k .. " = " .. tostring(v))
|
||||
end
|
||||
end
|
||||
print("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
|
||||
|
||||
if channel == CHANNEL_RECEIVE then
|
||||
print(" ✅ Channel matches CHANNEL_RECEIVE!")
|
||||
|
||||
-- Handle home position sync responses
|
||||
if type(message) == "table" then
|
||||
if message.type == "home_position" and message.turtleID == os.getComputerID() then
|
||||
@@ -1016,11 +1040,15 @@ parallel.waitForAny(
|
||||
end
|
||||
else
|
||||
-- Regular command processing
|
||||
print(" Passing to processMessage()")
|
||||
processMessage(message)
|
||||
end
|
||||
else
|
||||
print(" Message not a table, passing to processMessage()")
|
||||
processMessage(message)
|
||||
end
|
||||
else
|
||||
print(" ❌ Channel mismatch! Expected " .. CHANNEL_RECEIVE .. ", got " .. channel)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user