Posted 16 February 2015 - 06:12 PM
So I have this function (put inside a coroutine) that isn't working. For some reason, the call to
I know this because in the output of the program, "Beginning loop run…" is shown, but "I got something…" never appears, ever, even when I send a barrage of both P2P and broadcast messages over both wired and wireless modems. Yes, I am sure that I opened the modem, as the red ring at the base of the modem(s) turns on.
rednet.receive
never returns a value, even long after the 5 seconds that it's given in the parameter.
local function recvLoop()
print("RedMesh coroutine started!")
vprint("Checking on protocol \"" .. rnProtocolName .. "\".")
while true do
print("Beginning loop run...")
local sender, msg, proto = rednet.receive(rnProtocolName, 5) -- THIS NEVER RETURNS
vprint("I got something...")
local env = {}
if pcall(function() env = textutils.deserialize(msg) end) then -- Tries to deserialize.
vprint("Packet received! Handling...")
local mType = env["type"]
local sender = env["sender"]
local data = env["contents"]
local senderId = data["sender_id"]
local mProto = base64.from_base64(data["protocol"])
local msg = base64.from_base64(data["message"])
local sig = data["signature"]
if savePackets then savePacket(env) end
if processable(sig) then
if mType == "p2p" then
local dest = data["dest"]
vprint("P2P packet...")
if dest == ident then
vprint("...got it!")
pushDownwards(data)
else
vprint("...repropegating!")
repropegate("p2p", data) -- Pass it along if it isn't ours.
end
end
if mType == "broadcast" then
vprint("Broadcast packet!")
pushDownwards(data)
repropegate("broadcast", data)
end
end
else
vprint("Error in de-serialization, sender is " .. tostring(sender) .. ".")
end
end
end
I know this because in the output of the program, "Beginning loop run…" is shown, but "I got something…" never appears, ever, even when I send a barrage of both P2P and broadcast messages over both wired and wireless modems. Yes, I am sure that I opened the modem, as the red ring at the base of the modem(s) turns on.