diff --git a/inventoryManager.lua b/inventoryManager.lua index db44f3a..adbf68e 100644 --- a/inventoryManager.lua +++ b/inventoryManager.lua @@ -640,12 +640,15 @@ local function main() -- miss events while other tasks yield for "task_complete" etc. resilient("Network-capture", function() if not ctx.networkModem then + log.warn("NET-CAP", "No modem — capture task idle") while true do sleep(3600) end end + log.info("NET-CAP", "Capture task started, listening on ch %d", cfg.ORDER_CHANNEL) while true do local event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message") if channel == cfg.ORDER_CHANNEL and type(message) == "table" then table.insert(networkQueue, { replyChannel = replyChannel, message = message }) + log.info("NET-CAP", "Queued: type=%s queue=%d", tostring(message.type), #networkQueue) end end end), @@ -653,16 +656,20 @@ local function main() -- Task 13b: Network message processor (drains queue — safe to yield) resilient("Network-processor", function() if not ctx.networkModem then + log.warn("NET-PROC", "No modem — processor task idle") while true do sleep(3600) end end + log.info("NET-PROC", "Processor task started") while true do if #networkQueue == 0 then - sleep(0) + os.pullEvent() end while #networkQueue > 0 do local entry = table.remove(networkQueue, 1) local message = entry.message local replyChannel = entry.replyChannel + log.info("NET-PROC", "Processing: type=%s id=%s queue=%d", + tostring(message.type), tostring(message.commandId), #networkQueue) if isCommandDuplicate(message.commandId) then log.debug("NET", "Duplicate command skipped: %s", tostring(message.commandId))