Posted 12 April 2016 - 02:48 PM
Hi everyone,
I am creating a program to manage my inventory (there is a warehouse with a computing system to sort my inventory by type, send and receive items) based on a client-server communication with a modem.
One of my function verify how many servers can communicate with this computer (as a ping function). I use a timer to define when it stops its verification and it show the results.
My problem is, when an event is detected, the program send an error
Here is the line witch make an error
Can you help me please ?
I am creating a program to manage my inventory (there is a warehouse with a computing system to sort my inventory by type, send and receive items) based on a client-server communication with a modem.
One of my function verify how many servers can communicate with this computer (as a ping function). I use a timer to define when it stops its verification and it show the results.
function ping()
local overtime = 5
local event, timer = ""
local contactedServers = {}
local frame, parameter, cuttedframe = {}
local continue = true
frame[1] = "-1" -- Every servers are contacted
frame[2] = localID -- ID of this computer
frame[3] = "ping"
os.sleep(1)
envoiframe(frame) -- Sending frame
timer = os.startTimer(overtime) -- Starting timer
repeat -- We contact every servers until the timer is overpassed
event, parameter[1], parameter[2], parameter[3], parameter[4], parameter[5] = os.pullEvent()
if event == "modem_message" then
cuttedframe = split(parameter[4], ';') -- Cutting frame
if cuttedframe[2] == tostring(IDlocal) and cuttedframe[3] == "pingAcknoledge" then -- If we receive an acknoledge from a
table.insert(contactedServers, frame[3]) -- server, it is inserted in the table contactedServers
end
elseif event == "timer" and parameter[1] == timer then -- If the timer is overpassed, we show the results
continue = false
end
until continue == false
-- We show the results here
end
My problem is, when an event is detected, the program send an error
Index expected, got nil
Here is the line witch make an error
event, parameter[1], parameter[2], parameter[3], parameter[4], parameter[5] = os.pullEvent()
Can you help me please ?