MightyPirates / OpenComputers

Home of the OpenComputers mod for Minecraft.
https://oc.cil.li
Other
1.59k stars 430 forks source link

event.pull("modem_message") - does not work! #2681

Closed uehlbran closed 6 years ago

uehlbran commented 6 years ago

I have two, tier 3 computers both with wireless cards, and power.

On one, I go into the lua interpreter, and enter, event.pull("modem_message"), it has port 123 open. On the other computer who also has port 123 open, I enter, component.modem.send("address"., 123, "test")

On the first computer it never does anything but sit and wait forever frozen. It doesn't get any event. I also tried event.pull("modem"), and got the same results.

With the horrible documentation, and I don't mean to flame or be an ass, but come on!!!!! Document and keep it somewhat up-to date. The amount of misinformation, lack of information and so-on makes this mod near impossible to use by anyone! Which is evident by the fact that millions of people play minecraft, and maybe 100 use OC or understand the thing. It's sad! I want to use to the mod, learn it, and so-on, but it's near impossible in the current state.

wiring them together with a relay in the middle set to repeat and it works (broadcasts only). However, the wireless cards in this mod must be broken or I don't know... I've tried everything from any and all documentation that exists.

The computers are 3 blocks away from each other, nothing blocking them but air.

skyem123 commented 6 years ago
  1. Have you tried with wired networks? Dunno if it'll help though, though it's probably a good idea to try. (on that note, how far apart are the computers?)
  2. Your code seems to be correct? I do remember having some odd issues with modems before, have you tried doing it in a program, not the lua shell?
  3. The documentation is not great, but there's not much people can do when it's unpaid and done in people's spare time. To be honest, the one for the network card isn't bad... When I've used the docs, the worst there is that it's missing the more recent details and nuances.
uehlbran commented 6 years ago

Skyem,

My original post contains most of the info you asked for. I edited it just a second ago before you posted, haha.

Wiring them together with a relay in the middle set to repeat and broadcasts do work. however, using just send with an address does not.

the computers are 3 blocks apart, nothing between them but air.

It does seem if you hardwire them, put a relay in the middle, send a message it works, then break the relay, unhardwire them and broadcasts continue to work. Until you move either computer that is. modem.send, however, never works.

I assume you have something screwed up with wireless cards or GUIDs. Which is why hard wiring them fixes whatever issue that is and allows wireless to then work until GUID's change.

skyem123 commented 6 years ago

