Jump to content




Rednet messages being ignored


  • You cannot reply to this topic
4 replies to this topic

#1 Exerro

  • Members
  • 801 posts

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:
Spoiler

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 by awsumben13, 07 November 2014 - 12:29 AM.


#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 07 November 2014 - 02:55 AM

The code you've provided here isn't the code you're using to receive the messages! This makes it difficult to comment on where you might've gone wrong with it. ;)

While there is code in CC1.6+ which could cause rednet messages to be missed, the odds of it happening to any given message are remote. Seeing it occur multiple times in a row would be something akin to winning every lottery ticket you ever buy.

My guess is that you'd somehow disabled the rednet.run() function via your threading mechanism. Rednet message events don't occur "automatically", a bit of code that generally runs in parallel with CraftOS spits them out.

#3 Exerro

  • Members
  • 801 posts

Posted 07 November 2014 - 11:09 AM

The threading basically just adds a coroutine to a list, so I don't see how that could stop rednet.run() as that still runs on a higher level than the OS itself. The only thing I can think of is coroutine.yield() not returning rednet_messages, although that wouldn't explain why the first one is caught.
Receiver code
Spoiler

I commented out a couple of lines so I could replace them with detecting modem_message events. Using modem_message events, it works perfectly, and gets all the messages, so I doubt it is a problem with my code.

Sending code...
Spoiler

Thanks for replying

Edited by awsumben13, 07 November 2014 - 11:09 AM.


#4 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 08 November 2014 - 12:50 AM

Can't see anything obvious there. Got the code for managing your co-routine list?

#5 Exerro

  • Members
  • 801 posts

Posted 08 November 2014 - 05:12 PM

Probably not the easiest thing to read on the forums, sorry...
Spoiler
Thread.update() is called in the main update loop at every event or update timer. (with the event of course)

Any idea why a modem_message event wouldn't trigger a rednet_message event though? There's definitely something fishy going on with rednet here. I don't think it's a problem with my code because when I switched it to use modem_message events instead it worked absolutely fine. If it was my code that was the problem, it would be that the multitasking bit was filtering rednet_message events, which as you can see it doesn't do.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users