Posted 11 July 2012 - 05:45 PM
Hey guys,
I have some issues with rednet.send() when I use that command inside a lua program. However, when I open the lua console and write the command there everything is fine.
Test setup:
server <-> client
server tasks:
loops forever on os.pullEvent("rednet_message"), sends response whether received command was valid or not (for later use).
client tasks:
sends command to server and waits for ACK.
server:
client:
The issue: As you probably see I put the rednet.send() commands inside a print() command to debug its return value. For the client everything works great, but the server rednet.send() however returns "false".
If I sequence the commands manually inside the lua prompt -> everything works ?!
So, if anyone could explain me, why my server is unable to send rednet messages inside programs, I would be really happy. A possible solution/workaround is also welcome.
greetings,
foxxx0
PS: I'm from Germany so please excuse mistakes in language :)/>/>
I have some issues with rednet.send() when I use that command inside a lua program. However, when I open the lua console and write the command there everything is fine.
Test setup:
server <-> client
server tasks:
loops forever on os.pullEvent("rednet_message"), sends response whether received command was valid or not (for later use).
client tasks:
sends command to server and waits for ACK.
server:
local rnetSource = "left" -- rednet input from left
rednet.open(rnetSource) -- enable receiving
while true do
event, sender, message = os.pullEvent("rednet_message") -- wait for event to happen
print("msg from #" .. sender .. ": " .. message)
print(rednet.send(sender, "got your message"))
end
rednet.close(rnetSource)
client:
local rnetSource = "back" -- rednet input from back
local target = 11 -- serverID
rednet.open(rnetSource) -- enable receiving
sleep(5)
print(rednet.send(target, "Test msg"))
event, sender, message = os.pullEvent("rednet_message")
print("msg from #" .. sender .. ": " .. message)
rednet.close(rnetSource)
The issue: As you probably see I put the rednet.send() commands inside a print() command to debug its return value. For the client everything works great, but the server rednet.send() however returns "false".
If I sequence the commands manually inside the lua prompt -> everything works ?!
So, if anyone could explain me, why my server is unable to send rednet messages inside programs, I would be really happy. A possible solution/workaround is also welcome.
greetings,
foxxx0
PS: I'm from Germany so please excuse mistakes in language :)/>/>