Okay... This might be a bug? First off, what version of Minecraft and what version of OC? Secondly, to confirm, these are (tier two, if that's mentioned) wireless cards, right? Thirdly, note that the address for networking is the address of the network cards themselves, not the address of the computer, sorry if you already knew that, but just trying to cover every possiblity.

uehlbran commented 6 years ago

OC Version = 1.6.8 Minecraft Version = 1.12.2

They don't have tiers on my side. They just say wireless network cards, but they do go into a tier 2 slot on the computer (motherboard).

I replicated the issue in another world, and again, it was fixed by hard wiring, sending a broadcast, and then broadcasts continue to work until you move either computer (you can remove cables and relays so it is then wireless). modem.send, does not ever work still.

I think I was using the address of the computers and not the NICs, but how do I copy the address of the NIC? I can't sneak+ctrl+click on it like I can a computer?

So, manually entering the NICs address fixes the send issue, but you still have to hardwire them first in order for wireless to work.

skyem123 commented 6 years ago

Alright, is it possible for you to upgrade your version of OC? The latest version is 1.7.1. And just to confirm, what addresses are you using?

uehlbran commented 6 years ago

So, manually entering the NICs address fixes the send issue, but you still have to hardwire them first in order for wireless to work. How can you copy the NICs address? Can you somehow use an analyzer on it or copy it from the terminal? Manually entering it is a pain, but I can live with that if not. Same applies to broadcasts. They have to be hardwired, send a message, and then wireless works.

I will try to update.

skyem123 commented 6 years ago

I think you probably have to manually enter the UUID of network cards... Maybe there is a way to automate that, if not, there definitely should be. Out of curiosity, what is the result of component.modem.getStrength() on both computers?

uehlbran commented 6 years ago

The result is 400 for both.

payonel commented 6 years ago

i like to use broadcast to initiate communication and record addresses, rather than write them manually

skyem123 commented 6 years ago

Okay that definitely smells like a bug (and also a feature request?), to confirm, could you update it to OC 1.7.1, just in case?

uehlbran commented 6 years ago

Ok, so that would explain part of it. Hard wiring them, and sending a broadcasts lets them register the MAC address's (maybe?). Which they arn't doing over wireless for some reason. Hard wring them first, sending a BC resolves this.

I updated to 1.7.1 and the issue is still here. You must first hardwire everything, and then send a BC. After that wireless works for both BC's and modem.send.

skyem123 commented 6 years ago

That's very odd, you shouldn't need to wire everything physically first. That is almost certainly a bug!

uehlbran commented 6 years ago

Would seem so...

Maybe you can help me with another issue? How do you execute functions on components over wireless? for example, if i have a computer with a wireless card, and I want to send something like this, component.modem.send(address, port, component.redstone.setOutput(sides.left, 15) to a relay connected to redstone is that possible? I know we can't send functions so how do we do something like this? I assume a way exists but I'm not sure what that would be.

skyem123 commented 6 years ago

That's uh... Not possible in the way you describe it. However you can write server software (in Lua, running on the computer that has the redstone) that handles commands you send it.

payonel commented 6 years ago

sorry, this bug does not repro for me please consider my screen shots

step 1, setup on computer A

image

step 2, send modem message broadcast from computer B

image

step 3, confirm message received image

uehlbran commented 6 years ago

Ok, and then use something like event.listen to capture the packets sent wirelessly to it that execute a program?

payonel commented 6 years ago

@uehlbran can you join #oc on esper net? that would be a better place to discuss program ideas. let's try to keep this ticket to your bug report

payonel commented 6 years ago

https://webchat.esper.net/?channels=oc

uehlbran commented 6 years ago

I joined. I don't have much time left though before I have to go so hopefully I'll catch you later tonight!

payonel commented 6 years ago

Document and keep it somewhat up-to date. The amount of misinformation, lack of information and so-on makes this mod near impossible to use by anyone!

@uehlbran Please give specific pages and what information specifically is missing to #2686

Also, please update this ticket -- consider my screenshots. I cannot repro this bug. Let me know what you are doing differently to let me resolve this ticket

payonel commented 6 years ago

it sounds more like you are using modem.send incorrectly, please update this ticket after reviewing my screenshots.

uehlbran commented 6 years ago

Payonel, I did the same steps. I'm aware of how-to use the command. I don't know why it was occuring but it seems to have resolved itself. I'm not sure why.

I did notice that this command, component.modem.open(port here), would on occasion require the command twice before actually opening the port. Can't get it to reproduce though. Might have been another mod, old files or... honestly, not sure.

However, everything seems to be fine today.

payonel commented 6 years ago

ok, well i'd be happy to investigate this further if you can see a repro

skyem123 commented 6 years ago

To be fair, I think I've encountered this before... Everything was setup correctly but it didn't work until I rebuilt everything? Sadly it's a pain to reproduce, but maybe there's value in noting that... (annoyingly I no longer have the world any more)

xarses commented 6 years ago

fwiw, (@payonel this might be a wiki stub) I have to debug most of my wired builds, something doesn't work right at first. When it happens I use relays to detect the traversal of messages, as they light up in world, if you place your self just right you can ensure message traversal. Second aspect I use, is dmesg which slightly similar, but not at all the same as the posix tool of the same name, it emits every event received by the computer. Keeping in mind that you have to open a port before the message received event fires. I've been able to work out some of the nuances of it.

payonel commented 6 years ago

@xarses agreed - this should be covered in the wiki with your troubleshooting advice included. There is a item for this, see where I mentioned "demo how to send messages" (perhaps this text was a bit terse, but this is what I was thinking of)

purplemonday commented 6 years ago

i recall something like this.. however its specific to 168 and not 170,171 its something in lib/event.lua that will. eat the rest messages once a os.sleep() or yield like thing happends. i can recall its a sure case repro if you use 1.6.8 higher versions dont suffer from it.

tried to recreate it on 171 and failed. 168 does show lost messages with the same code. witch is just a os.sleep(0.1) after the event,

payonel commented 6 years ago

the event distribution layer is definitely more robust these days. It is now safe to call sleep or computer.pullSignal -- the signals are still distributed to all listeners and all threads. I can see how this might have caused some user code headaches previously

purplemonday commented 6 years ago

@payonel perhaps you need to add the fact that this behaviour has chanced to the documentation if you not already have done so. would avoid people with a older version going for a loop.

payonel commented 6 years ago

well it's not really a change in expected behavior, it was a few bug fixes. openos doesn't LOSE signals like it used to

purplemonday commented 6 years ago

then least mention the fact 168 doesnt work right and actually looses signals and doest reflect the current docs just these tiny detail helps somuch in learing openos. and the only person truly understanding openos is probably you. so this stuff is so natural to asume these 'lil' things for you. meenwhile you need to have this sort of cult education to know what your doing without going for this insanity loop with what OC got to offer. sarcasm

other side of the coin, people would stop waisting time trying to get it to work on 1.6.8 and getting verry angry at you when the answer is burried in thosands of github pages, i meen just my 2 cents.. ill shutup now.

skyem123 commented 6 years ago

There is probably value in noting that earlier versions are broken in documentation, so people don't pull their hair out. :p

sevanescence commented 4 years ago

A bit late but I found the problem. Likely copied the network card in creative, so the UUIDs matched, and since modems won't register their own hardware, the matching UUID prevents the registry. I hope this helps, albeit kinda late.