feat: Enhance logging for modem communication in turtle and webbridge; improve command transmission feedback

This commit is contained in:
MayaTheShy
2026-02-20 00:52:35 -05:00
parent 5fb8ddf68e
commit 5b23ab1a14
2 changed files with 44 additions and 3 deletions

View File

@@ -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