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

Rednet crashing when modem is not hooked up directly

Started by ElvishJerricco, 25 June 2013 - 03:33 AM
ElvishJerricco #1
Posted 25 June 2013 - 05:33 AM
Normally you can't attach a modem as a peripheral on a network cable. You have to attach it directly to a computer. But OpenPeripheral adds the Peripheral Proxy, which allows you to put a modem on the network that way. But the rednet API does an isOpen() call, which does a check to make sure the side is valid, every time a modem_message is received. The problem is that it uses a tValidSides table, which just has the rs.getSides() values in it. So receiving any modem messages this way causes a crash. The obvious fix is to use peripheral.getType(side) == "modem" instead of tValidSides, so it's not a huge bug. But it's an easily fixed one that allows for a bit more functionality.
Cloudy #2
Posted 25 June 2013 - 10:55 AM
Not going to fix this. It isn't supposed to be connected this way. If you want this, bypass the rednet API.
ElvishJerricco #3
Posted 25 June 2013 - 12:53 PM
Not going to fix this. It isn't supposed to be connected this way. If you want this, bypass the rednet API.

I'd be fine with that if that were possible. Without completely killing the shell and writing one from scratch that won't automatically reload the Rednet API, there is no way to kill the rednet coroutine. And as long as that coroutine runs, the entire system will crash any time a message is received. And just to be clear, this is any time. You don't have to be calling rednet.receive or anything like that.
Lyqyd #4
Posted 25 June 2013 - 01:40 PM
Have you seen NeverCast's Top Level Coroutine Override? Using that to spawn a new shell with a patched version of the rednet coroutine in parallel may provide the workaround you're looking for.
ElvishJerricco #5
Posted 25 June 2013 - 02:05 PM
Have you seen NeverCast's Top Level Coroutine Override? Using that to spawn a new shell with a patched version of the rednet coroutine in parallel may provide the workaround you're looking for.

Project NewLife uses its own top level coroutine override, so I know how to do all that. But the point is that someone shouldn't have to go to those lengths in order to use this when the fix is extremely simple. Two lines later in the rednet code it does a getType call to see that it's a modem. The tValidSides check is unnecessary, even from a point of view not taking this situation into account.
Lyqyd #6
Posted 25 June 2013 - 03:08 PM
Well, changing that would apparently run counter to an intentional design decision (that modems only be connected directly). It's a little unfortunate that the coroutine override is needed to bypass this restriction if one really wishes to do so, though I can understand the developers' point of view, especially the unwillingness to "fix" something that is only broken when using another mod that intentionally bypasses a restriction that the developers added.
Cloudy #7
Posted 25 June 2013 - 09:29 PM
The fix may be simple, but the modems are never intended to be used that way, and we will not support them in that way. Simples!