Posted 07 November 2014 - 12:13 AM
Hi,
I am writing a connection library for Nova, which uses rednet. I have been trying to get my head around it not working for about 3 hours now, and have only just narrowed it down to the problem.
It appears the messages being sent from computer A (which I have confirmed being sent) are actually queueing modem_message events on computer B, but not rednet_message events. For example, if I send the same string 3 times to the other computer, it gets the first one fine, but the next 2 are ignored by rednet.
Here is a screenshot which shows what is going on: http://puu.sh/cGb1V/9ca88d9cfb.png
As you can see, it gets a modem_message and rednet_message at the top. This is while the connection is being established, and that queues the http_connection event next.
After that, it gets another modem_message and rednet_message event, which is the first of the 3 messages it should be getting. The next modem_message isn't followed by a rednet_message, and same for the one after that.
I'm not sure if it's something I'm doing wrong, a rednet bug, or… well I really don't know.
Does anybody know what is going on here, or will I have to stop using rednet?
P.S.
The code sending the packets is identical. Literally nothing changes between them. It encrypts the data with the same key, and uses rednet.send( target, packet, "NovaNetwork" ) for both. The modem message events show this too, only the table id is changing.
Important sections of code:
Receiving computer…
I must point out that the problem here is the fact that rednet_message events aren't getting queued, not problems with the code above. If you would like to test for yourself, and see log files, etc, I can compile the latest version of Nova to give you, but I doubt it will help very much as you won't understand much of what is going on without further explanation.
Thank you for reading.
Edit:
After making a couple of changes to make it use modem.transmit() rather than rednet.send() it works fine. All 3 messages are received by receiving computer. In fact, even the ftp feature is working great (spoilers ;)/>). This is definitely a rednet problem, or at least a problem with how I'm using rednet. Is there some kind of spam protection? Because there are definitely messages that when encrypted are identical, so maybe rednet is ignoring them deliberately? There is nothing on the wiki about it, and I also tried just doing rednet.send(1, "hello") 3 times on different computers and that worked. I'm at a loss here.
I am writing a connection library for Nova, which uses rednet. I have been trying to get my head around it not working for about 3 hours now, and have only just narrowed it down to the problem.
It appears the messages being sent from computer A (which I have confirmed being sent) are actually queueing modem_message events on computer B, but not rednet_message events. For example, if I send the same string 3 times to the other computer, it gets the first one fine, but the next 2 are ignored by rednet.
Here is a screenshot which shows what is going on: http://puu.sh/cGb1V/9ca88d9cfb.png
As you can see, it gets a modem_message and rednet_message at the top. This is while the connection is being established, and that queues the http_connection event next.
After that, it gets another modem_message and rednet_message event, which is the first of the 3 messages it should be getting. The next modem_message isn't followed by a rednet_message, and same for the one after that.
I'm not sure if it's something I'm doing wrong, a rednet bug, or… well I really don't know.
Does anybody know what is going on here, or will I have to stop using rednet?
P.S.
The code sending the packets is identical. Literally nothing changes between them. It encrypts the data with the same key, and uses rednet.send( target, packet, "NovaNetwork" ) for both. The modem message events show this too, only the table id is changing.
Important sections of code:
Spoiler
Sending computer…
local connection, err = network.connection.establish( tonumber( response ), "http" )
if connection then
for i = 1, 3 do -- for debugging purposes, not any actual application.
os.log( connection:send( message ) ) -- the log file shows that this does send. (and other computer gets the modem_message event)
sleep( .5 )
end
app.display.alert "Message sent" ( )
else
app.display.alert( err ) ( )
end
Receiving computer…
if event == "http_connection" then
local connection = network.connection.get( cid ) -- gets the connection object, cid is event[2] basically
table.insert( buffer, "connection established with " .. connection:getPeer( ) )
app.newThread( function( ) -- runs in a seperate coroutine getting all events
while true do
local data, err = connection:receive( 1 )
if data then
table.insert( buffer, data ) -- gets 1 message, but not the next 2
else
table.insert( buffer, "error: " .. tostring( err ) )
break
end
end
end )
end
I must point out that the problem here is the fact that rednet_message events aren't getting queued, not problems with the code above. If you would like to test for yourself, and see log files, etc, I can compile the latest version of Nova to give you, but I doubt it will help very much as you won't understand much of what is going on without further explanation.
Thank you for reading.
Edit:
After making a couple of changes to make it use modem.transmit() rather than rednet.send() it works fine. All 3 messages are received by receiving computer. In fact, even the ftp feature is working great (spoilers ;)/>). This is definitely a rednet problem, or at least a problem with how I'm using rednet. Is there some kind of spam protection? Because there are definitely messages that when encrypted are identical, so maybe rednet is ignoring them deliberately? There is nothing on the wiki about it, and I also tried just doing rednet.send(1, "hello") 3 times on different computers and that worked. I'm at a loss here.
Edited on 06 November 2014 - 11:29 PM