This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
grabie2's profile picture

getting side on which rednet message arrived

Started by grabie2, 16 December 2012 - 08:26 AM
grabie2 #1
Posted 16 December 2012 - 09:26 AM
Hello everyone!

I need to know on which side rednet(from modems and cables) message arrived, BUT without modifying any rom files. If anyone has ANY idea how to do this, please write it here.

Also I need to poke dan200 for undocumented events like "open", "close" and "send"

Thanks a lot!
dissy #2
Posted 16 December 2012 - 09:43 AM
There really isn't a "default" way, since by default there are only rednet modems (so limited to that, there is no need to know the side)

The addition of cables is what makes it a special case, so any method to determine which it came from would also have to be a special case unfortunately.
Especially so if the cable addon is purposely trying to make messages look like normal rednet events instead of a unique event type.

Herhaps you could look into using a lan cable mod that already does this?
Lyqyd #3
Posted 16 December 2012 - 11:04 AM
This is not possible without modifying ROM.

Open, close and send "events" don't need documentation, since they aren't even real events.
grabie2 #4
Posted 16 December 2012 - 11:17 AM
There are not impossible things on the world! :D/>
(But sometimes they are, so hard, that it looks impossible)

Why Open, close and send aren't "real" events?

Thanks for real fast replies!
theoriginalbit #5
Posted 16 December 2012 - 01:37 PM
they are a state toggle and function call, not a trigger. (if I understand the implementation correctly)
Lyqyd #6
Posted 16 December 2012 - 02:06 PM
There are not impossible things on the world! :D/>
(But sometimes they are, so hard, that it looks impossible)

Okay. It is possible to get access to that data without modifying ROM, but it's going to be pretty tricky. Why do you need it?


Why Open, close and send aren't "real" events?

They're passed in as parameters when resuming the rednet coroutine rather than being triggered as events. They may look like events to that coroutine, but no other coroutines ever see those "events", which would not be true of actual events.
grabie2 #7
Posted 23 January 2013 - 07:15 AM
Oww, sorry I forgot about that thread.

@Lyqyd
I need to know which modem received data to make routing possible, but I done it program way - I check(in my OS that exist) MAC address of modem and one passed n packet. I'm not afraid of tricky things, how is it possible? I read rednet API couple times and I didn't find anything that could help.

Thanks for replies!
ChunLing #8
Posted 23 January 2013 - 08:16 AM
You can have the receiving computer send an acknowledgment (perhaps with useful information). That's what I typically do.

But there's no magic reason that the sender would know the message was received otherwise.
Eric #9
Posted 23 January 2013 - 09:17 AM
The rednet API is completely lua side, and as such, completely rewritable and not strictly necessary. Large amounts of it are for (wired) redpower comms anyway. You can do all the work yourself


local modem = peripheral.wrap("top")
modem.send(id, message)
local response = {os.pullEvent("rednet_message")}

Note that the "rednet_message" is both emulated by rednet and native to the modem. Since in general you can't determine which peripheral an event comes from, finding the side is impossible.

Unless you're talking about redpower comms…
grabie2 #10
Posted 23 January 2013 - 09:55 AM
yea, I was just surprised that Lyqyd said that it's possible. As I said I used MAC addresses for identification and rednet.broadcast.

However thanks for reply!
(Thread can be closed)