diff --git a/storage-net/common.lua b/storage-net/common.lua index d965108..bd0a4b7 100644 --- a/storage-net/common.lua +++ b/storage-net/common.lua @@ -42,7 +42,6 @@ function c_waitForMessage() (message["networkid"] ~= networkid) or -- Ignore packets from other networks (message["targetid"] and message["targetid"] ~= os.getComputerID) -- Ignore packets for other machines then - print("Discarded nonconformant message") return nil end return message @@ -60,7 +59,7 @@ function c_sendMessage(message) for k,v in pairs(message) do msg[k] = v end - print("Transmitting message: " .. textutils.serialize(msg)) + --print("Transmitting message: " .. textutils.serialize(msg)) rednet.broadcast(msg, packet_magic) end @@ -73,10 +72,16 @@ function m_loop() return end if msg["type"] == "pong" then - print("Received pong from slave: " .. msg["sourceid"]) + local source = msg["sourceid"] + print("Received pong from slave: " .. source) + m_slaves[source] = source end end function m_ping() + -- Clear out the list of all slaves and send out a fresh ping + -- Ping information isn't used for much, so delay in clearing cache and + -- repopulating the data isn't a big deal. + m_slaves = {} c_sendMessage({type="ping"}) end @@ -104,8 +109,8 @@ function main () rednet.open(modem_side) print("Pinging for slaves...") - c_sendMessage({type="ping"}) - + m_ping() + print("Entering main loop") c_mainLoop(m_loop) elseif (mode == "slave") then